MiscWidgets.h 4.6 KB

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