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"
2007-08-04 00:47:34 +03:00
# include <boost/logic/tribool.hpp>
2007-09-13 16:34:59 +03:00
# include "SDL_framerate.h"
2007-09-18 16:30:26 +03:00
2007-08-04 00:47:34 +03:00
BOOST_TRIBOOL_THIRD_STATE ( outOfRange )
2007-09-18 16:30:26 +03:00
2007-08-04 00:47:34 +03:00
using namespace boost : : logic ;
2007-09-18 16:30:26 +03:00
2007-08-04 00:47:34 +03:00
class CAdvMapInt ;
2007-09-14 16:11:10 +03:00
class CCallback ;
class CHeroInstance ;
2007-09-18 16:30:26 +03:00
class CDefHandler ;
2007-08-29 13:05:50 +03:00
struct HeroMoveDetails ;
2007-09-18 16:30:26 +03:00
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-09-14 16:11:10 +03:00
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-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-09-14 16:11:10 +03:00
virtual void heroKilled ( const CHeroInstance * hero ) { } ;
virtual void heroCreated ( const CHeroInstance * hero ) { } ;
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 ;
2007-09-13 16:34:59 +03:00
FPSmanager * mainFPSmng ;
2007-08-04 22:01:22 +03:00
//TODO: town interace, battle interface, other interfaces
2007-08-04 00:47:34 +03:00
2007-09-14 16:11:10 +03:00
CCallback * cb ;
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-09-30 19:16:00 +03:00
SDL_Surface * hInfo ;
//overloaded funcs from Interface
2007-08-04 22:01:22 +03:00
void yourTurn ( ) ;
2007-08-29 13:05:50 +03:00
void heroMoved ( const HeroMoveDetails & details ) ;
2007-09-14 16:11:10 +03:00
void heroKilled ( const CHeroInstance * hero ) ;
void heroCreated ( const CHeroInstance * hero ) ;
2007-09-30 19:16:00 +03:00
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*
2007-09-14 16:11:10 +03:00
2007-07-28 12:44:10 +03:00
void handleEvent ( SDL_Event * sEvent ) ;
2007-09-14 16:11:10 +03:00
void init ( CCallback * CB ) ;
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