CArtifactsOfHeroMain.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * CArtifactsOfHeroMain.h, 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. #pragma once
  11. #include "CArtifactsOfHeroBase.h"
  12. #include "../gui/Shortcut.h"
  13. class CArtifactsOfHeroMain : public CArtifactsOfHeroBase
  14. {
  15. public:
  16. CArtifactsOfHeroMain(const Point & position, bool costumesEnabled = false);
  17. ~CArtifactsOfHeroMain() override;
  18. private:
  19. // TODO may be removed if CKeyShortcut supports callbacks
  20. class CKeyShortcutWrapper : public CKeyShortcut
  21. {
  22. public:
  23. using KeyPressedFunctor = std::function<void()>;
  24. CKeyShortcutWrapper(const EShortcut & key, const KeyPressedFunctor & onCostumeSelect);
  25. void clickPressed(const Point & cursorPosition) override;
  26. private:
  27. KeyPressedFunctor onCostumeSelect;
  28. };
  29. const std::array<EShortcut, GameConstants::HERO_COSTUMES_ARTIFACTS> hotkeys =
  30. {
  31. EShortcut::HERO_COSTUME_0,
  32. EShortcut::HERO_COSTUME_1,
  33. EShortcut::HERO_COSTUME_2,
  34. EShortcut::HERO_COSTUME_3,
  35. EShortcut::HERO_COSTUME_4,
  36. EShortcut::HERO_COSTUME_5,
  37. EShortcut::HERO_COSTUME_6,
  38. EShortcut::HERO_COSTUME_7,
  39. EShortcut::HERO_COSTUME_8,
  40. EShortcut::HERO_COSTUME_9
  41. };
  42. std::vector<std::shared_ptr<CKeyShortcutWrapper>> costumesSwitchers;
  43. void onCostumeSelect(const size_t costumeIndex);
  44. };