| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- /*
- * MiscWidgets.h, part of VCMI engine
- *
- * Authors: listed in file AUTHORS in main folder
- *
- * License: GNU General Public License v2.0 or later
- * Full text of license available in license.txt file, in main folder
- *
- */
- #pragma once
- #include "../gui/CIntObject.h"
- VCMI_LIB_NAMESPACE_BEGIN
- class CGGarrison;
- struct InfoAboutArmy;
- class CArmedInstance;
- class AFactionMember;
- VCMI_LIB_NAMESPACE_END
- class CLabel;
- class CCreatureAnim;
- class CComponent;
- class CAnimImage;
- /// Shows a text by moving the mouse cursor over the object
- class CHoverableArea: public virtual CIntObject
- {
- public:
- std::string hoverText;
- virtual void hover (bool on) override;
- CHoverableArea();
- virtual ~CHoverableArea();
- };
- /// Can interact on left and right mouse clicks, plus it shows a text when by hovering over it
- class LRClickableAreaWText: public CHoverableArea
- {
- public:
- std::string text;
- LRClickableAreaWText();
- LRClickableAreaWText(const Rect & Pos, const std::string & HoverText = "", const std::string & ClickText = "");
- virtual ~LRClickableAreaWText();
- void init();
- void clickPressed(const Point & cursorPosition) override;
- void showPopupWindow(const Point & cursorPosition) override;
- };
- /// base class for hero/town/garrison tooltips
- class CArmyTooltip : public CIntObject
- {
- std::shared_ptr<CLabel> title;
- std::vector<std::shared_ptr<CAnimImage>> icons;
- std::vector<std::shared_ptr<CLabel>> subtitles;
- void init(const InfoAboutArmy & army);
- public:
- CArmyTooltip(Point pos, const InfoAboutArmy & army);
- CArmyTooltip(Point pos, const CArmedInstance * army);
- };
- /// Class for hero tooltip. Does not have any background!
- /// background for infoBox: ADSTATHR
- /// background for tooltip: HEROQVBK
- class CHeroTooltip : public CArmyTooltip
- {
- std::shared_ptr<CAnimImage> portrait;
- std::vector<std::shared_ptr<CLabel>> labels;
- std::shared_ptr<CAnimImage> morale;
- std::shared_ptr<CAnimImage> luck;
- void init(const InfoAboutHero & hero);
- public:
- CHeroTooltip(Point pos, const InfoAboutHero & hero);
- CHeroTooltip(Point pos, const CGHeroInstance * hero);
- };
- /// Class for town tooltip. Does not have any background!
- /// background for infoBox: ADSTATCS
- /// background for tooltip: TOWNQVBK
- class CTownTooltip : public CArmyTooltip
- {
- std::shared_ptr<CAnimImage> fort;
- std::shared_ptr<CAnimImage> hall;
- std::shared_ptr<CAnimImage> build;
- std::shared_ptr<CLabel> income;
- std::shared_ptr<CPicture> garrisonedHero;
- std::shared_ptr<CAnimImage> res1;
- std::shared_ptr<CAnimImage> res2;
- void init(const InfoAboutTown & town);
- public:
- CTownTooltip(Point pos, const InfoAboutTown & town);
- CTownTooltip(Point pos, const CGTownInstance * town);
- };
- /// draws picture with creature on background, use Animated=true to get animation
- class CCreaturePic : public CIntObject
- {
- private:
- std::shared_ptr<CPicture> bg;
- std::shared_ptr<CCreatureAnim> anim; //displayed animation
- std::shared_ptr<CLabel> amount;
- void show(Canvas & to) override;
- public:
- CCreaturePic(int x, int y, const CCreature * cre, bool Big=true, bool Animated=true);
- void setAmount(int newAmount);
- };
- /// Resource bar like that at the bottom of the adventure map screen
- class CMinorResDataBar : public CIntObject
- {
- std::shared_ptr<CPicture> background;
- std::string buildDateString();
- public:
- void show(Canvas & to) override;
- void showAll(Canvas & to) override;
- CMinorResDataBar();
- ~CMinorResDataBar();
- };
- /// Opens hero window by left-clicking on it
- class CHeroArea: public CIntObject
- {
- const CGHeroInstance * hero;
- std::shared_ptr<CAnimImage> portrait;
- public:
- CHeroArea(int x, int y, const CGHeroInstance * _hero);
- void clickPressed(const Point & cursorPosition) override;
- void hover(bool on) override;
- };
- /// Can interact on left and right mouse clicks
- class LRClickableAreaWTextComp: public LRClickableAreaWText
- {
- public:
- int type;
- int baseType;
- int bonusValue;
- void clickPressed(const Point & cursorPosition) override;
- void showPopupWindow(const Point & cursorPosition) override;
- LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
- std::shared_ptr<CComponent> createComponent() const;
- };
- /// Opens town screen by left-clicking on it
- class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
- {
- public:
- const CGTownInstance * town;
- void clickPressed(const Point & cursorPosition) override;
- LRClickableAreaOpenTown(const Rect & Pos, const CGTownInstance * Town);
- };
- class MoraleLuckBox : public LRClickableAreaWTextComp
- {
- std::shared_ptr<CAnimImage> image;
- public:
- bool morale; //true if morale, false if luck
- bool small;
- void set(const AFactionMember *node);
- MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
- };
|