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"
|
2009-04-16 14:14:13 +03:00
|
|
|
#include <SDL.h>
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "GUIBase.h"
|
|
|
|
#include "../hch/CMusicBase.h"
|
2009-04-16 14:14:13 +03:00
|
|
|
//#include "boost/tuple/tuple.hpp"
|
|
|
|
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;
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBuildingRect : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool moi; //motion interested is active
|
|
|
|
int offset, max; //first and last animation frame
|
|
|
|
Structure* str;
|
|
|
|
CDefHandler* def;
|
|
|
|
SDL_Surface* border;
|
|
|
|
SDL_Surface* area;
|
2009-05-07 20:20:41 +03:00
|
|
|
CBuildingRect(Structure *Str); //c-tor
|
|
|
|
~CBuildingRect(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
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);
|
|
|
|
};
|
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 clickRight(tribool down, bool previousState);
|
|
|
|
void clickLeft(tribool down, bool previousState);
|
2009-04-16 14:14:13 +03:00
|
|
|
void activate();
|
|
|
|
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
|
|
|
{
|
|
|
|
public:
|
2009-04-17 17:01:22 +03:00
|
|
|
SDL_Rect pos; //why not inherit this member from CIntObject ?
|
|
|
|
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;
|
|
|
|
|
|
|
|
CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
|
|
|
|
*status; //0 - already, 1 - can't, 2 - lack of resources
|
|
|
|
CDefHandler *hall,*fort;
|
|
|
|
CDefEssential* bicons; //150x70 buildings imgs
|
|
|
|
CTownList * townlist;
|
|
|
|
|
|
|
|
CHeroGSlot hslotup, hslotdown;
|
|
|
|
AdventureMapButton *exit;
|
|
|
|
AdventureMapButton *split;
|
|
|
|
|
2009-05-01 02:25:17 +03:00
|
|
|
musicBase::musicID musicID;
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
void buildingClicked(int building);
|
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)
|
2009-05-12 06:43:40 +03:00
|
|
|
CRecruitmentWindow * showRecruitmentWindow(int building);
|
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();
|
|
|
|
};
|
|
|
|
class CHallInterface : public IShowActivable
|
|
|
|
{
|
|
|
|
public:
|
2009-05-20 12:02:50 +03:00
|
|
|
CMinorResDataBar * resdatabar;
|
2009-04-16 14:14:13 +03:00
|
|
|
SDL_Rect pos;
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBuildingBox : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int BID;
|
|
|
|
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 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
|
|
|
|
//(-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);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
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-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();
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
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:
|
|
|
|
int bid;
|
2009-04-17 17:01:22 +03:00
|
|
|
RecArea(int BID):bid(BID){}; //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
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
public:
|
2009-05-20 12:02:50 +03:00
|
|
|
CMinorResDataBar * resdatabar;
|
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);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CMageGuildScreen : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2009-08-11 19:05:33 +03:00
|
|
|
class Scroll : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CSpell *spell;
|
|
|
|
|
|
|
|
Scroll(CSpell *Spell):spell(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);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
std::vector<std::vector<SDL_Rect> > positions;
|
|
|
|
|
|
|
|
SDL_Surface *bg;
|
|
|
|
CDefEssential *scrolls, *scrolls2;
|
|
|
|
AdventureMapButton *exit;
|
|
|
|
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();
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
|
2009-08-11 19:05:33 +03:00
|
|
|
class CBlacksmithDialog : public CIntObject
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AdventureMapButton *buy, *cancel;
|
2009-05-07 20:20:41 +03:00
|
|
|
SDL_Surface *bmp; //background
|
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();
|
|
|
|
void show(SDL_Surface * to);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __CCASTLEINTERFACE_H__
|