CArtifactsOfHeroMain.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
  20. enableGesture();
  21. }
  22. CArtifactsOfHeroMain::~CArtifactsOfHeroMain()
  23. {
  24. CArtifactsOfHeroBase::putBackPickedArtifact();
  25. }
  26. void CArtifactsOfHeroMain::keyPressed(EShortcut key)
  27. {
  28. if(!shortcutPressed)
  29. {
  30. uint32_t costumeIdx;
  31. switch(key)
  32. {
  33. case EShortcut::HERO_COSTUME_0:
  34. costumeIdx = 0;
  35. break;
  36. case EShortcut::HERO_COSTUME_1:
  37. costumeIdx = 1;
  38. break;
  39. case EShortcut::HERO_COSTUME_2:
  40. costumeIdx = 2;
  41. break;
  42. case EShortcut::HERO_COSTUME_3:
  43. costumeIdx = 3;
  44. break;
  45. case EShortcut::HERO_COSTUME_4:
  46. costumeIdx = 4;
  47. break;
  48. case EShortcut::HERO_COSTUME_5:
  49. costumeIdx = 5;
  50. break;
  51. case EShortcut::HERO_COSTUME_6:
  52. costumeIdx = 6;
  53. break;
  54. case EShortcut::HERO_COSTUME_7:
  55. costumeIdx = 7;
  56. break;
  57. case EShortcut::HERO_COSTUME_8:
  58. costumeIdx = 8;
  59. break;
  60. case EShortcut::HERO_COSTUME_9:
  61. costumeIdx = 9;
  62. break;
  63. default:
  64. return;
  65. }
  66. shortcutPressed = true;
  67. LOCPLINT->cb->manageHeroCostume(getHero()->id, costumeIdx, GH.isKeyboardCtrlDown());
  68. }
  69. }
  70. void CArtifactsOfHeroMain::keyReleased(EShortcut key)
  71. {
  72. if(vstd::contains(costumesSwitcherHotkeys, key))
  73. shortcutPressed = false;
  74. }