2011-07-22 19:22:22 +03:00
|
|
|
#pragma once
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2014-07-13 20:53:37 +03:00
|
|
|
#include "../widgets/CArtifactHolder.h"
|
|
|
|
#include "../widgets/CGarrisonInt.h"
|
2011-07-22 19:22:22 +03:00
|
|
|
|
2014-08-03 14:16:19 +03:00
|
|
|
class CButton;
|
2011-07-22 19:22:22 +03:00
|
|
|
class CAnimImage;
|
2014-08-03 14:16:19 +03:00
|
|
|
class CToggleGroup;
|
2010-01-25 23:25:14 +02:00
|
|
|
class CResDataBar;
|
|
|
|
class CSlider;
|
2011-07-22 19:22:22 +03:00
|
|
|
class CTownInfo;
|
|
|
|
class CCreaInfo;
|
|
|
|
class HeroSlots;
|
2014-07-13 18:39:45 +03:00
|
|
|
class LRClickableAreaOpenTown;
|
|
|
|
class CComponent;
|
|
|
|
class CHeroArea;
|
|
|
|
class MoraleLuckBox;
|
2014-07-15 10:14:49 +03:00
|
|
|
class CListBox;
|
|
|
|
class CTabbedInt;
|
|
|
|
class CGStatusBar;
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CKingdomInterface.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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-07-22 19:22:22 +03:00
|
|
|
class CKingdHeroList;
|
|
|
|
class CKingdTownList;
|
|
|
|
class IInfoBoxData;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Several classes to display basically any data.
|
|
|
|
* Main part - class InfoBox which controls how data will be formatted\positioned
|
|
|
|
* InfoBox have image and 0-2 labels
|
|
|
|
* In constructor it should receive object that implements IInfoBoxData interface
|
|
|
|
*
|
|
|
|
* interface IInfoBoxData defines way to get data for use in InfoBox
|
|
|
|
* have several implementations:
|
|
|
|
* InfoBoxHeroData - to display one of fields from hero (e.g. absolute value of primary skills)
|
|
|
|
* InfoBoxCustomHeroData - to display one of hero fields without hero (e.g. bonuses from objects)
|
|
|
|
* InfoBoxTownData - data from town
|
|
|
|
* InfoBoxCustom - user-defined data
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// Displays one of object propertries with image and optional labels
|
|
|
|
class InfoBox : public CIntObject
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
2011-07-22 19:22:22 +03:00
|
|
|
public:
|
|
|
|
enum InfoPos
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
2011-07-22 19:22:22 +03:00
|
|
|
POS_UP_DOWN, POS_DOWN, POS_RIGHT, POS_INSIDE, POS_CORNER, POS_NONE
|
2010-01-26 13:56:29 +02:00
|
|
|
};
|
2011-07-22 19:22:22 +03:00
|
|
|
enum InfoSize
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
2011-07-22 19:22:22 +03:00
|
|
|
SIZE_TINY, SIZE_SMALL, SIZE_MEDIUM, SIZE_BIG, SIZE_HUGE
|
2010-01-25 23:25:14 +02:00
|
|
|
};
|
2011-07-22 19:22:22 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
InfoSize size;
|
|
|
|
InfoPos infoPos;
|
|
|
|
IInfoBoxData *data;
|
|
|
|
|
|
|
|
CLabel * value;
|
|
|
|
CLabel * name;
|
|
|
|
CAnimImage * image;
|
2011-12-22 16:05:19 +03:00
|
|
|
CHoverableArea *hover;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
|
|
|
public:
|
2011-12-22 16:05:19 +03:00
|
|
|
InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data);
|
2011-07-22 19:22:22 +03:00
|
|
|
~InfoBox();
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
|
|
|
//Update object if data may have changed
|
|
|
|
//void update();
|
|
|
|
};
|
|
|
|
|
|
|
|
class IInfoBoxData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum InfoType
|
|
|
|
{
|
|
|
|
HERO_PRIMARY_SKILL, HERO_MANA, HERO_EXPERIENCE, HERO_SPECIAL, HERO_SECONDARY_SKILL,
|
|
|
|
//TODO: Luck? Morale? Artifact?
|
|
|
|
ARMY_SLOT,//TODO
|
|
|
|
TOWN_GROWTH, TOWN_AVAILABLE, TOWN_BUILDING,//TODO
|
|
|
|
CUSTOM
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
InfoType type;
|
|
|
|
|
|
|
|
IInfoBoxData(InfoType Type);
|
|
|
|
|
|
|
|
public:
|
|
|
|
//methods that generate values for displaying
|
|
|
|
virtual std::string getValueText()=0;
|
|
|
|
virtual std::string getNameText()=0;
|
|
|
|
virtual std::string getImageName(InfoBox::InfoSize size)=0;
|
|
|
|
virtual std::string getHoverText()=0;
|
|
|
|
virtual size_t getImageIndex()=0;
|
|
|
|
|
|
|
|
//TODO: replace with something better
|
2011-12-22 16:05:19 +03:00
|
|
|
virtual bool prepareMessage(std::string &text, CComponent **comp)=0;
|
2012-04-08 13:34:23 +03:00
|
|
|
|
|
|
|
virtual ~IInfoBoxData(){};
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class InfoBoxAbstractHeroData : public IInfoBoxData
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual int getSubID()=0;
|
|
|
|
virtual si64 getValue()=0;
|
|
|
|
|
|
|
|
public:
|
|
|
|
InfoBoxAbstractHeroData(InfoType Type);
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
std::string getValueText() override;
|
|
|
|
std::string getNameText() override;
|
|
|
|
std::string getImageName(InfoBox::InfoSize size) override;
|
|
|
|
std::string getHoverText() override;
|
|
|
|
size_t getImageIndex() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
bool prepareMessage(std::string &text, CComponent **comp) override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class InfoBoxHeroData : public InfoBoxAbstractHeroData
|
|
|
|
{
|
|
|
|
const CGHeroInstance * hero;
|
|
|
|
int index;//index of data in hero (0-7 for sec. skill, 0-3 for pr. skill)
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
int getSubID() override;
|
|
|
|
si64 getValue() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
2010-01-26 13:56:29 +02:00
|
|
|
public:
|
2011-07-22 19:22:22 +03:00
|
|
|
InfoBoxHeroData(InfoType Type, const CGHeroInstance *Hero, int Index=0);
|
|
|
|
|
|
|
|
//To get a bit different texts for hero window
|
2015-10-12 15:47:10 +02:00
|
|
|
std::string getHoverText() override;
|
|
|
|
std::string getValueText() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
bool prepareMessage(std::string &text, CComponent **comp) override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class InfoBoxCustomHeroData : public InfoBoxAbstractHeroData
|
|
|
|
{
|
|
|
|
int subID;//subID of data (0=attack...)
|
|
|
|
si64 value;//actual value of data, 64-bit to fit experience and negative values
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
int getSubID() override;
|
|
|
|
si64 getValue() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
InfoBoxCustomHeroData(InfoType Type, int subID, si64 value);
|
|
|
|
};
|
|
|
|
|
|
|
|
class InfoBoxCustom : public IInfoBoxData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string valueText;
|
|
|
|
std::string nameText;
|
|
|
|
std::string imageName;
|
|
|
|
std::string hoverText;
|
|
|
|
size_t imageIndex;
|
|
|
|
|
|
|
|
InfoBoxCustom(std::string ValueText, std::string NameText, std::string ImageName, size_t ImageIndex, std::string HoverText="");
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
std::string getValueText() override;
|
|
|
|
std::string getNameText() override;
|
|
|
|
std::string getImageName(InfoBox::InfoSize size) override;
|
|
|
|
std::string getHoverText() override;
|
|
|
|
size_t getImageIndex() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
bool prepareMessage(std::string &text, CComponent **comp) override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//TODO!!!
|
|
|
|
class InfoBoxTownData : public IInfoBoxData
|
|
|
|
{
|
|
|
|
const CGTownInstance * town;
|
|
|
|
int index;//index of data in town
|
|
|
|
int value;//actual value of data
|
|
|
|
|
|
|
|
public:
|
|
|
|
InfoBoxTownData(InfoType Type, const CGTownInstance * Town, int Index);
|
|
|
|
InfoBoxTownData(InfoType Type, int SubID, int Value);
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
std::string getValueText() override;
|
|
|
|
std::string getNameText() override;
|
|
|
|
std::string getImageName(InfoBox::InfoSize size) override;
|
|
|
|
std::string getHoverText() override;
|
|
|
|
size_t getImageIndex() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/// Class which holds all parts of kingdom overview window
|
2012-06-15 20:08:19 +03:00
|
|
|
class CKingdomInterface : public CWindowObject, public CGarrisonHolder, public CArtifactHolder
|
2011-07-22 19:22:22 +03:00
|
|
|
{
|
|
|
|
private:
|
2011-11-27 16:14:20 +03:00
|
|
|
struct OwnedObjectInfo
|
|
|
|
{
|
|
|
|
int imageID;
|
2011-12-14 00:23:17 +03:00
|
|
|
ui32 count;
|
2011-11-27 16:14:20 +03:00
|
|
|
std::string hoverText;
|
2012-09-30 13:35:17 +03:00
|
|
|
OwnedObjectInfo():
|
|
|
|
imageID(0),
|
|
|
|
count(0)
|
|
|
|
{}
|
2011-11-27 16:14:20 +03:00
|
|
|
};
|
|
|
|
std::vector<OwnedObjectInfo> objects;
|
|
|
|
|
2011-07-22 19:22:22 +03:00
|
|
|
CListBox * dwellingsList;
|
|
|
|
CTabbedInt * tabArea;
|
|
|
|
|
|
|
|
//Main buttons
|
2014-08-03 14:16:19 +03:00
|
|
|
CButton *btnTowns;
|
|
|
|
CButton *btnHeroes;
|
|
|
|
CButton *btnExit;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
|
|
|
//Buttons for scrolling dwellings list
|
2014-08-03 14:16:19 +03:00
|
|
|
CButton *dwellUp, *dwellDown;
|
|
|
|
CButton *dwellTop, *dwellBottom;
|
2011-07-22 19:22:22 +03:00
|
|
|
|
|
|
|
InfoBox * minesBox[7];
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
CHoverableArea * incomeArea;
|
2011-07-22 19:22:22 +03:00
|
|
|
CLabel * incomeAmount;
|
|
|
|
|
|
|
|
CGStatusBar * statusbar;
|
|
|
|
CResDataBar *resdatabar;
|
|
|
|
|
|
|
|
void activateTab(size_t which);
|
|
|
|
|
|
|
|
//Internal functions used during construction
|
|
|
|
void generateButtons();
|
|
|
|
void generateObjectsList(const std::vector<const CGObjectInstance * > &ownedObjects);
|
|
|
|
void generateMinesList(const std::vector<const CGObjectInstance * > &ownedObjects);
|
|
|
|
|
2011-11-27 16:14:20 +03:00
|
|
|
CIntObject* createOwnedObject(size_t index);
|
|
|
|
CIntObject* createMainTab(size_t index);
|
|
|
|
|
2011-07-22 19:22:22 +03:00
|
|
|
public:
|
|
|
|
CKingdomInterface();
|
|
|
|
|
|
|
|
void townChanged(const CGTownInstance *town);
|
2015-10-12 15:47:10 +02:00
|
|
|
void updateGarrisons() override;
|
|
|
|
void artifactRemoved(const ArtifactLocation &artLoc) override;
|
|
|
|
void artifactMoved(const ArtifactLocation &artLoc, const ArtifactLocation &destLoc) override;
|
|
|
|
void artifactDisassembled(const ArtifactLocation &artLoc) override;
|
|
|
|
void artifactAssembled(const ArtifactLocation &artLoc) override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// List item with town
|
2012-06-13 16:04:06 +03:00
|
|
|
class CTownItem : public CIntObject, public CGarrisonHolder
|
2011-07-22 19:22:22 +03:00
|
|
|
{
|
|
|
|
CAnimImage *background;
|
|
|
|
CAnimImage *picture;
|
|
|
|
CLabel *name;
|
|
|
|
CLabel *income;
|
|
|
|
CGarrisonInt *garr;
|
|
|
|
LRClickableAreaOpenTown *townArea;
|
|
|
|
|
|
|
|
HeroSlots *heroes;
|
|
|
|
CTownInfo *hall, *fort;
|
|
|
|
std::vector<CCreaInfo*> available;
|
|
|
|
std::vector<CCreaInfo*> growth;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const CGTownInstance * town;
|
|
|
|
|
|
|
|
CTownItem(const CGTownInstance* town);
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void updateGarrisons() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
void update();
|
|
|
|
};
|
|
|
|
|
|
|
|
/// List item with hero
|
2012-06-13 16:04:06 +03:00
|
|
|
class CHeroItem : public CIntObject, public CWindowWithGarrison
|
2011-07-22 19:22:22 +03:00
|
|
|
{
|
|
|
|
const CGHeroInstance * hero;
|
|
|
|
|
2011-11-27 16:14:20 +03:00
|
|
|
std::vector<CIntObject *> artTabs;
|
|
|
|
|
2011-07-22 19:22:22 +03:00
|
|
|
CAnimImage *portrait;
|
|
|
|
CLabel *name;
|
|
|
|
CHeroArea *heroArea;
|
|
|
|
|
|
|
|
CLabel *artsText;
|
|
|
|
CTabbedInt *artsTabs;
|
|
|
|
|
2014-08-03 14:16:19 +03:00
|
|
|
CToggleGroup *artButtons;
|
2011-07-22 19:22:22 +03:00
|
|
|
std::vector<InfoBox*> heroInfo;
|
|
|
|
MoraleLuckBox * morale, * luck;
|
|
|
|
|
|
|
|
void onArtChange(int tabIndex);
|
|
|
|
|
2011-11-27 16:14:20 +03:00
|
|
|
CIntObject * onTabSelected(size_t index);
|
|
|
|
void onTabDeselected(CIntObject *object);
|
|
|
|
|
2011-07-22 19:22:22 +03:00
|
|
|
public:
|
|
|
|
CArtifactsOfHero *heroArts;
|
|
|
|
|
2015-02-14 19:24:18 +02:00
|
|
|
CHeroItem(const CGHeroInstance* hero);
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Tab with all hero-specific data
|
2012-06-15 20:08:19 +03:00
|
|
|
class CKingdHeroList : public CIntObject, public CGarrisonHolder, public CWindowWithArtifacts
|
2011-07-22 19:22:22 +03:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector<CHeroItem*> heroItems;
|
|
|
|
CListBox * heroes;
|
|
|
|
CPicture * title;
|
|
|
|
CLabel * heroLabel;
|
|
|
|
CLabel * skillsLabel;
|
|
|
|
|
2011-11-27 16:14:20 +03:00
|
|
|
CIntObject* createHeroItem(size_t index);
|
|
|
|
void destroyHeroItem(CIntObject *item);
|
2011-07-22 19:22:22 +03:00
|
|
|
public:
|
|
|
|
CKingdHeroList(size_t maxSize);
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void updateGarrisons() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Tab with all town-specific data
|
2012-06-13 16:04:06 +03:00
|
|
|
class CKingdTownList : public CIntObject, public CGarrisonHolder
|
2011-07-22 19:22:22 +03:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector<CTownItem*> townItems;
|
|
|
|
CListBox * towns;
|
|
|
|
CPicture * title;
|
|
|
|
CLabel * townLabel;
|
|
|
|
CLabel * garrHeroLabel;
|
|
|
|
CLabel * visitHeroLabel;
|
|
|
|
|
2011-11-27 16:14:20 +03:00
|
|
|
CIntObject* createTownItem(size_t index);
|
2011-07-22 19:22:22 +03:00
|
|
|
public:
|
|
|
|
CKingdTownList(size_t maxSize);
|
|
|
|
|
|
|
|
void townChanged(const CGTownInstance *town);
|
2015-10-12 15:47:10 +02:00
|
|
|
void updateGarrisons() override;
|
2011-07-22 19:22:22 +03:00
|
|
|
};
|