CAdvmapInterface.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #ifndef CADVENTUREMAPINTERFACE_H
  2. #define CADVENTUREMAPINTERFACE_H
  3. #include <typeinfo>
  4. #include "global.h"
  5. #include "SDL.h"
  6. #include "CPlayerInterface.h"
  7. #include <map>
  8. class CDefHandler;
  9. class CCallback;
  10. class CTownInstance;
  11. class CPath;
  12. class CAdvMapInt;
  13. class CGHeroInstance;
  14. class CGTownInstance;
  15. class CHeroWindow;
  16. template <typename T=CAdvMapInt>
  17. class AdventureMapButton
  18. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase
  19. {
  20. public:
  21. std::string name; //for status bar
  22. std::string helpBox; //for right-click help
  23. char key; //key shortcut
  24. T* owner;
  25. void (T::*function)(); //function in CAdvMapInt called when this button is pressed, different for each button
  26. void clickRight (tribool down);
  27. void clickLeft (tribool down);
  28. void hover (bool on);
  29. void keyPressed (SDL_KeyboardEvent & key);
  30. void activate(); // makes button active
  31. void deactivate(); // makes button inactive (but doesn't delete)
  32. AdventureMapButton(); //c-tor
  33. AdventureMapButton( std::string Name, std::string HelpBox, void(T::*Function)(), int x, int y, std::string defName, T* Owner, bool activ=false, std::vector<std::string> * add = NULL );//c-tor
  34. };
  35. /*****************************/
  36. class CMinimap
  37. : public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
  38. {
  39. public:
  40. SDL_Surface * radar;
  41. SDL_Surface * temps;
  42. std::map<int,SDL_Color> colors;
  43. std::map<int,SDL_Color> colorsBlocked;
  44. std::vector<SDL_Surface *> map, FoW; //one bitmap for each level (terrain, Fog of War)
  45. //TODO flagged buildings
  46. std::string statusbarTxt, rcText;
  47. CMinimap(bool draw=true);
  48. void draw();
  49. void redraw(int level=-1);// (level==-1) => redraw all levels
  50. void updateRadar();
  51. void clickRight (tribool down);
  52. void clickLeft (tribool down);
  53. void hover (bool on);
  54. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  55. void activate(); // makes button active
  56. void deactivate(); // makes button inactive (but don't deletes)
  57. void hideTile(int3 pos); //puts FoW
  58. void showTile(int3 pos); //removes FoW
  59. };
  60. class CTerrainRect
  61. : public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested,
  62. public MotionInterested
  63. {
  64. public:
  65. int tilesw, tilesh;
  66. int3 curHoveredTile;
  67. CDefHandler * arrows;
  68. CTerrainRect();
  69. CPath * currentPath;
  70. void activate();
  71. void deactivate();
  72. void clickLeft(tribool down);
  73. void clickRight(tribool down);
  74. void hover(bool on);
  75. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  76. void keyPressed (SDL_KeyboardEvent & key);
  77. void show();
  78. void showPath();
  79. int3 whichTileIsIt(int x, int y); //x,y are cursor position
  80. int3 whichTileIsIt(); //uses current cursor pos
  81. };
  82. class CResDataBar
  83. :public ClickableR, public virtual CIntObject
  84. {
  85. public:
  86. SDL_Surface * bg;
  87. std::vector<std::pair<int,int> > txtpos;
  88. std::string datetext;
  89. void clickRight (tribool down);
  90. void activate();
  91. void deactivate();
  92. CResDataBar();
  93. ~CResDataBar();
  94. void draw();
  95. };
  96. class CInfoBar
  97. :public virtual CIntObject, public TimeInterested
  98. {
  99. public:
  100. CDefHandler *day, *week1, *week2, *week3, *week4;
  101. SComponent * current;
  102. int mode;
  103. int pom;
  104. CInfoBar();
  105. ~CInfoBar();
  106. void newDay(int Day);
  107. void showComp(SComponent * comp, int time=5000);
  108. void tick();
  109. void draw(const CGObjectInstance * specific=NULL); // if specific==0 function draws info about selected hero/town
  110. void blitAnim(int mode);//0 - day, 1 - week
  111. CDefHandler * getAnim(int mode);
  112. };
  113. /*****************************/
  114. class CAdvMapInt : public IActivable //adventure map interface
  115. {
  116. public:
  117. CAdvMapInt(int Player);
  118. ~CAdvMapInt();
  119. int3 position; //top left corner of visible map part
  120. int player;
  121. std::vector<CDefHandler *> gems;
  122. bool scrollingLeft ;
  123. bool scrollingRight ;
  124. bool scrollingUp ;
  125. bool scrollingDown ;
  126. bool updateScreen, updateMinimap ;
  127. unsigned char anim, animValHitCount; //animation frame
  128. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  129. CMinimap minimap;
  130. SDL_Surface * bg;
  131. AdventureMapButton<> kingOverview,//- kingdom overview
  132. underground,//- underground switch
  133. questlog,//- questlog
  134. sleepWake, //- sleep/wake hero
  135. moveHero, //- move hero
  136. spellbook,//- spellbook
  137. advOptions, //- adventure options
  138. sysOptions,//- system options
  139. nextHero, //- next hero
  140. endTurn;//- end turn
  141. //CHeroList herolist;
  142. CTerrainRect terrain; //visible terrain
  143. CStatusBar statusbar;
  144. CResDataBar resdatabar;
  145. CHeroList heroList;
  146. CTownList<CAdvMapInt> townList;
  147. CInfoBar infoBar;
  148. CHeroWindow * heroWindow;
  149. struct CurrentSelection
  150. {
  151. int type; //0 - hero, 1 - town
  152. const void* selected;
  153. CurrentSelection(); //ctor
  154. } selection;
  155. //fuctions binded to buttons
  156. void fshowOverview();
  157. void fswitchLevel();
  158. void fshowQuestlog();
  159. void fsleepWake();
  160. void fmoveHero();
  161. void fshowSpellbok();
  162. void fadventureOPtions();
  163. void fsystemOptions();
  164. void fnextHero();
  165. void fendTurn();
  166. void activate();
  167. void deactivate();
  168. void show(); //shows and activates adv. map interface
  169. void hide(); //deactivates advmap interface
  170. void update(); //redraws terrain
  171. void selectionChanged();
  172. void centerOn(int3 on);
  173. int3 verifyPos(int3 ver);
  174. void handleRightClick(std::string text, tribool down, CIntObject * client);
  175. };
  176. #endif //CADVENTUREMAPINTERFACE_H