1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/CGameInterface.h

130 lines
3.2 KiB
C
Raw Normal View History

#ifndef CGAMEINTERFACE_H
#define CGAMEINTERFACE_H
#include "SDL.h"
#include <boost/logic/tribool.hpp>
2007-09-13 16:34:59 +03:00
#include "SDL_framerate.h"
BOOST_TRIBOOL_THIRD_STATE(outOfRange)
using namespace boost::logic;
class CAdvMapInt;
class CCallback;
class CHeroInstance;
class CDefHandler;
2007-08-29 13:05:50 +03:00
struct HeroMoveDetails;
class CIntObject //interface object
{
public:
SDL_Rect pos;
int ID;
};
class CButtonBase : public virtual CIntObject
{
public:
int type; //advmapbutton=2
bool abs;
bool active;
CIntObject * ourObj;
int state;
std::vector< std::vector<SDL_Surface*> > imgs;
int curimg;
virtual void show() ;
virtual void activate()=0;
virtual void deactivate()=0;
CButtonBase();
};
class ClickableL : public virtual CIntObject //for left-clicks
{
public:
bool pressedL;
2007-08-25 07:56:25 +03:00
ClickableL();
virtual void clickLeft (tribool down)=0;
virtual void activate()=0;
virtual void deactivate()=0;
};
class ClickableR : public virtual CIntObject //for right-clicks
{
public:
bool pressedR;
2007-08-25 07:56:25 +03:00
ClickableR();
virtual void clickRight (tribool down)=0;
virtual void activate()=0;
virtual void deactivate()=0;
};
class Hoverable : public virtual CIntObject
{
public:
Hoverable(){hovered=false;}
bool hovered;
virtual void hover (bool on)=0;
virtual void activate()=0;
virtual void deactivate()=0;
};
class KeyInterested : public virtual CIntObject
{
public:
virtual void keyPressed (SDL_KeyboardEvent & key)=0;
virtual void activate()=0;
virtual void deactivate()=0;
};
class MotionInterested: public virtual CIntObject
{
public:
virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
virtual void activate()=0;
virtual void deactivate()=0;
};
class CGameInterface
{
public:
bool human;
int playerID, serialID;
virtual void yourTurn()=0{};
virtual void heroKilled(const CHeroInstance * hero)=0{};
virtual void heroCreated(const CHeroInstance * hero)=0{};
2007-08-29 13:05:50 +03:00
virtual void heroMoved(const HeroMoveDetails & details)=0;
};
2007-08-25 07:56:25 +03:00
class CGlobalAI : public CGameInterface // AI class (to derivate)
{
public:
virtual void yourTurn(){};
virtual void heroKilled(const CHeroInstance * hero){};
virtual void heroCreated(const CHeroInstance * hero){};
};
class CPlayerInterface : public CGameInterface
{
public:
SDL_Event * current;
CAdvMapInt * adventureInt;
2007-09-13 16:34:59 +03:00
FPSmanager * mainFPSmng;
//TODO: town interace, battle interface, other interfaces
CCallback * cb;
std::vector<ClickableL*> lclickable;
std::vector<ClickableR*> rclickable;
std::vector<Hoverable*> hoverable;
std::vector<KeyInterested*> keyinterested;
std::vector<MotionInterested*> motioninterested;
SDL_Surface * hInfo;
//overloaded funcs from Interface
void yourTurn();
2007-08-29 13:05:50 +03:00
void heroMoved(const HeroMoveDetails & details);
void heroKilled(const CHeroInstance * hero);
void heroCreated(const CHeroInstance * hero);
SDL_Surface * infoWin(void * specific); //specific=0 => draws info about selected town/hero //TODO - gdy sie dorobi sensowna hierarchie klas ins. to wywalic tego brzydkiego void*
void handleEvent(SDL_Event * sEvent);
void init(CCallback * CB);
CPlayerInterface(int Player, int serial);
};
#endif //CGAMEINTERFACE_H