2007-08-01 17:06:04 +03:00
|
|
|
#ifndef CGAMEINTERFACE_H
|
|
|
|
#define CGAMEINTERFACE_H
|
|
|
|
|
2007-07-28 12:44:10 +03:00
|
|
|
#include "SDL.h"
|
|
|
|
#include "CDefHandler.h"
|
|
|
|
#include "SDL_Extensions.h"
|
2007-08-04 00:47:34 +03:00
|
|
|
#include <boost/logic/tribool.hpp>
|
|
|
|
BOOST_TRIBOOL_THIRD_STATE(outOfRange)
|
|
|
|
using namespace boost::logic;
|
|
|
|
class CAdvMapInt;
|
|
|
|
|
2007-07-28 12:44:10 +03:00
|
|
|
class CIntObject //interface object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SDL_Rect pos;
|
|
|
|
int ID;
|
|
|
|
};
|
2007-08-06 07:03:34 +03:00
|
|
|
class CButtonBase : public virtual CIntObject
|
2007-07-28 12:44:10 +03:00
|
|
|
{
|
|
|
|
public:
|
2007-08-04 00:47:34 +03:00
|
|
|
int type; //advmapbutton=2
|
2007-07-28 12:44:10 +03:00
|
|
|
bool abs;
|
2007-08-04 00:47:34 +03:00
|
|
|
bool active;
|
2007-07-28 12:44:10 +03:00
|
|
|
CIntObject * ourObj;
|
|
|
|
int state;
|
2007-08-08 22:28:56 +03:00
|
|
|
std::vector< std::vector<SDL_Surface*> > imgs;
|
|
|
|
int curimg;
|
2007-07-28 12:44:10 +03:00
|
|
|
virtual void show() ;
|
2007-08-04 00:47:34 +03:00
|
|
|
virtual void activate()=0;
|
|
|
|
virtual void deactivate()=0;
|
|
|
|
CButtonBase();
|
2007-07-28 12:44:10 +03:00
|
|
|
};
|
2007-08-06 07:03:34 +03:00
|
|
|
class ClickableL : public virtual CIntObject //for left-clicks
|
2007-07-28 12:44:10 +03:00
|
|
|
{
|
2007-08-04 00:47:34 +03:00
|
|
|
public:
|
2007-08-06 07:03:34 +03:00
|
|
|
bool pressedL;
|
2007-08-25 07:56:25 +03:00
|
|
|
ClickableL();
|
2007-08-04 00:47:34 +03:00
|
|
|
virtual void clickLeft (tribool down)=0;
|
|
|
|
virtual void activate()=0;
|
|
|
|
virtual void deactivate()=0;
|
2007-07-28 12:44:10 +03:00
|
|
|
};
|
2007-08-06 07:03:34 +03:00
|
|
|
class ClickableR : public virtual CIntObject //for right-clicks
|
2007-07-28 12:44:10 +03:00
|
|
|
{
|
2007-08-04 00:47:34 +03:00
|
|
|
public:
|
2007-08-06 07:03:34 +03:00
|
|
|
bool pressedR;
|
2007-08-25 07:56:25 +03:00
|
|
|
ClickableR();
|
2007-08-04 00:47:34 +03:00
|
|
|
virtual void clickRight (tribool down)=0;
|
|
|
|
virtual void activate()=0;
|
|
|
|
virtual void deactivate()=0;
|
2007-07-28 12:44:10 +03:00
|
|
|
};
|
2007-08-06 07:03:34 +03:00
|
|
|
class Hoverable : public virtual CIntObject
|
2007-07-28 12:44:10 +03:00
|
|
|
{
|
2007-08-04 00:47:34 +03:00
|
|
|
public:
|
2007-08-07 14:54:50 +03:00
|
|
|
Hoverable(){hovered=false;}
|
2007-07-28 12:44:10 +03:00
|
|
|
bool hovered;
|
|
|
|
virtual void hover (bool on)=0;
|
2007-08-04 00:47:34 +03:00
|
|
|
virtual void activate()=0;
|
|
|
|
virtual void deactivate()=0;
|
2007-07-28 12:44:10 +03:00
|
|
|
};
|
2007-08-06 07:03:34 +03:00
|
|
|
class KeyInterested : public virtual CIntObject
|
2007-07-28 12:44:10 +03:00
|
|
|
{
|
2007-08-04 00:47:34 +03:00
|
|
|
public:
|
2007-07-28 12:44:10 +03:00
|
|
|
virtual void keyPressed (SDL_KeyboardEvent & key)=0;
|
2007-08-04 00:47:34 +03:00
|
|
|
virtual void activate()=0;
|
|
|
|
virtual void deactivate()=0;
|
|
|
|
};
|
2007-08-27 17:15:03 +03:00
|
|
|
class MotionInterested: public virtual CIntObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
|
|
|
|
virtual void activate()=0;
|
|
|
|
virtual void deactivate()=0;
|
|
|
|
};
|
2007-08-04 00:47:34 +03:00
|
|
|
class CGameInterface
|
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
public:
|
|
|
|
bool human;
|
2007-08-06 07:03:34 +03:00
|
|
|
int playerID, serialID;
|
2007-08-04 22:01:22 +03:00
|
|
|
|
|
|
|
virtual void yourTurn()=0{};
|
2007-08-04 00:47:34 +03:00
|
|
|
};
|
2007-08-25 07:56:25 +03:00
|
|
|
class CGlobalAI : public CGameInterface // AI class (to derivate)
|
2007-08-04 00:47:34 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
public:
|
|
|
|
virtual void yourTurn(){};
|
2007-07-28 12:44:10 +03:00
|
|
|
};
|
2007-08-04 22:01:22 +03:00
|
|
|
class CPlayerInterface : public CGameInterface
|
2007-07-28 12:44:10 +03:00
|
|
|
{
|
2007-08-04 00:47:34 +03:00
|
|
|
public:
|
2007-08-20 00:12:55 +03:00
|
|
|
SDL_Event * current;
|
2007-08-04 22:01:22 +03:00
|
|
|
CAdvMapInt * adventureInt;
|
|
|
|
//TODO: town interace, battle interface, other interfaces
|
2007-08-04 00:47:34 +03:00
|
|
|
|
2007-07-28 12:44:10 +03:00
|
|
|
std::vector<ClickableL*> lclickable;
|
|
|
|
std::vector<ClickableR*> rclickable;
|
|
|
|
std::vector<Hoverable*> hoverable;
|
|
|
|
std::vector<KeyInterested*> keyinterested;
|
2007-08-27 17:15:03 +03:00
|
|
|
std::vector<MotionInterested*> motioninterested;
|
2007-08-04 00:47:34 +03:00
|
|
|
|
2007-08-04 22:01:22 +03:00
|
|
|
void yourTurn();
|
2007-07-28 12:44:10 +03:00
|
|
|
void handleEvent(SDL_Event * sEvent);
|
2007-08-06 07:03:34 +03:00
|
|
|
void init();
|
2007-08-04 22:01:22 +03:00
|
|
|
|
2007-08-06 07:03:34 +03:00
|
|
|
CPlayerInterface(int Player, int serial);
|
2007-08-01 17:06:04 +03:00
|
|
|
};
|
|
|
|
#endif //CGAMEINTERFACE_H
|