2009-04-16 14:14:13 +03:00
|
|
|
#ifndef __CCASTLEINTERFACE_H__
|
|
|
|
#define __CCASTLEINTERFACE_H__
|
|
|
|
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "../global.h"
|
2010-11-15 17:15:00 +02:00
|
|
|
#include "CAnimation.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "GUIBase.h"
|
2011-02-06 19:26:27 +02:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
class AdventureMapButton;
|
2011-04-07 20:54:08 +03:00
|
|
|
class CBuilding;
|
|
|
|
class CCastleBuildings;
|
|
|
|
class CCreaturePic;
|
|
|
|
class CGStatusBar;
|
|
|
|
class CGTownInstance;
|
|
|
|
class CLabel;
|
|
|
|
class CMinorResDataBar;
|
|
|
|
class CPicture;
|
2009-04-16 14:14:13 +03:00
|
|
|
class CResDataBar;
|
2011-04-07 20:54:08 +03:00
|
|
|
class CSpell;
|
2009-05-20 12:02:50 +03:00
|
|
|
class CStatusBar;
|
2011-04-07 20:54:08 +03:00
|
|
|
class CTextBox;
|
2009-05-20 12:02:50 +03:00
|
|
|
class CTownList;
|
2011-04-07 20:54:08 +03:00
|
|
|
struct Structure;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* CCastleInterface.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
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Building "button"
|
2010-11-15 17:15:00 +02:00
|
|
|
class CBuildingRect : public CShowableAnim
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2011-03-22 15:19:07 +02:00
|
|
|
CCastleBuildings * parent;
|
2011-04-07 20:54:08 +03:00
|
|
|
const CGTownInstance * town;
|
2010-12-17 20:47:07 +02:00
|
|
|
const Structure* str;
|
2009-04-16 14:14:13 +03:00
|
|
|
SDL_Surface* border;
|
|
|
|
SDL_Surface* area;
|
2011-03-22 15:19:07 +02:00
|
|
|
|
|
|
|
unsigned int stateCounter;//For building construction - current stage in animation
|
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
CBuildingRect(CCastleBuildings * Par, const CGTownInstance *Town, const Structure *Str); //c-tor
|
2009-05-07 20:20:41 +03:00
|
|
|
~CBuildingRect(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
bool operator<(const CBuildingRect & p2) const;
|
|
|
|
void hover(bool on);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
2010-11-15 17:15:00 +02:00
|
|
|
void show(SDL_Surface *to);
|
|
|
|
void showAll(SDL_Surface *to);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
2010-06-26 13:01:26 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
/// Dwelling info box - right-click screen for dwellings
|
|
|
|
class CDwellingInfoBox : public CIntObject
|
|
|
|
{
|
|
|
|
CPicture *background;
|
|
|
|
CLabel *title;
|
|
|
|
CCreaturePic *animation;
|
|
|
|
CLabel *available;
|
|
|
|
CLabel *costPerTroop;
|
|
|
|
|
|
|
|
std::vector<CPicture *> resPicture;
|
|
|
|
std::vector<CLabel *> resAmount;
|
|
|
|
public:
|
|
|
|
CDwellingInfoBox(int centerX, int centerY, const CGTownInstance *Town, int level);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Hero army slot
|
2009-08-11 19:05:33 +03:00
|
|
|
class CHeroGSlot : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCastleInterface *owner;
|
|
|
|
const CGHeroInstance *hero;
|
|
|
|
int upg; //0 - up garrison, 1 - down garrison
|
2009-04-17 17:01:22 +03:00
|
|
|
bool highlight; //indicates id the slot is highlighted
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-09-09 09:04:42 +03:00
|
|
|
void setHighlight(bool on);
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
void hover (bool on);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void deactivate();
|
2011-04-07 20:54:08 +03:00
|
|
|
void showAll(SDL_Surface * to);
|
2009-05-07 20:20:41 +03:00
|
|
|
CHeroGSlot(int x, int y, int updown, const CGHeroInstance *h,CCastleInterface * Owner); //c-tor
|
|
|
|
~CHeroGSlot(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-03-22 15:19:07 +02:00
|
|
|
/// Class for town screen management (town background and structures)
|
|
|
|
class CCastleBuildings : public CIntObject
|
|
|
|
{
|
|
|
|
struct AnimRule
|
|
|
|
{
|
|
|
|
int townID, buildID;
|
|
|
|
int toCheck;
|
|
|
|
size_t firstA, lastA;
|
|
|
|
size_t firstB, lastB;
|
|
|
|
};
|
|
|
|
|
|
|
|
CPicture *background;
|
|
|
|
//List of buildings for each group
|
|
|
|
std::map< int, std::vector<const Structure*> > groups;
|
|
|
|
//Vector with all blittable buildings
|
|
|
|
std::vector<CBuildingRect*> buildings;
|
|
|
|
|
|
|
|
const CGTownInstance * town;
|
|
|
|
|
|
|
|
const CGHeroInstance* getHero();//Select hero for buildings usage
|
|
|
|
void checkRules();//Check animation rules (special anims for Shipyard and Mana Vortex)
|
|
|
|
|
|
|
|
void enterBlacksmith(int ArtifactID);//support for blacksmith + ballista yard
|
|
|
|
void enterBuilding(int building);//for buildings with simple description + pic left-click messages
|
|
|
|
void enterCastleGate();
|
|
|
|
void enterFountain(int building);//Rampart's fountains
|
|
|
|
void enterMagesGuild();
|
|
|
|
void enterTownHall();
|
|
|
|
|
|
|
|
void openMagesGuild();
|
|
|
|
void openTownHall();
|
|
|
|
|
|
|
|
public:
|
|
|
|
CBuildingRect * selectedBuilding;
|
|
|
|
|
|
|
|
CCastleBuildings(const CGTownInstance* town);
|
|
|
|
~CCastleBuildings();
|
|
|
|
|
|
|
|
void enterDwelling(int level);
|
|
|
|
|
|
|
|
void buildingClicked(int building);
|
|
|
|
void addBuilding(int building);
|
|
|
|
void removeBuilding(int building);//FIXME: not tested!!!
|
|
|
|
|
|
|
|
void show(SDL_Surface *to);
|
|
|
|
void showAll(SDL_Surface *to);
|
|
|
|
};
|
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
/// Creature info window
|
|
|
|
class CCreaInfo : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2011-04-07 20:54:08 +03:00
|
|
|
const CGTownInstance * town;
|
|
|
|
const CCreature *creature;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
CAnimImage *picture;
|
|
|
|
CLabel * label;
|
2011-03-22 15:19:07 +02:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
int AddToString(std::string from, std::string & to, int numb);
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2011-04-07 20:54:08 +03:00
|
|
|
CCreaInfo(int posX, int posY, const CGTownInstance *Town, int Level);
|
|
|
|
|
|
|
|
void hover(bool on);
|
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Town hall and fort icons for town screen
|
|
|
|
class CTownInfo : public CIntObject
|
|
|
|
{
|
|
|
|
const CGTownInstance *town;
|
|
|
|
const CBuilding *building;
|
|
|
|
CAnimImage *picture;
|
|
|
|
public:
|
|
|
|
//if (townHall) hall-capital else fort - castle
|
|
|
|
CTownInfo(int posX, int posY, const CGTownInstance* town, bool townHall);
|
|
|
|
|
|
|
|
void hover(bool on);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Class which manages the castle window
|
|
|
|
class CCastleInterface : public CWindowWithGarrison
|
|
|
|
{
|
|
|
|
CLabel *title;
|
|
|
|
CLabel *income;
|
|
|
|
CAnimImage *icon;
|
|
|
|
|
|
|
|
CPicture * panel;
|
2009-04-16 14:14:13 +03:00
|
|
|
CResDataBar *resdatabar;
|
2011-04-07 20:54:08 +03:00
|
|
|
CGStatusBar * statusbar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
CTownInfo *hall, *fort;
|
2009-04-16 14:14:13 +03:00
|
|
|
CTownList * townlist;
|
|
|
|
|
|
|
|
AdventureMapButton *exit;
|
|
|
|
AdventureMapButton *split;
|
|
|
|
|
2009-12-23 03:46:15 +02:00
|
|
|
std::vector<CCreaInfo*> creainfo;//small icons of creatures (bottom-left corner);
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
public:
|
|
|
|
//TODO: remove - currently used only in dialog messages
|
|
|
|
CDefEssential* bicons; //150x70 buildings imgs
|
|
|
|
|
|
|
|
//TODO: move to private
|
|
|
|
const CGTownInstance * town;
|
|
|
|
CHeroGSlot *heroSlotUp, *heroSlotDown;
|
|
|
|
CCastleBuildings *builds;
|
|
|
|
|
2009-07-20 11:18:33 +03:00
|
|
|
CCastleInterface(const CGTownInstance * Town, int listPos = 1); //c-tor
|
2011-04-07 20:54:08 +03:00
|
|
|
~CCastleInterface();
|
2009-07-20 11:18:33 +03:00
|
|
|
|
2010-06-26 13:01:26 +03:00
|
|
|
void castleTeleport(int where);
|
2009-04-16 14:14:13 +03:00
|
|
|
void townChange();
|
2009-07-20 11:18:33 +03:00
|
|
|
void keyPressed(const SDL_KeyboardEvent & key);
|
2009-09-09 09:04:42 +03:00
|
|
|
void splitClicked(); //for hero meeting (splitting stacks is handled by garrison int)
|
2011-04-07 20:54:08 +03:00
|
|
|
void showAll(SDL_Surface *to);
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
|
|
|
void addBuilding(int bid);
|
|
|
|
void removeBuilding(int bid);
|
2009-12-23 03:46:15 +02:00
|
|
|
void recreateIcons();
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
2011-02-22 13:52:36 +02:00
|
|
|
|
|
|
|
/// Hall window where you can build things
|
2010-08-28 18:10:37 +03:00
|
|
|
class CHallInterface : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2011-03-22 15:19:07 +02:00
|
|
|
/// Building box from town hall (building icon + subtitle)
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBuildingBox : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2011-04-07 20:54:08 +03:00
|
|
|
const CGTownInstance * town;
|
|
|
|
const CBuilding * building;
|
|
|
|
|
|
|
|
unsigned int state;//Buildings::EBuildStructure enum
|
|
|
|
|
|
|
|
CAnimImage * picture;
|
|
|
|
CAnimImage * panel;
|
|
|
|
CAnimImage * icon;
|
|
|
|
CLabel * label;
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2011-04-07 20:54:08 +03:00
|
|
|
CBuildingBox(int x, int y, const CGTownInstance * Town, const CBuilding * Building);
|
2009-04-16 14:14:13 +03:00
|
|
|
void hover(bool on);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
2011-04-07 20:54:08 +03:00
|
|
|
const CGTownInstance * town;
|
|
|
|
|
|
|
|
std::vector< std::vector<CBuildingBox*> >boxes;
|
|
|
|
CPicture *background;
|
|
|
|
CLabel *title;
|
|
|
|
CGStatusBar *statusBar;
|
|
|
|
CMinorResDataBar * resdatabar;
|
|
|
|
AdventureMapButton *exit;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
public:
|
|
|
|
CHallInterface(const CGTownInstance * Town); //c-tor
|
|
|
|
void close();
|
|
|
|
};
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
/// Window where you can decide to buy a building or not
|
|
|
|
class CBuildWindow: public CIntObject
|
|
|
|
{
|
|
|
|
const CGTownInstance *town;
|
|
|
|
const CBuilding *building;
|
|
|
|
int state; //state - same as CHallInterface::CBuildingBox::state
|
|
|
|
bool mode; // 0 - normal (with buttons), 1 - r-click popup
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
CPicture *background;
|
|
|
|
CAnimImage *buildingPic;
|
|
|
|
AdventureMapButton *buy;
|
|
|
|
AdventureMapButton *cancel;
|
|
|
|
|
|
|
|
CLabel * title;
|
|
|
|
CTextBox * buildingDescr;
|
|
|
|
CTextBox * buildingState;
|
|
|
|
CGStatusBar *statusBar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
std::vector<CPicture *> resPicture;
|
|
|
|
std::vector<CLabel *> resAmount;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
std::string getTextForState(int state);
|
|
|
|
void buyFunc();
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
2011-04-07 20:54:08 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
void clickRight(tribool down, bool previousState);
|
|
|
|
CBuildWindow(const CGTownInstance *Town, const CBuilding * building, int State, bool Mode); //c-tor
|
|
|
|
~CBuildWindow(); //d-tor
|
|
|
|
};
|
|
|
|
|
|
|
|
//Small class to display
|
|
|
|
class LabeledValue : public CIntObject
|
|
|
|
{
|
|
|
|
std::string hoverText;
|
|
|
|
CLabel *name;
|
|
|
|
CLabel *value;
|
|
|
|
void init(std::string name, std::string descr, int min, int max);
|
|
|
|
|
|
|
|
public:
|
|
|
|
LabeledValue(Rect size, std::string name, std::string descr, int min, int max);
|
|
|
|
LabeledValue(Rect size, std::string name, std::string descr, int val);
|
|
|
|
void hover(bool on);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// The fort screen where you can afford units
|
2009-08-11 19:05:33 +03:00
|
|
|
class CFortScreen : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2011-04-07 20:54:08 +03:00
|
|
|
class RecruitArea : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2011-04-07 20:54:08 +03:00
|
|
|
const CGTownInstance *town;
|
2010-07-26 01:47:59 +03:00
|
|
|
int level;
|
2011-04-07 20:54:08 +03:00
|
|
|
|
|
|
|
std::string hoverText;
|
|
|
|
CLabel * creatureName;
|
|
|
|
CLabel * dwellingName;
|
|
|
|
CLabel * availableCount;
|
|
|
|
|
|
|
|
std::vector<LabeledValue*> values;
|
|
|
|
CPicture *icons;
|
|
|
|
CAnimImage * buildingPic;
|
|
|
|
CCreaturePic *creatureAnim;
|
|
|
|
|
|
|
|
public:
|
|
|
|
RecruitArea(int posX, int posY, const CGTownInstance *town, int buildingID, int level);
|
|
|
|
|
|
|
|
void creaturesChanged();
|
|
|
|
void hover(bool on);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
2011-04-07 20:54:08 +03:00
|
|
|
|
|
|
|
CPicture *background;
|
|
|
|
CLabel *title;
|
|
|
|
std::vector<RecruitArea*> recAreas;
|
2009-05-20 12:02:50 +03:00
|
|
|
CMinorResDataBar * resdatabar;
|
2011-04-07 20:54:08 +03:00
|
|
|
CGStatusBar *statusBar;
|
2009-04-16 14:14:13 +03:00
|
|
|
AdventureMapButton *exit;
|
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
public:
|
|
|
|
CFortScreen(const CGTownInstance * town); //c-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
void creaturesChanged();
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// The mage guild screen where you can see which spells you have
|
2009-08-11 19:05:33 +03:00
|
|
|
class CMageGuildScreen : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2009-08-11 19:05:33 +03:00
|
|
|
class Scroll : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2010-12-17 20:47:07 +02:00
|
|
|
const CSpell *spell;
|
2011-04-07 20:54:08 +03:00
|
|
|
CAnimImage *image;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
public:
|
|
|
|
Scroll(Point position, const CSpell *Spell);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void hover(bool on);
|
|
|
|
};
|
2011-04-07 20:54:08 +03:00
|
|
|
CPicture *background;
|
|
|
|
CPicture *window;
|
2009-04-16 14:14:13 +03:00
|
|
|
AdventureMapButton *exit;
|
2010-11-15 17:15:00 +02:00
|
|
|
std::vector<Scroll *> spells;
|
2009-05-20 12:02:50 +03:00
|
|
|
CMinorResDataBar * resdatabar;
|
2011-04-07 20:54:08 +03:00
|
|
|
CGStatusBar *statusBar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
void close();
|
2010-11-15 17:15:00 +02:00
|
|
|
|
2011-04-07 20:54:08 +03:00
|
|
|
public:
|
|
|
|
CMageGuildScreen(CCastleInterface * owner);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-03-22 15:19:07 +02:00
|
|
|
/// The blacksmith window where you can buy available in town war machine
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBlacksmithDialog : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
AdventureMapButton *buy, *cancel;
|
2011-04-07 20:54:08 +03:00
|
|
|
CPicture *background;
|
2011-02-06 19:26:27 +02:00
|
|
|
CPicture *animBG;
|
2010-11-15 17:15:00 +02:00
|
|
|
CCreatureAnim * anim;
|
2011-04-07 20:54:08 +03:00
|
|
|
CPicture * gold;
|
|
|
|
CLabel * title;
|
|
|
|
CLabel * costText;
|
|
|
|
CLabel * costValue;
|
|
|
|
CGStatusBar *statusBar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
void close();
|
2011-04-07 20:54:08 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid);
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __CCASTLEINTERFACE_H__
|