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 CGTownInstance;
|
|
|
|
class CTownHandler;
|
|
|
|
class CHallInterface;
|
|
|
|
struct Structure;
|
|
|
|
class CSpell;
|
|
|
|
class AdventureMapButton;
|
|
|
|
class CResDataBar;
|
2009-05-20 12:02:50 +03:00
|
|
|
class CStatusBar;
|
|
|
|
class CTownList;
|
|
|
|
class CRecruitmentWindow;
|
2010-07-03 15:00:53 +03:00
|
|
|
class CTransformerWindow;
|
2010-11-15 17:15:00 +02:00
|
|
|
class CPicture;
|
2009-05-20 12:02:50 +03:00
|
|
|
class CCreaturePic;
|
|
|
|
class CMinorResDataBar;
|
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
|
|
|
*/
|
|
|
|
|
2010-11-15 17:15:00 +02:00
|
|
|
class CBuildingRect : public CShowableAnim
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
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;
|
2010-12-17 20:47:07 +02:00
|
|
|
CBuildingRect(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
|
|
|
|
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();
|
|
|
|
void show(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
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CCastleInterface : public CWindowWithGarrison
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2009-12-23 03:46:15 +02:00
|
|
|
class CCreaInfo : public CIntObject
|
|
|
|
{
|
|
|
|
public:
|
2010-07-10 19:50:23 +03:00
|
|
|
int crid,level;
|
|
|
|
CCreaInfo(int CRID, int LVL); //c-tor
|
2009-12-30 09:49:25 +02:00
|
|
|
~CCreaInfo();//d-tor
|
2009-12-29 15:40:16 +02:00
|
|
|
int AddToString(std::string from, std::string & to, int numb);
|
2009-12-23 03:46:15 +02:00
|
|
|
void hover(bool on);
|
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
};
|
|
|
|
class CTownInfo : public CIntObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int bid;//typeID
|
|
|
|
CDefHandler * pic;
|
|
|
|
CTownInfo(int BID); //c-tor
|
|
|
|
~CTownInfo();//d-tor
|
|
|
|
void hover(bool on);
|
|
|
|
void clickLeft(tribool down, bool previousState);
|
|
|
|
void clickRight(tribool down, bool previousState);
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
};
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2009-04-17 17:01:22 +03:00
|
|
|
bool showing; //indicates if interface is active
|
2009-04-16 14:14:13 +03:00
|
|
|
CBuildingRect * hBuild; //highlighted building
|
|
|
|
SDL_Surface * townInt;
|
|
|
|
SDL_Surface * cityBg;
|
|
|
|
const CGTownInstance * town;
|
|
|
|
CStatusBar * statusbar;
|
|
|
|
CResDataBar *resdatabar;
|
|
|
|
unsigned char animval, count;
|
2010-02-28 12:01:36 +02:00
|
|
|
int winMode;//0=right-click popup, 1 = normal, 2 = town hall only, 3 = fort only;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
|
|
|
|
*status; //0 - already, 1 - can't, 2 - lack of resources
|
2009-12-23 03:46:15 +02:00
|
|
|
CTownInfo *hall,*fort,*market;
|
2009-04-16 14:14:13 +03:00
|
|
|
CDefEssential* bicons; //150x70 buildings imgs
|
|
|
|
CTownList * townlist;
|
|
|
|
|
|
|
|
CHeroGSlot hslotup, hslotdown;
|
|
|
|
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
|
|
|
std::vector<CBuildingRect*> buildings; //building id, building def, structure struct, border, filling
|
|
|
|
|
2009-07-20 11:18:33 +03:00
|
|
|
CCastleInterface(const CGTownInstance * Town, int listPos = 1); //c-tor
|
2009-05-07 20:20:41 +03:00
|
|
|
~CCastleInterface(); //d-tor
|
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-04-16 14:14:13 +03:00
|
|
|
void show(SDL_Surface * to);
|
|
|
|
void showAll(SDL_Surface * to);
|
2009-12-30 09:49:25 +02:00
|
|
|
void buildingClicked(int building);
|
2009-12-29 15:40:16 +02:00
|
|
|
void defaultBuildingClicked(int building);//for buildings with simple description + pic left-click messages
|
2010-01-25 23:25:14 +02:00
|
|
|
void enterFountain(int building);
|
|
|
|
void enterBlacksmith(int ArtifactID);//support for blacksmith + ballista yard
|
2009-05-22 02:50:45 +03:00
|
|
|
void enterTavern();
|
2009-04-16 14:14:13 +03:00
|
|
|
void enterMageGuild();
|
2009-09-09 09:04:42 +03:00
|
|
|
void splitClicked(); //for hero meeting (splitting stacks is handled by garrison int)
|
2010-07-26 01:47:59 +03:00
|
|
|
void showRecruitmentWindow( int level );
|
2009-04-16 14:14:13 +03:00
|
|
|
void enterHall();
|
|
|
|
void close();
|
|
|
|
void splitF();
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
void addBuilding(int bid);
|
|
|
|
void removeBuilding(int bid);
|
|
|
|
void recreateBuildings();
|
2009-12-23 03:46:15 +02:00
|
|
|
void recreateIcons();
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
2010-08-28 18:10:37 +03:00
|
|
|
class CHallInterface : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2009-05-20 12:02:50 +03:00
|
|
|
CMinorResDataBar * resdatabar;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBuildingBox : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int BID;
|
2010-01-25 23:25:14 +02:00
|
|
|
int state;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - already builded today, 6 - cannot afford, 7 - build, 8 - lack of requirements
|
2009-04-16 14:14:13 +03:00
|
|
|
//(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists
|
|
|
|
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 show(SDL_Surface * to);
|
2009-05-07 20:20:41 +03:00
|
|
|
CBuildingBox(int id); //c-tor
|
|
|
|
CBuildingBox(int id, int x, int y); //c-tor
|
|
|
|
~CBuildingBox(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBuildWindow: public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int tid, bid, state; //town id, building id, state
|
|
|
|
bool mode; // 0 - normal (with buttons), 1 - r-click popup
|
|
|
|
SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
|
|
|
|
AdventureMapButton *buy, *cancel;
|
|
|
|
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
std::string getTextForState(int state);
|
2009-08-11 19:05:33 +03:00
|
|
|
void clickRight(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void show(SDL_Surface * to);
|
|
|
|
void Buy();
|
|
|
|
void close();
|
2009-05-07 20:20:41 +03:00
|
|
|
CBuildWindow(int Tid, int Bid, int State, bool Mode); //c-tor
|
|
|
|
~CBuildWindow(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector< std::vector<CBuildingBox*> >boxes;
|
|
|
|
|
|
|
|
AdventureMapButton *exit;
|
|
|
|
|
2009-05-07 20:20:41 +03:00
|
|
|
SDL_Surface * bg; //background
|
2009-12-29 15:40:16 +02:00
|
|
|
int bid;//building ID
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-05-07 20:20:41 +03:00
|
|
|
CHallInterface(CCastleInterface * owner); //c-tor
|
|
|
|
~CHallInterface(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
2011-02-06 19:26:27 +02:00
|
|
|
void showAll(SDL_Surface * to);
|
2009-04-16 14:14:13 +03:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CFortScreen : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2009-08-11 19:05:33 +03:00
|
|
|
class RecArea : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2010-07-26 01:47:59 +03:00
|
|
|
int level;
|
|
|
|
RecArea(int LEVEL):level(LEVEL){used = LCLICK | RCLICK;}; //c-tor
|
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
|
|
|
};
|
|
|
|
public:
|
2009-05-20 12:02:50 +03:00
|
|
|
CMinorResDataBar * resdatabar;
|
2010-07-26 01:47:59 +03:00
|
|
|
int fortSize;
|
2009-04-16 14:14:13 +03:00
|
|
|
AdventureMapButton *exit;
|
|
|
|
SDL_Surface * bg;
|
|
|
|
std::vector<Rect> positions;
|
|
|
|
std::vector<RecArea*> recAreas;
|
|
|
|
std::vector<CCreaturePic*> crePics;
|
|
|
|
|
2009-04-17 17:01:22 +03:00
|
|
|
CFortScreen(CCastleInterface * owner); //c-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
void draw( CCastleInterface * owner, bool first);
|
2009-04-17 17:01:22 +03:00
|
|
|
~CFortScreen(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
|
|
|
void show(SDL_Surface * to);
|
2011-02-06 19:26:27 +02:00
|
|
|
void showAll(SDL_Surface * to);
|
2009-04-16 14:14:13 +03:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CMageGuildScreen : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2010-02-28 12:01:36 +02:00
|
|
|
public:
|
2009-08-11 19:05:33 +03:00
|
|
|
class Scroll : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2010-12-17 20:47:07 +02:00
|
|
|
const CSpell *spell;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-02-06 19:26:27 +02:00
|
|
|
Scroll(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);
|
|
|
|
};
|
|
|
|
std::vector<std::vector<SDL_Rect> > positions;
|
|
|
|
|
2010-11-15 17:15:00 +02:00
|
|
|
CPicture *bg;
|
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;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
|
|
|
|
2009-05-07 20:20:41 +03:00
|
|
|
CMageGuildScreen(CCastleInterface * owner); //c-tor
|
|
|
|
~CMageGuildScreen(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
2010-11-15 17:15:00 +02:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBlacksmithDialog : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AdventureMapButton *buy, *cancel;
|
2010-11-15 17:15:00 +02:00
|
|
|
CPicture *bmp; //background
|
2011-02-06 19:26:27 +02:00
|
|
|
CPicture *animBG;
|
2010-11-15 17:15:00 +02:00
|
|
|
CCreatureAnim * anim;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-05-07 20:20:41 +03:00
|
|
|
CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid); //c-tor
|
|
|
|
~CBlacksmithDialog(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
void close();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __CCASTLEINTERFACE_H__
|