CreaturePurchaseCard.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * CreaturePurchaseCard.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 "../widgets/Images.h"
  12. class CCreaturePic;
  13. class CSlider;
  14. class CButton;
  15. class CreatureCostBox;
  16. class QuickRecruitmentWindow;
  17. class CreaturePurchaseCard : public CIntObject
  18. {
  19. public:
  20. const CCreature * creatureOnTheCard;
  21. std::shared_ptr<CSlider> slider;
  22. QuickRecruitmentWindow * parent;
  23. int maxAmount;
  24. void sliderMoved(int to);
  25. CreaturePurchaseCard(const std::vector<CreatureID> & creaturesID, Point position, int creaturesMaxAmount, QuickRecruitmentWindow * parents);
  26. private:
  27. void initView();
  28. void initButtons();
  29. void initMaxButton();
  30. void initMinButton();
  31. void initCreatureSwitcherButton();
  32. void switchCreatureLevel();
  33. void initAmountInfo();
  34. void updateAmountInfo(int value);
  35. void initSlider();
  36. void initCostBox();
  37. // This just wraps a clickeable area. There's a weird layout scheme in the file and
  38. // it's easier to just add a separate invisible box on top
  39. class CCreatureClickArea : public CIntObject
  40. {
  41. public:
  42. CCreatureClickArea(const Point & pos, const std::shared_ptr<CCreaturePic> creaturePic, const CCreature * creatureOnTheCard);
  43. void showPopupWindow(const Point & cursorPosition) override;
  44. const CCreature * creatureOnTheCard;
  45. // These are obtained by guessing and checking. I'm not sure how the other numbers
  46. // used to set positions were obtained; commit messages don't document it
  47. static constexpr int CREATURE_WIDTH = 110;
  48. static constexpr int CREATURE_HEIGHT = 132;
  49. };
  50. std::shared_ptr<CButton> maxButton;
  51. std::shared_ptr<CButton> minButton;
  52. std::shared_ptr<CButton> creatureSwitcher;
  53. std::shared_ptr<CLabel> availableAmount;
  54. std::shared_ptr<CLabel> purchaseAmount;
  55. std::shared_ptr<CCreaturePic> picture;
  56. std::shared_ptr<CreatureCostBox> cost;
  57. std::vector<CreatureID> upgradesID;
  58. std::shared_ptr<CPicture> background;
  59. std::shared_ptr<CCreatureClickArea> creatureClickArea;
  60. };