MiscWidgets.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * MiscWidgets.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 "../gui/CIntObject.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CGGarrison;
  14. class CGCreature;
  15. struct InfoAboutArmy;
  16. class CArmedInstance;
  17. class AFactionMember;
  18. VCMI_LIB_NAMESPACE_END
  19. class CLabel;
  20. class CTextBox;
  21. class CGarrisonInt;
  22. class CCreatureAnim;
  23. class CComponent;
  24. class CAnimImage;
  25. /// Shows a text by moving the mouse cursor over the object
  26. class CHoverableArea: public virtual CIntObject
  27. {
  28. public:
  29. std::string hoverText;
  30. virtual void hover (bool on) override;
  31. CHoverableArea();
  32. virtual ~CHoverableArea();
  33. };
  34. /// Can interact on left and right mouse clicks, plus it shows a text when by hovering over it
  35. class LRClickableAreaWText: public CHoverableArea
  36. {
  37. public:
  38. std::string text;
  39. LRClickableAreaWText();
  40. LRClickableAreaWText(const Rect & Pos, const std::string & HoverText = "", const std::string & ClickText = "");
  41. virtual ~LRClickableAreaWText();
  42. void init();
  43. void clickPressed(const Point & cursorPosition) override;
  44. void showPopupWindow(const Point & cursorPosition) override;
  45. };
  46. /// base class for hero/town/garrison tooltips
  47. class CArmyTooltip : public CIntObject
  48. {
  49. std::shared_ptr<CLabel> title;
  50. std::vector<std::shared_ptr<CAnimImage>> icons;
  51. std::vector<std::shared_ptr<CLabel>> subtitles;
  52. void init(const InfoAboutArmy & army);
  53. public:
  54. CArmyTooltip(Point pos, const InfoAboutArmy & army);
  55. CArmyTooltip(Point pos, const CArmedInstance * army);
  56. };
  57. /// Class for hero tooltip. Does not have any background!
  58. /// background for infoBox: ADSTATHR
  59. /// background for tooltip: HEROQVBK
  60. class CHeroTooltip : public CArmyTooltip
  61. {
  62. std::shared_ptr<CAnimImage> portrait;
  63. std::vector<std::shared_ptr<CLabel>> labels;
  64. std::shared_ptr<CAnimImage> morale;
  65. std::shared_ptr<CAnimImage> luck;
  66. void init(const InfoAboutHero & hero);
  67. public:
  68. CHeroTooltip(Point pos, const InfoAboutHero & hero);
  69. CHeroTooltip(Point pos, const CGHeroInstance * hero);
  70. };
  71. /// Class for HD mod-like interactable infobox tooltip. Does not have any background!
  72. class CInteractableHeroTooltip : public CIntObject
  73. {
  74. std::shared_ptr<CLabel> title;
  75. std::shared_ptr<CAnimImage> portrait;
  76. std::vector<std::shared_ptr<CLabel>> labels;
  77. std::shared_ptr<CAnimImage> morale;
  78. std::shared_ptr<CAnimImage> luck;
  79. std::shared_ptr<CGarrisonInt> garrison;
  80. void init(const InfoAboutHero & hero);
  81. public:
  82. CInteractableHeroTooltip(Point pos, const CGHeroInstance * hero);
  83. };
  84. /// Class for town tooltip. Does not have any background!
  85. /// background for infoBox: ADSTATCS
  86. /// background for tooltip: TOWNQVBK
  87. class CTownTooltip : public CArmyTooltip
  88. {
  89. std::shared_ptr<CAnimImage> fort;
  90. std::shared_ptr<CAnimImage> hall;
  91. std::shared_ptr<CAnimImage> build;
  92. std::shared_ptr<CLabel> income;
  93. std::shared_ptr<CPicture> garrisonedHero;
  94. std::shared_ptr<CAnimImage> res1;
  95. std::shared_ptr<CAnimImage> res2;
  96. void init(const InfoAboutTown & town);
  97. public:
  98. CTownTooltip(Point pos, const InfoAboutTown & town);
  99. CTownTooltip(Point pos, const CGTownInstance * town);
  100. };
  101. /// Class for HD mod-like interactable infobox tooltip. Does not have any background!
  102. class CInteractableTownTooltip : public CIntObject
  103. {
  104. std::shared_ptr<CLabel> title;
  105. std::shared_ptr<CAnimImage> fort;
  106. std::shared_ptr<CAnimImage> hall;
  107. std::shared_ptr<CAnimImage> build;
  108. std::shared_ptr<CLabel> income;
  109. std::shared_ptr<CPicture> garrisonedHero;
  110. std::shared_ptr<CAnimImage> res1;
  111. std::shared_ptr<CAnimImage> res2;
  112. std::shared_ptr<CGarrisonInt> garrison;
  113. void init(const InfoAboutTown & town);
  114. public:
  115. CInteractableTownTooltip(Point pos, const CGTownInstance * town);
  116. };
  117. /// draws picture with creature on background, use Animated=true to get animation
  118. class CCreaturePic : public CIntObject
  119. {
  120. private:
  121. std::shared_ptr<CPicture> bg;
  122. std::shared_ptr<CCreatureAnim> anim; //displayed animation
  123. std::shared_ptr<CLabel> amount;
  124. void show(Canvas & to) override;
  125. public:
  126. CCreaturePic(int x, int y, const CCreature * cre, bool Big=true, bool Animated=true);
  127. void setAmount(int newAmount);
  128. };
  129. class CreatureTooltip : public CIntObject
  130. {
  131. std::shared_ptr<CAnimImage> creatureImage;
  132. std::shared_ptr<CTextBox> tooltipTextbox;
  133. public:
  134. CreatureTooltip(Point pos, const CGCreature * creature);
  135. };
  136. /// Resource bar like that at the bottom of the adventure map screen
  137. class CMinorResDataBar : public CIntObject
  138. {
  139. std::shared_ptr<CPicture> background;
  140. std::string buildDateString();
  141. public:
  142. void show(Canvas & to) override;
  143. void showAll(Canvas & to) override;
  144. CMinorResDataBar();
  145. ~CMinorResDataBar();
  146. };
  147. /// Opens hero window by left-clicking on it
  148. class CHeroArea: public CIntObject
  149. {
  150. const CGHeroInstance * hero;
  151. std::shared_ptr<CAnimImage> portrait;
  152. public:
  153. CHeroArea(int x, int y, const CGHeroInstance * _hero);
  154. void clickPressed(const Point & cursorPosition) override;
  155. void hover(bool on) override;
  156. };
  157. /// Can interact on left and right mouse clicks
  158. class LRClickableAreaWTextComp: public LRClickableAreaWText
  159. {
  160. public:
  161. int type;
  162. int baseType;
  163. int bonusValue;
  164. void clickPressed(const Point & cursorPosition) override;
  165. void showPopupWindow(const Point & cursorPosition) override;
  166. LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
  167. std::shared_ptr<CComponent> createComponent() const;
  168. };
  169. /// Opens town screen by left-clicking on it
  170. class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
  171. {
  172. public:
  173. const CGTownInstance * town;
  174. void clickPressed(const Point & cursorPosition) override;
  175. LRClickableAreaOpenTown(const Rect & Pos, const CGTownInstance * Town);
  176. };
  177. class MoraleLuckBox : public LRClickableAreaWTextComp
  178. {
  179. std::shared_ptr<CAnimImage> image;
  180. public:
  181. bool morale; //true if morale, false if luck
  182. bool small;
  183. void set(const AFactionMember *node);
  184. MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
  185. };