MiscWidgets.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #pragma once
  2. #include "../gui/CIntObject.h"
  3. /*
  4. * MiscWidgets.h, part of VCMI engine
  5. *
  6. * Authors: listed in file AUTHORS in main folder
  7. *
  8. * License: GNU General Public License v2.0 or later
  9. * Full text of license available in license.txt file, in main folder
  10. *
  11. */
  12. class CLabel;
  13. class CCreatureAnim;
  14. class CComponent;
  15. class CGGarrison;
  16. class CSelectableComponent;
  17. class InfoAboutArmy;
  18. class CArmedInstance;
  19. class IBonusBearer;
  20. class CAnimImage;
  21. /// Shows a text by moving the mouse cursor over the object
  22. class CHoverableArea: public virtual CIntObject
  23. {
  24. public:
  25. std::string hoverText;
  26. virtual void hover (bool on) override;
  27. CHoverableArea();
  28. virtual ~CHoverableArea();
  29. };
  30. /// Can interact on left and right mouse clicks, plus it shows a text when by hovering over it
  31. class LRClickableAreaWText: public CHoverableArea
  32. {
  33. public:
  34. std::string text;
  35. LRClickableAreaWText();
  36. LRClickableAreaWText(const Rect &Pos, const std::string &HoverText = "", const std::string &ClickText = "");
  37. virtual ~LRClickableAreaWText();
  38. void init();
  39. virtual void clickLeft(tribool down, bool previousState) override;
  40. virtual void clickRight(tribool down, bool previousState) override;
  41. };
  42. /// base class for hero/town/garrison tooltips
  43. class CArmyTooltip : public CIntObject
  44. {
  45. void init(const InfoAboutArmy &army);
  46. public:
  47. CArmyTooltip(Point pos, const InfoAboutArmy &army);
  48. CArmyTooltip(Point pos, const CArmedInstance * army);
  49. };
  50. /// Class for hero tooltip. Does not have any background!
  51. /// background for infoBox: ADSTATHR
  52. /// background for tooltip: HEROQVBK
  53. class CHeroTooltip : public CArmyTooltip
  54. {
  55. void init(const InfoAboutHero &hero);
  56. public:
  57. CHeroTooltip(Point pos, const InfoAboutHero &hero);
  58. CHeroTooltip(Point pos, const CGHeroInstance * hero);
  59. };
  60. /// Class for town tooltip. Does not have any background!
  61. /// background for infoBox: ADSTATCS
  62. /// background for tooltip: TOWNQVBK
  63. class CTownTooltip : public CArmyTooltip
  64. {
  65. void init(const InfoAboutTown &town);
  66. public:
  67. CTownTooltip(Point pos, const InfoAboutTown &town);
  68. CTownTooltip(Point pos, const CGTownInstance * town);
  69. };
  70. /// draws picture with creature on background, use Animated=true to get animation
  71. class CCreaturePic : public CIntObject
  72. {
  73. private:
  74. CPicture *bg;
  75. CCreatureAnim *anim; //displayed animation
  76. CLabel * amount;
  77. void show(SDL_Surface *to) override;
  78. public:
  79. CCreaturePic(int x, int y, const CCreature *cre, bool Big=true, bool Animated=true); //c-tor
  80. void setAmount(int newAmount);
  81. };
  82. /// Resource bar like that at the bottom of the adventure map screen
  83. class CMinorResDataBar : public CIntObject
  84. {
  85. public:
  86. SDL_Surface *bg; //background bitmap
  87. void show(SDL_Surface * to) override;
  88. void showAll(SDL_Surface * to) override;
  89. CMinorResDataBar(); //c-tor
  90. ~CMinorResDataBar(); //d-tor
  91. };
  92. /// Opens hero window by left-clicking on it
  93. class CHeroArea: public CIntObject
  94. {
  95. const CGHeroInstance * hero;
  96. public:
  97. CHeroArea(int x, int y, const CGHeroInstance * _hero);
  98. void clickLeft(tribool down, bool previousState) override;
  99. void clickRight(tribool down, bool previousState) override;
  100. void hover(bool on) override;
  101. };
  102. /// Can interact on left and right mouse clicks
  103. class LRClickableAreaWTextComp: public LRClickableAreaWText
  104. {
  105. public:
  106. int baseType;
  107. int bonusValue, type;
  108. virtual void clickLeft(tribool down, bool previousState) override;
  109. virtual void clickRight(tribool down, bool previousState) override;
  110. LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
  111. CComponent * createComponent() const;
  112. };
  113. /// Opens town screen by left-clicking on it
  114. class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
  115. {
  116. public:
  117. const CGTownInstance * town;
  118. void clickLeft(tribool down, bool previousState) override;
  119. void clickRight(tribool down, bool previousState) override;
  120. LRClickableAreaOpenTown();
  121. };
  122. class MoraleLuckBox : public LRClickableAreaWTextComp
  123. {
  124. CAnimImage *image;
  125. public:
  126. bool morale; //true if morale, false if luck
  127. bool small;
  128. void set(const IBonusBearer *node);
  129. MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
  130. };