CGameInterface.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 CSimpleWindow : public virtual CIntObject
  20. {
  21. public:
  22. SDL_Surface * bitmap;
  23. CIntObject * owner;
  24. CSimpleWindow():bitmap(NULL),owner(NULL){};
  25. virtual ~CSimpleWindow();
  26. };
  27. class CButtonBase : public virtual CIntObject //basic buttton class
  28. {
  29. public:
  30. int type; //advmapbutton=2
  31. bool abs;
  32. bool active;
  33. CIntObject * ourObj;
  34. int state;
  35. std::vector< std::vector<SDL_Surface*> > imgs;
  36. int curimg;
  37. virtual void show() ;
  38. virtual void activate()=0;
  39. virtual void deactivate()=0;
  40. CButtonBase();
  41. };
  42. class ClickableL : public virtual CIntObject //for left-clicks
  43. {
  44. public:
  45. bool pressedL;
  46. ClickableL();
  47. virtual void clickLeft (tribool down)=0;
  48. virtual void activate()=0;
  49. virtual void deactivate()=0;
  50. };
  51. class ClickableR : public virtual CIntObject //for right-clicks
  52. {
  53. public:
  54. bool pressedR;
  55. ClickableR();
  56. virtual void clickRight (tribool down)=0;
  57. virtual void activate()=0;
  58. virtual void deactivate()=0;
  59. };
  60. class Hoverable : public virtual CIntObject
  61. {
  62. public:
  63. Hoverable(){hovered=false;}
  64. bool hovered;
  65. virtual void hover (bool on)=0;
  66. virtual void activate()=0;
  67. virtual void deactivate()=0;
  68. };
  69. class KeyInterested : public virtual CIntObject
  70. {
  71. public:
  72. virtual void keyPressed (SDL_KeyboardEvent & key)=0;
  73. virtual void activate()=0;
  74. virtual void deactivate()=0;
  75. };
  76. class MotionInterested: public virtual CIntObject
  77. {
  78. public:
  79. virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
  80. virtual void activate()=0;
  81. virtual void deactivate()=0;
  82. };
  83. class CGameInterface
  84. {
  85. public:
  86. bool human;
  87. int playerID, serialID;
  88. virtual void yourTurn()=0{};
  89. virtual void heroKilled(const CHeroInstance * hero)=0{};
  90. virtual void heroCreated(const CHeroInstance * hero)=0{};
  91. virtual void heroMoved(const HeroMoveDetails & details)=0;
  92. };
  93. class CGlobalAI : public CGameInterface // AI class (to derivate)
  94. {
  95. public:
  96. virtual void yourTurn(){};
  97. virtual void heroKilled(const CHeroInstance * hero){};
  98. virtual void heroCreated(const CHeroInstance * hero){};
  99. };
  100. class CPlayerInterface : public CGameInterface
  101. {
  102. public:
  103. SDL_Event * current;
  104. CAdvMapInt * adventureInt;
  105. FPSmanager * mainFPSmng;
  106. //TODO: town interace, battle interface, other interfaces
  107. CCallback * cb;
  108. std::vector<ClickableL*> lclickable;
  109. std::vector<ClickableR*> rclickable;
  110. std::vector<Hoverable*> hoverable;
  111. std::vector<KeyInterested*> keyinterested;
  112. std::vector<MotionInterested*> motioninterested;
  113. std::vector<CSimpleWindow*> objsToBlit;
  114. SDL_Surface * hInfo;
  115. //overloaded funcs from Interface
  116. void yourTurn();
  117. void heroMoved(const HeroMoveDetails & details);
  118. void heroKilled(const CHeroInstance * hero);
  119. void heroCreated(const CHeroInstance * hero);
  120. 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*
  121. void handleEvent(SDL_Event * sEvent);
  122. void init(CCallback * CB);
  123. int3 repairScreenPos(int3 pos);
  124. CPlayerInterface(int Player, int serial);
  125. };
  126. #endif //CGAMEINTERFACE_H