CGameInterface.h 2.9 KB

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