MiscWidgets.h 5.7 KB

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