CGameInterface.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef CGAMEINTERFACE_H
  2. #define CGAMEINTERFACE_H
  3. #include "SDL.h"
  4. #include <boost/logic/tribool.hpp>
  5. #include "SDL_framerate.h"
  6. BOOST_TRIBOOL_THIRD_STATE(outOfRange)
  7. using namespace boost::logic;
  8. class CAdvMapInt;
  9. class CCallback;
  10. class CHeroInstance;
  11. class CDefHandler;
  12. struct HeroMoveDetails;
  13. class CIntObject //interface object
  14. {
  15. public:
  16. SDL_Rect pos;
  17. int ID;
  18. };
  19. class CButtonBase : public virtual CIntObject
  20. {
  21. public:
  22. int type; //advmapbutton=2
  23. bool abs;
  24. bool active;
  25. CIntObject * ourObj;
  26. int state;
  27. std::vector< std::vector<SDL_Surface*> > imgs;
  28. int curimg;
  29. virtual void show() ;
  30. virtual void activate()=0;
  31. virtual void deactivate()=0;
  32. CButtonBase();
  33. };
  34. class ClickableL : public virtual CIntObject //for left-clicks
  35. {
  36. public:
  37. bool pressedL;
  38. ClickableL();
  39. virtual void clickLeft (tribool down)=0;
  40. virtual void activate()=0;
  41. virtual void deactivate()=0;
  42. };
  43. class ClickableR : public virtual CIntObject //for right-clicks
  44. {
  45. public:
  46. bool pressedR;
  47. ClickableR();
  48. virtual void clickRight (tribool down)=0;
  49. virtual void activate()=0;
  50. virtual void deactivate()=0;
  51. };
  52. class Hoverable : public virtual CIntObject
  53. {
  54. public:
  55. Hoverable(){hovered=false;}
  56. bool hovered;
  57. virtual void hover (bool on)=0;
  58. virtual void activate()=0;
  59. virtual void deactivate()=0;
  60. };
  61. class KeyInterested : public virtual CIntObject
  62. {
  63. public:
  64. virtual void keyPressed (SDL_KeyboardEvent & key)=0;
  65. virtual void activate()=0;
  66. virtual void deactivate()=0;
  67. };
  68. class MotionInterested: public virtual CIntObject
  69. {
  70. public:
  71. virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
  72. virtual void activate()=0;
  73. virtual void deactivate()=0;
  74. };
  75. class CGameInterface
  76. {
  77. public:
  78. bool human;
  79. int playerID, serialID;
  80. virtual void yourTurn()=0{};
  81. virtual void heroKilled(const CHeroInstance * hero)=0{};
  82. virtual void heroCreated(const CHeroInstance * hero)=0{};
  83. virtual void heroMoved(const HeroMoveDetails & details)=0;
  84. };
  85. class CGlobalAI : public CGameInterface // AI class (to derivate)
  86. {
  87. public:
  88. virtual void yourTurn(){};
  89. virtual void heroKilled(const CHeroInstance * hero){};
  90. virtual void heroCreated(const CHeroInstance * hero){};
  91. };
  92. class CPlayerInterface : public CGameInterface
  93. {
  94. public:
  95. SDL_Event * current;
  96. CAdvMapInt * adventureInt;
  97. FPSmanager * mainFPSmng;
  98. //TODO: town interace, battle interface, other interfaces
  99. CCallback * cb;
  100. std::vector<ClickableL*> lclickable;
  101. std::vector<ClickableR*> rclickable;
  102. std::vector<Hoverable*> hoverable;
  103. std::vector<KeyInterested*> keyinterested;
  104. std::vector<MotionInterested*> motioninterested;
  105. SDL_Surface * hInfo;
  106. //overloaded funcs from Interface
  107. void yourTurn();
  108. void heroMoved(const HeroMoveDetails & details);
  109. void heroKilled(const CHeroInstance * hero);
  110. void heroCreated(const CHeroInstance * hero);
  111. 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*
  112. void handleEvent(SDL_Event * sEvent);
  113. void init(CCallback * CB);
  114. CPlayerInterface(int Player, int serial);
  115. };
  116. #endif //CGAMEINTERFACE_H