CGameInterface.h 3.6 KB

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