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"
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2014-09-19 16:31:01 +03:00
|
|
|
class CLabel;
|
2014-07-13 18:40:13 +03:00
|
|
|
class CCreatureAnim;
|
|
|
|
class CComponent;
|
|
|
|
class CGGarrison;
|
|
|
|
class CSelectableComponent;
|
2016-08-30 04:13:45 +02:00
|
|
|
struct InfoAboutArmy;
|
2014-07-13 18:40:13 +03:00
|
|
|
class CArmedInstance;
|
|
|
|
class IBonusBearer;
|
2014-07-15 10:14:49 +03:00
|
|
|
class CAnimImage;
|
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();
|
|
|
|
LRClickableAreaWText(const Rect &Pos, const std::string &HoverText = "", const std::string &ClickText = "");
|
|
|
|
virtual ~LRClickableAreaWText();
|
|
|
|
void init();
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
virtual void clickLeft(tribool down, bool previousState) override;
|
|
|
|
virtual void clickRight(tribool down, bool previousState) override;
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// base class for hero/town/garrison tooltips
|
|
|
|
class CArmyTooltip : public CIntObject
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
CPicture *bg;
|
|
|
|
CCreatureAnim *anim; //displayed animation
|
2014-09-19 16:31:01 +03:00
|
|
|
CLabel * amount;
|
2014-07-13 18:40:13 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void show(SDL_Surface *to) override;
|
2014-07-13 18:40:13 +03:00
|
|
|
public:
|
2017-07-17 23:04:00 +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
|
|
|
};
|
|
|
|
|
|
|
|
/// Resource bar like that at the bottom of the adventure map screen
|
|
|
|
class CMinorResDataBar : public CIntObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SDL_Surface *bg; //background bitmap
|
2015-10-12 15:47:10 +02:00
|
|
|
void show(SDL_Surface * to) override;
|
|
|
|
void showAll(SDL_Surface * to) override;
|
2017-07-17 23:04:00 +02:00
|
|
|
CMinorResDataBar();
|
|
|
|
~CMinorResDataBar();
|
2014-07-13 18:40:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Opens hero window by left-clicking on it
|
|
|
|
class CHeroArea: public CIntObject
|
|
|
|
{
|
|
|
|
const CGHeroInstance * hero;
|
|
|
|
public:
|
|
|
|
|
|
|
|
CHeroArea(int x, int y, const CGHeroInstance * _hero);
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void hover(bool on) override;
|
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:
|
|
|
|
int baseType;
|
|
|
|
int bonusValue, type;
|
2015-10-12 15:47:10 +02:00
|
|
|
virtual void clickLeft(tribool down, bool previousState) override;
|
|
|
|
virtual void clickRight(tribool down, bool previousState) override;
|
2014-07-15 10:14:49 +03:00
|
|
|
|
|
|
|
LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
|
|
|
|
CComponent * createComponent() const;
|
|
|
|
};
|
|
|
|
|
2014-07-13 18:40:13 +03:00
|
|
|
/// Opens town screen by left-clicking on it
|
|
|
|
class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const CGTownInstance * town;
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) 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
|
|
|
|
|
|
|
class MoraleLuckBox : public LRClickableAreaWTextComp
|
|
|
|
{
|
|
|
|
CAnimImage *image;
|
|
|
|
public:
|
|
|
|
bool morale; //true if morale, false if luck
|
|
|
|
bool small;
|
|
|
|
|
|
|
|
void set(const IBonusBearer *node);
|
|
|
|
|
|
|
|
MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
|
|
|
|
};
|