1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/CCastleInterface.h

219 lines
5.8 KiB
C
Raw Normal View History

#pragma once
2008-01-09 19:21:31 +02:00
#include "global.h"
#include "SDL.h"
#include "CPlayerInterface.h"
//#include "boost/tuple/tuple.hpp"
2008-01-09 19:21:31 +02:00
class CGTownInstance;
class CTownHandler;
2008-03-11 23:36:59 +02:00
class CHallInterface;
struct Structure;
class CSpell;
class AdventureMapButton;
2008-01-24 00:15:33 +02:00
class CBuildingRect : public Hoverable, public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested
2008-01-09 19:21:31 +02: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;
CBuildingRect(Structure *Str);
~CBuildingRect();
2008-01-09 19:21:31 +02:00
void activate();
void deactivate();
bool operator<(const CBuildingRect & p2) const;
2008-01-20 18:24:03 +02:00
void hover(bool on);
void clickLeft (tribool down);
void clickRight (tribool down);
2008-01-24 00:15:33 +02:00
void mouseMoved (SDL_MouseMotionEvent & sEvent);
2008-01-09 19:21:31 +02:00
};
class CHeroGSlot : public ClickableL, public ClickableR, public Hoverable
{
public:
CCastleInterface *owner;
const CGHeroInstance *hero;
int upg; //0 - up garrison, 1 - down garrison
bool highlight;
void hover (bool on);
void clickRight (boost::logic::tribool down);
void clickLeft(boost::logic::tribool down);
void activate();
void deactivate();
void show();
CHeroGSlot(int x, int y, int updown, const CGHeroInstance *h,CCastleInterface * Owner);
~CHeroGSlot();
};
class CCastleInterface : public CMainInterface
2008-01-09 19:21:31 +02:00
{
public:
2008-03-11 23:36:59 +02:00
bool showing;
2008-01-24 00:15:33 +02:00
CBuildingRect * hBuild; //highlighted building
2008-01-09 19:21:31 +02:00
SDL_Surface * townInt;
SDL_Surface * cityBg;
const CGTownInstance * town;
CStatusBar * statusbar;
2008-01-19 14:26:55 +02:00
unsigned char animval, count;
CDefHandler *hall,*fort;
CDefEssential* bicons; //150x70 buildings imgs
CTownList * townlist;
CHeroGSlot hslotup, hslotdown;
CGarrisonInt * garr;
AdventureMapButton *exit;
AdventureMapButton *split;
2008-01-09 19:21:31 +02:00
std::vector<CBuildingRect*> buildings; //building id, building def, structure struct, border, filling
2008-01-09 19:21:31 +02:00
CCastleInterface(const CGTownInstance * Town, bool Activate=true);
~CCastleInterface();
void townChange();
2008-01-19 14:26:55 +02:00
void show(SDL_Surface * to=NULL);
void showAll(SDL_Surface * to=NULL, bool forceTotalRedraw = false);
2008-03-10 01:06:35 +02:00
void buildingClicked(int building);
void enterMageGuild();
CRecrutationWindow * showRecruitmentWindow(int building);
2008-03-10 01:06:35 +02:00
void enterHall();
2008-01-09 19:21:31 +02:00
void close();
void splitF();
2008-01-09 19:21:31 +02:00
void activate();
void deactivate();
void addBuilding(int bid);
void removeBuilding(int bid);
void recreateBuildings();
2008-03-10 01:06:35 +02:00
};
class CHallInterface : public IShowActivable
2008-03-10 01:06:35 +02:00
{
public:
CMinorResDataBar resdatabar;
2008-03-10 01:06:35 +02:00
class CBuildingBox : public Hoverable, public ClickableL, public ClickableR
{
public:
2008-03-21 02:03:31 +02:00
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
2008-03-10 01:06:35 +02:00
void hover(bool on);
void clickLeft (tribool down);
void clickRight (tribool down);
2008-03-11 23:36:59 +02:00
void show(SDL_Surface * to=NULL);
2008-03-10 01:06:35 +02:00
void activate();
void deactivate();
2008-03-11 23:36:59 +02:00
CBuildingBox(int id);
CBuildingBox(int id, int x, int y);
2008-03-10 01:06:35 +02:00
~CBuildingBox();
};
2008-03-21 02:03:31 +02:00
class CBuildWindow: public IShowable, public ClickableR
{
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);
2008-03-21 02:03:31 +02:00
void clickRight (tribool down);
void show(SDL_Surface * to=NULL);
2008-03-21 02:03:31 +02:00
void Buy();
void close();
CBuildWindow(int Tid, int Bid, int State, bool Mode);
~CBuildWindow();
};
2008-03-11 23:36:59 +02:00
CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
*status; //0 - already, 1 - can't, 2 - lack of resources
std::vector< std::vector<CBuildingBox*> >boxes;
2008-03-10 01:06:35 +02:00
AdventureMapButton *exit;
2008-03-10 01:06:35 +02:00
SDL_Surface * bg;
CHallInterface(CCastleInterface * owner);
~CHallInterface();
void close();
void show(SDL_Surface * to=NULL);
void activate();
void deactivate();
};
class CFortScreen : public CMainInterface
{
class RecArea : public ClickableL
{
public:
int bid;
RecArea(int BID):bid(BID){};
void clickLeft (tribool down);
void activate();
void deactivate();
};
public:
CMinorResDataBar resdatabar;
AdventureMapButton *exit;
SDL_Surface * bg;
std::vector<SDL_Rect> positions;
std::vector<RecArea*> recAreas;
std::vector<CCreaturePic*> crePics;
CFortScreen(CCastleInterface * owner);
void draw( CCastleInterface * owner, bool first);
~CFortScreen();
void close();
void show(SDL_Surface * to=NULL);
void activate();
void deactivate();
};
class CMageGuildScreen : public IShowActivable
{
public:
class Scroll : public ClickableL, public Hoverable, public ClickableR
{
public:
CSpell *spell;
Scroll(CSpell *Spell):spell(Spell){};
void clickLeft (tribool down);
void clickRight (tribool down);
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;
CMinorResDataBar resdatabar;
CMageGuildScreen(CCastleInterface * owner);
~CMageGuildScreen();
void close();
void show(SDL_Surface * to=NULL);
void activate();
void deactivate();
};
class CBlacksmithDialog : public IShowable, public CIntObject
{
public:
AdventureMapButton *buy, *cancel;
SDL_Surface *bmp;
CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid);
~CBlacksmithDialog();
void close();
void show(SDL_Surface * to=NULL);
void activate();
void deactivate();
};