CArtifactsOfHeroMain.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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::keyPressed(EShortcut key)
  31. {
  32. if(!shortcutPressed)
  33. {
  34. uint32_t costumeIdx;
  35. switch(key)
  36. {
  37. case EShortcut::HERO_COSTUME_0:
  38. costumeIdx = 0;
  39. break;
  40. case EShortcut::HERO_COSTUME_1:
  41. costumeIdx = 1;
  42. break;
  43. case EShortcut::HERO_COSTUME_2:
  44. costumeIdx = 2;
  45. break;
  46. case EShortcut::HERO_COSTUME_3:
  47. costumeIdx = 3;
  48. break;
  49. case EShortcut::HERO_COSTUME_4:
  50. costumeIdx = 4;
  51. break;
  52. case EShortcut::HERO_COSTUME_5:
  53. costumeIdx = 5;
  54. break;
  55. case EShortcut::HERO_COSTUME_6:
  56. costumeIdx = 6;
  57. break;
  58. case EShortcut::HERO_COSTUME_7:
  59. costumeIdx = 7;
  60. break;
  61. case EShortcut::HERO_COSTUME_8:
  62. costumeIdx = 8;
  63. break;
  64. case EShortcut::HERO_COSTUME_9:
  65. costumeIdx = 9;
  66. break;
  67. default:
  68. return;
  69. }
  70. shortcutPressed = true;
  71. LOCPLINT->cb->manageHeroCostume(getHero()->id, costumeIdx, GH.isKeyboardCtrlDown());
  72. }
  73. }
  74. void CArtifactsOfHeroMain::keyReleased(EShortcut key)
  75. {
  76. if(vstd::contains(costumesSwitcherHotkeys, key))
  77. shortcutPressed = false;
  78. }