CAdvmapInterface.h 5.3 KB

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