CArtifactsOfHeroMain.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * CArtifactsOfHeroMain.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "CArtifactsOfHeroMain.h"
  12. #include "../gui/CGuiHandler.h"
  13. #include "../CPlayerInterface.h"
  14. #include "../../lib/mapObjects/CGHeroInstance.h"
  15. #include "../../CCallback.h"
  16. #include "../../lib/networkPacks/ArtifactLocation.h"
  17. CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
  18. {
  19. init(
  20. std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2),
  21. std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2),
  22. position,
  23. std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
  24. addGestureCallback(std::bind(&CArtifactsOfHeroBase::gestureArtPlace, this, _1, _2));
  25. }
  26. CArtifactsOfHeroMain::~CArtifactsOfHeroMain()
  27. {
  28. CArtifactsOfHeroBase::putBackPickedArtifact();
  29. }
  30. void CArtifactsOfHeroMain::enableArtifactsCostumeSwitcher()
  31. {
  32. size_t costumeIdx = 0;
  33. for(const auto & hotkey : costumesSwitcherHotkeys)
  34. {
  35. auto keyProc = costumesSwitcherProcessors.emplace_back(std::make_shared<CKeyShortcut>(hotkey,
  36. [this, costumeIdx]()
  37. {
  38. LOCPLINT->cb->manageHeroCostume(getHero()->id, costumeIdx, GH.isKeyboardCtrlDown());
  39. }));
  40. keyProc->addUsedEvents(AEventsReceiver::KEYBOARD);
  41. costumeIdx++;
  42. }
  43. }