/* * 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" #include "../../lib/networkPacks/Component.h" VCMI_LIB_NAMESPACE_BEGIN class CGGarrison; class CGCreature; struct InfoAboutArmy; struct InfoAboutHero; struct InfoAboutTown; class CArmedInstance; class CGTownInstance; class CGHeroInstance; class AFactionMember; VCMI_LIB_NAMESPACE_END class CLabel; class CTextBox; class CGarrisonInt; class CCreatureAnim; class CComponent; class CAnimImage; class LRClickableArea; class TransparentFilledRectangle; /// Shows a text by moving the mouse cursor over the object class CHoverableArea: public virtual CIntObject { public: std::string hoverText; 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 title; std::vector> icons; std::vector> 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 portrait; std::vector> labels; std::shared_ptr morale; std::shared_ptr luck; void init(const InfoAboutHero & hero); public: CHeroTooltip(Point pos, const InfoAboutHero & hero); CHeroTooltip(Point pos, const CGHeroInstance * hero); }; /// Class for HD mod-like interactable infobox tooltip. Does not have any background! class CInteractableHeroTooltip : public CIntObject { std::shared_ptr title; std::shared_ptr portrait; std::vector> labels; std::shared_ptr morale; std::shared_ptr luck; std::shared_ptr garrison; void init(const InfoAboutHero & hero); public: CInteractableHeroTooltip(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 fort; std::shared_ptr hall; std::shared_ptr build; std::shared_ptr income; std::shared_ptr garrisonedHero; std::shared_ptr res1; std::shared_ptr res2; void init(const InfoAboutTown & town); public: CTownTooltip(Point pos, const InfoAboutTown & town); CTownTooltip(Point pos, const CGTownInstance * town); }; /// Class for HD mod-like interactable infobox tooltip. Does not have any background! class CInteractableTownTooltip : public CIntObject { std::shared_ptr title; std::shared_ptr fort; std::shared_ptr hall; std::shared_ptr build; std::shared_ptr income; std::shared_ptr garrisonedHero; std::shared_ptr res1; std::shared_ptr res2; std::shared_ptr garrison; std::shared_ptr fastTavern; std::shared_ptr fastMarket; std::shared_ptr fastTownHall; std::shared_ptr fastArmyPurchase; void init(const CGTownInstance * town); public: CInteractableTownTooltip(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 bg; std::shared_ptr anim; //displayed animation std::shared_ptr 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); }; class CreatureTooltip : public CIntObject { std::shared_ptr creatureImage; std::shared_ptr tooltipTextbox; public: CreatureTooltip(Point pos, const CGCreature * creature); }; /// Resource bar like that at the bottom of the adventure map screen class CMinorResDataBar : public CIntObject { std::shared_ptr background; std::string buildDateString(); public: void show(Canvas & to) override; void showAll(Canvas & to) override; CMinorResDataBar(); ~CMinorResDataBar(); }; /// Performs an action by left-clicking on it. Opens hero window by default class CHeroArea: public CIntObject { public: using ClickFunctor = std::function; CHeroArea(int x, int y, const CGHeroInstance * hero); void addClickCallback(ClickFunctor callback); void addRClickCallback(ClickFunctor callback); void clickPressed(const Point & cursorPosition) override; void showPopupWindow(const Point & cursorPosition) override; void hover(bool on) override; private: const CGHeroInstance * hero; std::shared_ptr portrait; ClickFunctor clickFunctor; ClickFunctor clickRFunctor; ClickFunctor showPopupHandler; }; /// Can interact on left and right mouse clicks class LRClickableAreaWTextComp: public LRClickableAreaWText { public: Component component; void clickPressed(const Point & cursorPosition) override; void showPopupWindow(const Point & cursorPosition) override; LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), ComponentType baseType = ComponentType::NONE); std::shared_ptr 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); }; /// Can do action on click class LRClickableArea: public CIntObject { std::function onClick; std::function onPopup; public: void clickPressed(const Point & cursorPosition) override; void showPopupWindow(const Point & cursorPosition) override; LRClickableArea(const Rect & Pos, std::function onClick = nullptr, std::function onPopup = nullptr); }; class MoraleLuckBox : public LRClickableAreaWTextComp { std::shared_ptr image; std::shared_ptr label; 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); }; class SelectableSlot : public LRClickableAreaWTextComp { std::shared_ptr selection; bool selected; public: SelectableSlot(Rect area, Point oversize, const int width); SelectableSlot(Rect area, Point oversize); SelectableSlot(Rect area, const int width = 1); void selectSlot(bool on); bool isSelected() const; void setSelectionWidth(int width); void moveSelectionForeground(); };