2014-07-13 18:40:13 +03:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../gui/CIntObject.h"
|
2023-10-31 11:09:56 +02:00
|
|
|
#include "../../lib/networkPacks/Component.h"
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2014-07-13 18:40:13 +03:00
|
|
|
class CGGarrison;
|
2023-08-21 14:42:41 +02:00
|
|
|
class CGCreature;
|
2016-08-30 04:13:45 +02:00
|
|
|
struct InfoAboutArmy;
|
2023-07-31 18:50:55 +02:00
|
|
|
struct InfoAboutHero;
|
|
|
|
struct InfoAboutTown;
|
2014-07-13 18:40:13 +03:00
|
|
|
class CArmedInstance;
|
2023-07-31 18:50:55 +02:00
|
|
|
class CGTownInstance;
|
|
|
|
class CGHeroInstance;
|
2023-04-30 17:21:02 +02:00
|
|
|
class AFactionMember;
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
class CLabel;
|
2023-08-21 14:42:41 +02:00
|
|
|
class CTextBox;
|
2023-08-05 13:25:57 +02:00
|
|
|
class CGarrisonInt;
|
2022-07-26 15:07:42 +02:00
|
|
|
class CCreatureAnim;
|
|
|
|
class CComponent;
|
2014-07-15 10:14:49 +03:00
|
|
|
class CAnimImage;
|
2023-10-13 00:21:58 +02:00
|
|
|
class LRClickableArea;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
/// Shows a text by moving the mouse cursor over the object
|
|
|
|
class CHoverableArea: public virtual CIntObject
|
2014-07-13 18:40:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2014-07-15 10:14:49 +03:00
|
|
|
std::string hoverText;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
virtual void hover (bool on) override;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
CHoverableArea();
|
|
|
|
virtual ~CHoverableArea();
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
/// Can interact on left and right mouse clicks, plus it shows a text when by hovering over it
|
|
|
|
class LRClickableAreaWText: public CHoverableArea
|
2014-07-13 18:40:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2014-07-15 10:14:49 +03:00
|
|
|
std::string text;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
LRClickableAreaWText();
|
2018-04-07 13:34:11 +02:00
|
|
|
LRClickableAreaWText(const Rect & Pos, const std::string & HoverText = "", const std::string & ClickText = "");
|
2014-07-15 10:14:49 +03:00
|
|
|
virtual ~LRClickableAreaWText();
|
|
|
|
void init();
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2023-07-09 16:48:25 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2023-07-08 13:33:04 +02:00
|
|
|
void showPopupWindow(const Point & cursorPosition) override;
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// base class for hero/town/garrison tooltips
|
|
|
|
class CArmyTooltip : public CIntObject
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::vector<std::shared_ptr<CAnimImage>> icons;
|
|
|
|
std::vector<std::shared_ptr<CLabel>> subtitles;
|
|
|
|
void init(const InfoAboutArmy & army);
|
2014-07-13 18:40:13 +03:00
|
|
|
public:
|
2018-04-07 13:34:11 +02:00
|
|
|
CArmyTooltip(Point pos, const InfoAboutArmy & army);
|
2014-07-13 18:40:13 +03:00
|
|
|
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
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
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);
|
2014-07-13 18:40:13 +03:00
|
|
|
public:
|
2018-04-07 13:34:11 +02:00
|
|
|
CHeroTooltip(Point pos, const InfoAboutHero & hero);
|
2014-07-13 18:40:13 +03:00
|
|
|
CHeroTooltip(Point pos, const CGHeroInstance * hero);
|
|
|
|
};
|
|
|
|
|
2023-07-15 23:14:59 +02:00
|
|
|
/// Class for HD mod-like interactable infobox tooltip. Does not have any background!
|
2023-08-05 13:25:57 +02:00
|
|
|
class CInteractableHeroTooltip : public CIntObject
|
2023-07-15 23:14:59 +02:00
|
|
|
{
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CAnimImage> portrait;
|
|
|
|
std::vector<std::shared_ptr<CLabel>> labels;
|
|
|
|
std::shared_ptr<CAnimImage> morale;
|
|
|
|
std::shared_ptr<CAnimImage> luck;
|
2023-08-05 13:25:57 +02:00
|
|
|
std::shared_ptr<CGarrisonInt> garrison;
|
2023-07-15 23:14:59 +02:00
|
|
|
|
|
|
|
void init(const InfoAboutHero & hero);
|
|
|
|
public:
|
|
|
|
CInteractableHeroTooltip(Point pos, const CGHeroInstance * hero);
|
|
|
|
};
|
|
|
|
|
2014-07-13 18:40:13 +03:00
|
|
|
/// Class for town tooltip. Does not have any background!
|
|
|
|
/// background for infoBox: ADSTATCS
|
|
|
|
/// background for tooltip: TOWNQVBK
|
|
|
|
class CTownTooltip : public CArmyTooltip
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
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);
|
2014-07-13 18:40:13 +03:00
|
|
|
public:
|
2018-04-07 13:34:11 +02:00
|
|
|
CTownTooltip(Point pos, const InfoAboutTown & town);
|
2014-07-13 18:40:13 +03:00
|
|
|
CTownTooltip(Point pos, const CGTownInstance * town);
|
2023-07-16 10:17:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Class for HD mod-like interactable infobox tooltip. Does not have any background!
|
2023-08-05 13:25:57 +02:00
|
|
|
class CInteractableTownTooltip : public CIntObject
|
2023-07-16 10:17:37 +02:00
|
|
|
{
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
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;
|
2023-08-05 13:25:57 +02:00
|
|
|
std::shared_ptr<CGarrisonInt> garrison;
|
2023-10-13 00:21:58 +02:00
|
|
|
|
2023-10-13 23:36:51 +02:00
|
|
|
std::shared_ptr<LRClickableArea> fastTavern;
|
2023-10-13 00:21:58 +02:00
|
|
|
std::shared_ptr<LRClickableArea> fastMarket;
|
|
|
|
std::shared_ptr<LRClickableArea> fastTownHall;
|
|
|
|
std::shared_ptr<LRClickableArea> fastArmyPurchase;
|
2023-07-16 10:17:37 +02:00
|
|
|
|
2023-10-13 00:21:58 +02:00
|
|
|
void init(const CGTownInstance * town);
|
2023-07-16 10:17:37 +02:00
|
|
|
public:
|
|
|
|
CInteractableTownTooltip(Point pos, const CGTownInstance * town);
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// draws picture with creature on background, use Animated=true to get animation
|
|
|
|
class CCreaturePic : public CIntObject
|
|
|
|
{
|
|
|
|
private:
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CPicture> bg;
|
|
|
|
std::shared_ptr<CCreatureAnim> anim; //displayed animation
|
|
|
|
std::shared_ptr<CLabel> amount;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2023-06-02 15:42:18 +02:00
|
|
|
void show(Canvas & to) override;
|
2014-07-13 18:40:13 +03:00
|
|
|
public:
|
2018-04-07 13:34:11 +02:00
|
|
|
CCreaturePic(int x, int y, const CCreature * cre, bool Big=true, bool Animated=true);
|
2014-09-19 16:31:01 +03:00
|
|
|
void setAmount(int newAmount);
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
2023-08-21 14:42:41 +02:00
|
|
|
class CreatureTooltip : public CIntObject
|
|
|
|
{
|
|
|
|
std::shared_ptr<CAnimImage> creatureImage;
|
|
|
|
std::shared_ptr<CTextBox> tooltipTextbox;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CreatureTooltip(Point pos, const CGCreature * creature);
|
|
|
|
};
|
|
|
|
|
2014-07-13 18:40:13 +03:00
|
|
|
/// Resource bar like that at the bottom of the adventure map screen
|
|
|
|
class CMinorResDataBar : public CIntObject
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CPicture> background;
|
2023-02-03 18:55:25 +02:00
|
|
|
|
|
|
|
std::string buildDateString();
|
2014-07-13 18:40:13 +03:00
|
|
|
public:
|
2023-06-02 15:42:18 +02:00
|
|
|
void show(Canvas & to) override;
|
|
|
|
void showAll(Canvas & to) override;
|
2017-07-17 23:04:00 +02:00
|
|
|
CMinorResDataBar();
|
|
|
|
~CMinorResDataBar();
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
2023-09-03 20:42:22 +02:00
|
|
|
/// Performs an action by left-clicking on it. Opens hero window by default
|
2014-07-13 18:40:13 +03:00
|
|
|
class CHeroArea: public CIntObject
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
public:
|
2023-09-03 20:42:22 +02:00
|
|
|
using ClickFunctor = std::function<void()>;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2023-09-03 20:42:22 +02:00
|
|
|
CHeroArea(int x, int y, const CGHeroInstance * hero);
|
|
|
|
void addClickCallback(ClickFunctor callback);
|
2023-12-22 02:30:41 +02:00
|
|
|
void addRClickCallback(ClickFunctor callback);
|
2023-07-09 16:48:25 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2023-12-22 02:30:41 +02:00
|
|
|
void showPopupWindow(const Point & cursorPosition) override;
|
2015-10-12 15:47:10 +02:00
|
|
|
void hover(bool on) override;
|
2023-09-03 20:42:22 +02:00
|
|
|
private:
|
|
|
|
const CGHeroInstance * hero;
|
|
|
|
std::shared_ptr<CAnimImage> portrait;
|
|
|
|
ClickFunctor clickFunctor;
|
2023-12-22 02:30:41 +02:00
|
|
|
ClickFunctor clickRFunctor;
|
2023-09-03 20:42:22 +02:00
|
|
|
ClickFunctor showPopupHandler;
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
/// Can interact on left and right mouse clicks
|
|
|
|
class LRClickableAreaWTextComp: public LRClickableAreaWText
|
|
|
|
{
|
|
|
|
public:
|
2023-10-31 11:09:56 +02:00
|
|
|
Component component;
|
|
|
|
|
2023-07-09 16:48:25 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2023-07-08 13:33:04 +02:00
|
|
|
void showPopupWindow(const Point & cursorPosition) override;
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2023-10-31 11:09:56 +02:00
|
|
|
LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), ComponentType baseType = ComponentType::NONE);
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CComponent> createComponent() const;
|
2014-07-15 10:14:49 +03:00
|
|
|
};
|
|
|
|
|
2014-07-13 18:40:13 +03:00
|
|
|
/// Opens town screen by left-clicking on it
|
|
|
|
class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const CGTownInstance * town;
|
2023-07-09 16:48:25 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2016-11-27 17:17:20 +02:00
|
|
|
LRClickableAreaOpenTown(const Rect & Pos, const CGTownInstance * Town);
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
2014-07-15 10:14:49 +03:00
|
|
|
|
2023-10-13 00:21:58 +02:00
|
|
|
/// Can do action on click
|
|
|
|
class LRClickableArea: public CIntObject
|
|
|
|
{
|
|
|
|
std::function<void()> onClick;
|
|
|
|
std::function<void()> onPopup;
|
|
|
|
public:
|
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
|
|
|
void showPopupWindow(const Point & cursorPosition) override;
|
|
|
|
LRClickableArea(const Rect & Pos, std::function<void()> onClick = nullptr, std::function<void()> onPopup = nullptr);
|
|
|
|
};
|
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
class MoraleLuckBox : public LRClickableAreaWTextComp
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> image;
|
2023-12-23 17:07:12 +02:00
|
|
|
std::shared_ptr<CLabel> label;
|
2014-07-15 10:14:49 +03:00
|
|
|
public:
|
|
|
|
bool morale; //true if morale, false if luck
|
|
|
|
bool small;
|
|
|
|
|
2023-04-30 17:21:02 +02:00
|
|
|
void set(const AFactionMember *node);
|
2014-07-15 10:14:49 +03:00
|
|
|
|
|
|
|
MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
|
|
|
|
};
|
2023-09-17 20:34:31 +02:00
|
|
|
|
|
|
|
class TransparentFilledRectangle : public CIntObject
|
|
|
|
{
|
|
|
|
ColorRGBA color;
|
|
|
|
ColorRGBA colorLine;
|
|
|
|
bool drawLine;
|
2023-11-19 19:49:59 +02:00
|
|
|
int lineWidth;
|
|
|
|
|
2023-09-17 20:34:31 +02:00
|
|
|
public:
|
|
|
|
TransparentFilledRectangle(Rect position, ColorRGBA color);
|
2023-11-19 19:49:59 +02:00
|
|
|
TransparentFilledRectangle(Rect position, ColorRGBA color, ColorRGBA colorLine, int width = 1);
|
|
|
|
void setDrawBorder(bool on);
|
|
|
|
bool getDrawBorder();
|
|
|
|
void setBorderWidth(int width);
|
2023-09-17 20:34:31 +02:00
|
|
|
void showAll(Canvas & to) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SimpleLine : public CIntObject
|
|
|
|
{
|
|
|
|
Point pos1;
|
|
|
|
Point pos2;
|
|
|
|
ColorRGBA color;
|
|
|
|
public:
|
|
|
|
SimpleLine(Point pos1, Point pos2, ColorRGBA color);
|
|
|
|
void showAll(Canvas & to) override;
|
2023-10-31 11:09:56 +02:00
|
|
|
};
|
2023-11-19 19:49:59 +02:00
|
|
|
|
2024-01-10 18:01:34 +02:00
|
|
|
class SelectableSlot : public LRClickableAreaWTextComp
|
2023-11-19 19:49:59 +02:00
|
|
|
{
|
|
|
|
std::unique_ptr<TransparentFilledRectangle> selection;
|
|
|
|
|
2024-01-10 18:01:34 +02:00
|
|
|
public:
|
2023-11-19 19:49:59 +02:00
|
|
|
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;
|
2024-01-10 18:01:34 +02:00
|
|
|
void setSelectionWidth(int width);
|
2023-11-19 19:49:59 +02:00
|
|
|
};
|