CAltar.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * CAltar.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/CArtifactsOfHeroAltar.h"
  12. #include "../widgets/CTradeBase.h"
  13. class CSlider;
  14. class CAltar : public CTradeBase, public CIntObject
  15. {
  16. public:
  17. std::shared_ptr<CLabel> expToLevel;
  18. std::shared_ptr<CLabel> expForHero;
  19. std::shared_ptr<CButton> sacrificeAllButton;
  20. CAltar(const IMarket * market, const CGHeroInstance * hero);
  21. virtual ~CAltar() = default;
  22. virtual void sacrificeAll() = 0;
  23. virtual void deselect();
  24. virtual TExpType calcExpAltarForHero() = 0;
  25. };
  26. class CAltarArtifacts : public CAltar
  27. {
  28. public:
  29. CAltarArtifacts(const IMarket * market, const CGHeroInstance * hero);
  30. TExpType calcExpAltarForHero() override;
  31. void makeDeal() override;
  32. void sacrificeAll() override;
  33. void sacrificeBackpack();
  34. void setSelectedArtifact(const CArtifactInstance * art);
  35. void moveArtToAltar(std::shared_ptr<CTradeableItem>, const CArtifactInstance * art);
  36. std::shared_ptr<CArtifactsOfHeroAltar> getAOHset() const;
  37. private:
  38. std::shared_ptr<CArtPlace> selectedArt;
  39. std::shared_ptr<CLabel> selectedCost;
  40. std::shared_ptr<CButton> sacrificeBackpackButton;
  41. std::shared_ptr<CArtifactsOfHeroAltar> arts;
  42. const std::vector<Point> posSlotsAltar =
  43. {
  44. Point(317, 53), Point(371, 53), Point(425, 53),
  45. Point(479, 53), Point(533, 53), Point(317, 123),
  46. Point(371, 123), Point(425, 123), Point(479, 123),
  47. Point(533, 123), Point(317, 193), Point(371, 193),
  48. Point(425, 193), Point(479, 193), Point(533, 193),
  49. Point(317, 263), Point(371, 263), Point(425, 263),
  50. Point(479, 263), Point(533, 263), Point(398, 333),
  51. Point(452, 333)
  52. };
  53. bool putArtOnAltar(std::shared_ptr<CTradeableItem> altarSlot, const CArtifactInstance * art);
  54. void onSlotClickPressed(std::shared_ptr<CTradeableItem> altarSlot);
  55. };
  56. class CAltarCreatures : public CAltar
  57. {
  58. public:
  59. CAltarCreatures(const IMarket * market, const CGHeroInstance * hero);
  60. void updateGarrison();
  61. void deselect() override;
  62. TExpType calcExpAltarForHero() override;
  63. void makeDeal() override;
  64. void sacrificeAll() override;
  65. void updateAltarSlot(std::shared_ptr<CTradeableItem> slot);
  66. private:
  67. std::shared_ptr<CButton> maxUnits;
  68. std::shared_ptr<CSlider> unitsSlider;
  69. std::vector<int> unitsOnAltar;
  70. std::vector<int> expPerUnit;
  71. std::shared_ptr<CLabel> lSubtitle, rSubtitle;
  72. const std::vector<Point> posSlotsAltar =
  73. {
  74. Point(334, 110), Point(417, 110), Point(500, 110),
  75. Point(334, 208), Point(417, 208), Point(500, 208),
  76. Point(417, 306)
  77. };
  78. const std::vector<Point> posSlotsHero =
  79. {
  80. Point(45, 110), Point(128, 110), Point(211, 110),
  81. Point(45, 208), Point(128, 208), Point(211, 208),
  82. Point(128, 306)
  83. };
  84. void readExpValues();
  85. void updateControls();
  86. void updateSubtitlesForSelected();
  87. void onUnitsSliderMoved(int newVal);
  88. void onSlotClickPressed(std::shared_ptr<CTradeableItem> altarSlot,
  89. std::vector<std::shared_ptr<CTradeableItem>> & oppositeSlots,
  90. std::shared_ptr<CTradeableItem> & hCurSide, std::shared_ptr<CTradeableItem> & hOppSide);
  91. };