2007-08-04 00:47:34 +03:00
|
|
|
#ifndef CADVENTUREMAPINTERFACE_H
|
|
|
|
#define CADVENTUREMAPINTERFACE_H
|
2007-09-14 16:11:10 +03:00
|
|
|
#include <typeinfo>
|
2007-09-18 16:30:26 +03:00
|
|
|
#include "global.h"
|
2007-08-04 00:47:34 +03:00
|
|
|
#include "SDL.h"
|
|
|
|
#include "CGameInterface.h"
|
|
|
|
#include <boost/logic/tribool.hpp>
|
2007-09-18 16:30:26 +03:00
|
|
|
#include <map>
|
2007-08-12 20:48:05 +03:00
|
|
|
|
2007-09-18 16:30:26 +03:00
|
|
|
class CDefHandler;
|
2007-09-14 16:11:10 +03:00
|
|
|
class CCallback;
|
2007-09-18 16:30:26 +03:00
|
|
|
class CTownInstance;
|
|
|
|
class CPath;
|
2007-09-14 16:11:10 +03:00
|
|
|
|
2007-08-04 00:47:34 +03:00
|
|
|
class AdventureMapButton
|
|
|
|
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string name; //for status bar
|
|
|
|
std::string helpBox; //for right-click help
|
|
|
|
char key; //key shortcut
|
|
|
|
void (CAdvMapInt::*function)(); //function in CAdvMapInt called when this button is pressed, different for each button
|
|
|
|
|
|
|
|
void clickRight (tribool down);
|
|
|
|
void clickLeft (tribool down);
|
|
|
|
void hover (bool on);
|
|
|
|
void keyPressed (SDL_KeyboardEvent & key);
|
|
|
|
void activate(); // makes button active
|
|
|
|
void deactivate(); // makes button inactive (but don't deletes)
|
|
|
|
|
|
|
|
AdventureMapButton(); //c-tor
|
2007-08-08 22:28:56 +03:00
|
|
|
AdventureMapButton( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ=false, std::vector<std::string> * add = NULL );//c-tor
|
2007-08-04 00:47:34 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
/*****************************/
|
|
|
|
class CList
|
2007-09-14 16:11:10 +03:00
|
|
|
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
|
2007-08-04 00:47:34 +03:00
|
|
|
{
|
2007-08-25 07:56:25 +03:00
|
|
|
public:
|
2007-08-04 00:47:34 +03:00
|
|
|
SDL_Surface * bg;
|
2007-09-02 15:36:54 +03:00
|
|
|
CDefHandler *arrup, *arrdo;
|
2007-09-14 16:11:10 +03:00
|
|
|
SDL_Surface *empty, *selection;
|
|
|
|
SDL_Rect arrupp, arrdop; //positions of arrows
|
2007-08-04 00:47:34 +03:00
|
|
|
int posw, posh; //position width/height
|
2007-09-14 16:11:10 +03:00
|
|
|
int selected, //id of selected position, <0 if none
|
|
|
|
from;
|
|
|
|
tribool pressed; //true=up; false=down; indeterminate=none
|
2007-08-04 00:47:34 +03:00
|
|
|
|
|
|
|
void clickLeft(tribool down);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
2007-09-14 16:11:10 +03:00
|
|
|
virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
|
|
|
|
virtual void genList()=0;
|
2007-08-04 00:47:34 +03:00
|
|
|
virtual void select(int which)=0;
|
2007-09-14 16:11:10 +03:00
|
|
|
virtual void draw()=0;
|
2007-08-04 00:47:34 +03:00
|
|
|
};
|
|
|
|
class CHeroList
|
|
|
|
: public CList
|
|
|
|
{
|
2007-08-25 07:56:25 +03:00
|
|
|
public:
|
2007-09-02 15:36:54 +03:00
|
|
|
CDefHandler *mobile, *mana;
|
2007-09-14 16:11:10 +03:00
|
|
|
std::vector<const CHeroInstance*> items;
|
|
|
|
int posmobx, posporx, posmanx, posmoby, pospory, posmany;
|
2007-08-25 07:56:25 +03:00
|
|
|
|
|
|
|
CHeroList();
|
2007-09-14 16:11:10 +03:00
|
|
|
void genList();
|
2007-08-04 00:47:34 +03:00
|
|
|
void select(int which);
|
2007-09-14 16:11:10 +03:00
|
|
|
void mouseMoved (SDL_MouseMotionEvent & sEvent);
|
2007-08-25 07:56:25 +03:00
|
|
|
void clickLeft(tribool down);
|
2007-08-04 00:47:34 +03:00
|
|
|
void clickRight(tribool down);
|
2007-08-25 07:56:25 +03:00
|
|
|
void hover (bool on);
|
|
|
|
void keyPressed (SDL_KeyboardEvent & key);
|
2007-09-14 16:11:10 +03:00
|
|
|
void updateHList();
|
|
|
|
void redrawAllOne(int which);
|
|
|
|
void draw();
|
|
|
|
void init();
|
2007-08-04 00:47:34 +03:00
|
|
|
};
|
|
|
|
class CTownList
|
|
|
|
: public CList
|
|
|
|
{
|
2007-09-02 15:36:54 +03:00
|
|
|
public:
|
2007-09-18 16:30:26 +03:00
|
|
|
std::vector<const CTownInstance*> items;
|
|
|
|
int posporx,pospory;
|
2007-08-25 07:56:25 +03:00
|
|
|
|
|
|
|
CTownList();
|
2007-09-14 16:11:10 +03:00
|
|
|
void genList();
|
2007-08-04 00:47:34 +03:00
|
|
|
void select(int which);
|
2007-09-14 16:11:10 +03:00
|
|
|
void mouseMoved (SDL_MouseMotionEvent & sEvent);
|
2007-08-25 07:56:25 +03:00
|
|
|
void clickLeft(tribool down);
|
2007-08-04 00:47:34 +03:00
|
|
|
void clickRight(tribool down);
|
2007-08-25 07:56:25 +03:00
|
|
|
void hover (bool on);
|
|
|
|
void keyPressed (SDL_KeyboardEvent & key);
|
2007-09-14 16:11:10 +03:00
|
|
|
void draw();
|
2007-08-04 00:47:34 +03:00
|
|
|
};
|
|
|
|
class CResourceBar
|
|
|
|
:public ClickableR, public CIntObject
|
|
|
|
{
|
|
|
|
SDL_Surface * bg;
|
|
|
|
void clickRight(tribool down);
|
|
|
|
void refresh();
|
|
|
|
};
|
|
|
|
class CDataBar
|
|
|
|
:public ClickableR, public CIntObject
|
|
|
|
{
|
|
|
|
SDL_Surface * bg;
|
|
|
|
void clickRight(tribool down);
|
|
|
|
void refresh();
|
|
|
|
};
|
|
|
|
class CStatusBar
|
2007-08-04 22:01:22 +03:00
|
|
|
: public CIntObject
|
2007-08-04 00:47:34 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
public:
|
2007-08-07 14:54:50 +03:00
|
|
|
SDL_Surface * bg; //background
|
|
|
|
int middlex, middley; //middle of statusbar
|
|
|
|
std::string current; //text currently printed
|
2007-08-06 07:03:34 +03:00
|
|
|
|
2007-08-07 14:54:50 +03:00
|
|
|
CStatusBar(int x, int y); //c-tor
|
|
|
|
~CStatusBar(); //d-tor
|
|
|
|
void print(std::string text); //prints text and refreshes statusbar
|
|
|
|
void clear();//clears statusbar and refreshes
|
|
|
|
void show(); //shows statusbar (with current text)
|
2007-08-04 00:47:34 +03:00
|
|
|
};
|
|
|
|
class CMinimap
|
2007-08-27 17:15:03 +03:00
|
|
|
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
|
2007-08-04 00:47:34 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
public:
|
2007-08-20 00:12:55 +03:00
|
|
|
CDefHandler * radar; //radar.def; TODO: radars for maps with custom dimensions
|
|
|
|
std::map<int,SDL_Color> colors;
|
|
|
|
std::map<int,SDL_Color> colorsBlocked;
|
|
|
|
std::vector<SDL_Surface *> map; //one bitmap for each level
|
2007-08-04 00:47:34 +03:00
|
|
|
//TODO flagged buildings
|
2007-08-20 00:12:55 +03:00
|
|
|
std::string statusbarTxt;
|
2007-08-04 00:47:34 +03:00
|
|
|
|
2007-08-20 00:12:55 +03:00
|
|
|
CMinimap(bool draw=true);
|
|
|
|
void draw();
|
|
|
|
void redraw(int level=-1);// (level==-1) => redraw all levels
|
|
|
|
void updateRadar();
|
2007-08-04 00:47:34 +03:00
|
|
|
|
2007-08-20 00:12:55 +03:00
|
|
|
void clickRight (tribool down);
|
|
|
|
void clickLeft (tribool down);
|
|
|
|
void hover (bool on);
|
2007-08-27 17:15:03 +03:00
|
|
|
void mouseMoved (SDL_MouseMotionEvent & sEvent);
|
2007-08-20 00:12:55 +03:00
|
|
|
void activate(); // makes button active
|
|
|
|
void deactivate(); // makes button inactive (but don't deletes)
|
2007-08-04 22:01:22 +03:00
|
|
|
};
|
|
|
|
class CTerrainRect
|
2007-08-17 20:42:21 +03:00
|
|
|
: public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested
|
2007-08-04 22:01:22 +03:00
|
|
|
{
|
|
|
|
public:
|
2007-08-20 00:12:55 +03:00
|
|
|
int tilesw, tilesh;
|
2007-08-17 20:42:21 +03:00
|
|
|
CDefHandler * arrows;
|
|
|
|
CTerrainRect();
|
|
|
|
CPath * currentPath;
|
2007-08-04 22:01:22 +03:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
void clickLeft(tribool down);
|
|
|
|
void clickRight(tribool down);
|
|
|
|
void hover(bool on);
|
|
|
|
void keyPressed (SDL_KeyboardEvent & key);
|
|
|
|
void show();
|
2007-08-04 00:47:34 +03:00
|
|
|
};
|
2007-09-16 20:21:23 +03:00
|
|
|
class CResDataBar
|
|
|
|
:public ClickableR, public virtual CIntObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SDL_Surface * bg;
|
|
|
|
std::vector<std::pair<int,int> > txtpos;
|
2007-09-18 16:30:26 +03:00
|
|
|
std::string datetext;
|
2007-09-16 20:21:23 +03:00
|
|
|
|
|
|
|
void clickRight (tribool down);
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
CResDataBar();
|
|
|
|
~CResDataBar();
|
|
|
|
|
|
|
|
void draw();
|
|
|
|
};
|
2007-08-04 00:47:34 +03:00
|
|
|
/*****************************/
|
2007-08-04 22:01:22 +03:00
|
|
|
class CAdvMapInt //adventure map interface
|
2007-08-04 00:47:34 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
public:
|
2007-08-04 00:47:34 +03:00
|
|
|
CAdvMapInt(int Player);
|
|
|
|
~CAdvMapInt();
|
|
|
|
|
2007-08-04 22:01:22 +03:00
|
|
|
int3 position; //top left corner of visible map part
|
2007-08-04 00:47:34 +03:00
|
|
|
int player;
|
2007-08-04 22:01:22 +03:00
|
|
|
|
|
|
|
std::vector<CDefHandler *> gems;
|
|
|
|
|
|
|
|
|
|
|
|
bool scrollingLeft ;
|
|
|
|
bool scrollingRight ;
|
|
|
|
bool scrollingUp ;
|
|
|
|
bool scrollingDown ;
|
|
|
|
bool updateScreen ;
|
|
|
|
unsigned char anim, animValHitCount; //animation frame
|
|
|
|
|
2007-08-20 00:12:55 +03:00
|
|
|
CMinimap minimap;
|
2007-08-04 22:01:22 +03:00
|
|
|
|
|
|
|
|
2007-08-04 00:47:34 +03:00
|
|
|
SDL_Surface * bg;
|
|
|
|
AdventureMapButton kingOverview,//- kingdom overview
|
2007-08-08 22:28:56 +03:00
|
|
|
underground,//- underground switch
|
2007-08-04 00:47:34 +03:00
|
|
|
questlog,//- questlog
|
|
|
|
sleepWake, //- sleep/wake hero
|
|
|
|
moveHero, //- move hero
|
|
|
|
spellbook,//- spellbook
|
|
|
|
advOptions, //- adventure options
|
|
|
|
sysOptions,//- system options
|
|
|
|
nextHero, //- next hero
|
|
|
|
endTurn;//- end turn
|
|
|
|
//CHeroList herolist;
|
2007-08-04 22:01:22 +03:00
|
|
|
|
2007-08-06 07:03:34 +03:00
|
|
|
CTerrainRect terrain; //visible terrain
|
2007-08-04 00:47:34 +03:00
|
|
|
|
2007-08-06 07:03:34 +03:00
|
|
|
CStatusBar statusbar;
|
2007-09-16 20:21:23 +03:00
|
|
|
CResDataBar resdatabar;
|
2007-08-06 07:03:34 +03:00
|
|
|
|
2007-08-25 07:56:25 +03:00
|
|
|
CHeroList heroList;
|
|
|
|
CTownList townList;
|
|
|
|
|
2007-08-06 07:03:34 +03:00
|
|
|
//fuctions binded to buttons
|
|
|
|
void fshowOverview();
|
|
|
|
void fswitchLevel();
|
|
|
|
void fshowQuestlog();
|
|
|
|
void fsleepWake();
|
|
|
|
void fmoveHero();
|
|
|
|
void fshowSpellbok();
|
|
|
|
void fadventureOPtions();
|
|
|
|
void fsystemOptions();
|
|
|
|
void fnextHero();
|
|
|
|
void fendTurn();
|
|
|
|
|
|
|
|
void show(); //shows and activates adv. map interface
|
|
|
|
void update(); //redraws terrain
|
2007-08-04 22:01:22 +03:00
|
|
|
|
2007-09-14 16:11:10 +03:00
|
|
|
void centerOn(int3 on);
|
|
|
|
|
|
|
|
struct CurrentSelection
|
|
|
|
{
|
|
|
|
const type_info* type;
|
|
|
|
const void* selected;
|
|
|
|
CurrentSelection(); //ctor
|
|
|
|
} selection;
|
2007-08-04 00:47:34 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
#endif //CADVENTUREMAPINTERFACE_H
|