CGameInterface.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 init(CCallback * CB)=0{};
  90. virtual void yourTurn()=0{};
  91. virtual void heroKilled(const CHeroInstance * hero)=0{};
  92. virtual void heroCreated(const CHeroInstance * hero)=0{};
  93. virtual void heroMoved(const HeroMoveDetails & details)=0;
  94. };
  95. class CGlobalAI;
  96. class CAIHandler
  97. {
  98. public:
  99. static CGlobalAI * getNewAI(CCallback * cb, std::string dllname);
  100. };
  101. class CGlobalAI : public CGameInterface // AI class (to derivate)
  102. {
  103. public:
  104. //CGlobalAI();
  105. virtual void yourTurn(){};
  106. virtual void heroKilled(const CHeroInstance * hero){};
  107. virtual void heroCreated(const CHeroInstance * hero){};
  108. };
  109. class CPlayerInterface : public CGameInterface
  110. {
  111. public:
  112. bool makingTurn;
  113. SDL_Event * current;
  114. CAdvMapInt * adventureInt;
  115. FPSmanager * mainFPSmng;
  116. //TODO: town interace, battle interface, other interfaces
  117. CCallback * cb;
  118. std::vector<ClickableL*> lclickable;
  119. std::vector<ClickableR*> rclickable;
  120. std::vector<Hoverable*> hoverable;
  121. std::vector<KeyInterested*> keyinterested;
  122. std::vector<MotionInterested*> motioninterested;
  123. std::vector<CSimpleWindow*> objsToBlit;
  124. SDL_Surface * hInfo;
  125. std::vector<std::pair<int, int> > slotsPos;
  126. CDefEssential *luck22, *luck30, *luck42, *luck82,
  127. *morale22, *morale30, *morale42, *morale82;
  128. //overloaded funcs from Interface
  129. void yourTurn();
  130. void heroMoved(const HeroMoveDetails & details);
  131. void heroKilled(const CHeroInstance * hero);
  132. void heroCreated(const CHeroInstance * hero);
  133. 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*
  134. void handleEvent(SDL_Event * sEvent);
  135. void init(CCallback * CB);
  136. int3 repairScreenPos(int3 pos);
  137. CPlayerInterface(int Player, int serial);
  138. };
  139. #endif //CGAMEINTERFACE_H