MiscWidgets.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. class CArmedInstance;
  17. class AFactionMember;
  18. VCMI_LIB_NAMESPACE_END
  19. class CLabel;
  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 CGarrisonInt
  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. void init(const InfoAboutHero & hero);
  78. public:
  79. CInteractableHeroTooltip(Point pos, const CGHeroInstance * hero);
  80. };
  81. /// Class for town tooltip. Does not have any background!
  82. /// background for infoBox: ADSTATCS
  83. /// background for tooltip: TOWNQVBK
  84. class CTownTooltip : public CArmyTooltip
  85. {
  86. std::shared_ptr<CAnimImage> fort;
  87. std::shared_ptr<CAnimImage> hall;
  88. std::shared_ptr<CAnimImage> build;
  89. std::shared_ptr<CLabel> income;
  90. std::shared_ptr<CPicture> garrisonedHero;
  91. std::shared_ptr<CAnimImage> res1;
  92. std::shared_ptr<CAnimImage> res2;
  93. void init(const InfoAboutTown & town);
  94. public:
  95. CTownTooltip(Point pos, const InfoAboutTown & town);
  96. CTownTooltip(Point pos, const CGTownInstance * town);
  97. };
  98. /// Class for HD mod-like interactable infobox tooltip. Does not have any background!
  99. class CInteractableTownTooltip : public CGarrisonInt
  100. {
  101. std::shared_ptr<CLabel> title;
  102. std::shared_ptr<CAnimImage> fort;
  103. std::shared_ptr<CAnimImage> hall;
  104. std::shared_ptr<CAnimImage> build;
  105. std::shared_ptr<CLabel> income;
  106. std::shared_ptr<CPicture> garrisonedHero;
  107. std::shared_ptr<CAnimImage> res1;
  108. std::shared_ptr<CAnimImage> res2;
  109. void init(const InfoAboutTown & town);
  110. public:
  111. CInteractableTownTooltip(Point pos, const CGTownInstance * town);
  112. };
  113. /// draws picture with creature on background, use Animated=true to get animation
  114. class CCreaturePic : public CIntObject
  115. {
  116. private:
  117. std::shared_ptr<CPicture> bg;
  118. std::shared_ptr<CCreatureAnim> anim; //displayed animation
  119. std::shared_ptr<CLabel> amount;
  120. void show(Canvas & to) override;
  121. public:
  122. CCreaturePic(int x, int y, const CCreature * cre, bool Big=true, bool Animated=true);
  123. void setAmount(int newAmount);
  124. };
  125. /// Resource bar like that at the bottom of the adventure map screen
  126. class CMinorResDataBar : public CIntObject
  127. {
  128. std::shared_ptr<CPicture> background;
  129. std::string buildDateString();
  130. public:
  131. void show(Canvas & to) override;
  132. void showAll(Canvas & to) override;
  133. CMinorResDataBar();
  134. ~CMinorResDataBar();
  135. };
  136. /// Opens hero window by left-clicking on it
  137. class CHeroArea: public CIntObject
  138. {
  139. const CGHeroInstance * hero;
  140. std::shared_ptr<CAnimImage> portrait;
  141. public:
  142. CHeroArea(int x, int y, const CGHeroInstance * _hero);
  143. void clickPressed(const Point & cursorPosition) override;
  144. void hover(bool on) override;
  145. };
  146. /// Can interact on left and right mouse clicks
  147. class LRClickableAreaWTextComp: public LRClickableAreaWText
  148. {
  149. public:
  150. int type;
  151. int baseType;
  152. int bonusValue;
  153. void clickPressed(const Point & cursorPosition) override;
  154. void showPopupWindow(const Point & cursorPosition) override;
  155. LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
  156. std::shared_ptr<CComponent> createComponent() const;
  157. };
  158. /// Opens town screen by left-clicking on it
  159. class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
  160. {
  161. public:
  162. const CGTownInstance * town;
  163. void clickPressed(const Point & cursorPosition) override;
  164. LRClickableAreaOpenTown(const Rect & Pos, const CGTownInstance * Town);
  165. };
  166. class MoraleLuckBox : public LRClickableAreaWTextComp
  167. {
  168. std::shared_ptr<CAnimImage> image;
  169. public:
  170. bool morale; //true if morale, false if luck
  171. bool small;
  172. void set(const AFactionMember *node);
  173. MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
  174. };