MiscWidgets.h 3.8 KB

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