MiscWidgets.h 5.6 KB

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