CGameInterface.h 3.8 KB

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