CAdvmapInterface.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #ifndef CADVENTUREMAPINTERFACE_H
  2. #define CADVENTUREMAPINTERFACE_H
  3. #include <typeinfo>
  4. #include "SDL.h"
  5. #include "hch\CDefHandler.h"
  6. #include "SDL_Extensions.h"
  7. #include "CGameInterface.h"
  8. #include "CGameInfo.h"
  9. #include "SDL_Extensions.h"
  10. #include <boost/logic/tribool.hpp>
  11. #include "global.h"
  12. #include "CPathfinder.h"
  13. #include "mapHandler.h"
  14. class CCallback;
  15. class AdventureMapButton
  16. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase
  17. {
  18. public:
  19. std::string name; //for status bar
  20. std::string helpBox; //for right-click help
  21. char key; //key shortcut
  22. void (CAdvMapInt::*function)(); //function in CAdvMapInt called when this button is pressed, different for each button
  23. void clickRight (tribool down);
  24. void clickLeft (tribool down);
  25. void hover (bool on);
  26. void keyPressed (SDL_KeyboardEvent & key);
  27. void activate(); // makes button active
  28. void deactivate(); // makes button inactive (but don't deletes)
  29. AdventureMapButton(); //c-tor
  30. AdventureMapButton( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ=false, std::vector<std::string> * add = NULL );//c-tor
  31. };
  32. /*****************************/
  33. class CList
  34. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
  35. {
  36. public:
  37. SDL_Surface * bg;
  38. CDefHandler *arrup, *arrdo;
  39. SDL_Surface *empty, *selection;
  40. SDL_Rect arrupp, arrdop; //positions of arrows
  41. int posw, posh; //position width/height
  42. int selected, //id of selected position, <0 if none
  43. from;
  44. tribool pressed; //true=up; false=down; indeterminate=none
  45. void clickLeft(tribool down);
  46. void activate();
  47. void deactivate();
  48. virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
  49. virtual void genList()=0;
  50. virtual void select(int which)=0;
  51. virtual void draw()=0;
  52. };
  53. class CHeroList
  54. : public CList
  55. {
  56. public:
  57. CDefHandler *mobile, *mana;
  58. std::vector<const CHeroInstance*> items;
  59. int posmobx, posporx, posmanx, posmoby, pospory, posmany;
  60. CHeroList();
  61. void genList();
  62. void select(int which);
  63. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  64. void clickLeft(tribool down);
  65. void clickRight(tribool down);
  66. void hover (bool on);
  67. void keyPressed (SDL_KeyboardEvent & key);
  68. void updateHList();
  69. void redrawAllOne(int which);
  70. void draw();
  71. void init();
  72. };
  73. class CTownList
  74. : public CList
  75. {
  76. public:
  77. CTownList();
  78. void genList();
  79. void select(int which);
  80. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  81. void clickLeft(tribool down);
  82. void clickRight(tribool down);
  83. void hover (bool on);
  84. void keyPressed (SDL_KeyboardEvent & key);
  85. void draw();
  86. };
  87. class CResourceBar
  88. :public ClickableR, public CIntObject
  89. {
  90. SDL_Surface * bg;
  91. void clickRight(tribool down);
  92. void refresh();
  93. };
  94. class CDataBar
  95. :public ClickableR, public CIntObject
  96. {
  97. SDL_Surface * bg;
  98. void clickRight(tribool down);
  99. void refresh();
  100. };
  101. class CStatusBar
  102. : public CIntObject
  103. {
  104. public:
  105. SDL_Surface * bg; //background
  106. int middlex, middley; //middle of statusbar
  107. std::string current; //text currently printed
  108. CStatusBar(int x, int y); //c-tor
  109. ~CStatusBar(); //d-tor
  110. void print(std::string text); //prints text and refreshes statusbar
  111. void clear();//clears statusbar and refreshes
  112. void show(); //shows statusbar (with current text)
  113. };
  114. class CMinimap
  115. : public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
  116. {
  117. public:
  118. CDefHandler * radar; //radar.def; TODO: radars for maps with custom dimensions
  119. std::map<int,SDL_Color> colors;
  120. std::map<int,SDL_Color> colorsBlocked;
  121. std::vector<SDL_Surface *> map; //one bitmap for each level
  122. //TODO flagged buildings
  123. std::string statusbarTxt;
  124. CMinimap(bool draw=true);
  125. void draw();
  126. void redraw(int level=-1);// (level==-1) => redraw all levels
  127. void updateRadar();
  128. void clickRight (tribool down);
  129. void clickLeft (tribool down);
  130. void hover (bool on);
  131. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  132. void activate(); // makes button active
  133. void deactivate(); // makes button inactive (but don't deletes)
  134. };
  135. class CTerrainRect
  136. : public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested
  137. {
  138. public:
  139. int tilesw, tilesh;
  140. CDefHandler * arrows;
  141. CTerrainRect();
  142. CPath * currentPath;
  143. void activate();
  144. void deactivate();
  145. void clickLeft(tribool down);
  146. void clickRight(tribool down);
  147. void hover(bool on);
  148. void keyPressed (SDL_KeyboardEvent & key);
  149. void show();
  150. };
  151. /*****************************/
  152. class CAdvMapInt //adventure map interface
  153. {
  154. public:
  155. CAdvMapInt(int Player);
  156. ~CAdvMapInt();
  157. int3 position; //top left corner of visible map part
  158. int player;
  159. std::vector<CDefHandler *> gems;
  160. bool scrollingLeft ;
  161. bool scrollingRight ;
  162. bool scrollingUp ;
  163. bool scrollingDown ;
  164. bool updateScreen ;
  165. unsigned char anim, animValHitCount; //animation frame
  166. CMinimap minimap;
  167. SDL_Surface * bg;
  168. AdventureMapButton kingOverview,//- kingdom overview
  169. underground,//- underground switch
  170. questlog,//- questlog
  171. sleepWake, //- sleep/wake hero
  172. moveHero, //- move hero
  173. spellbook,//- spellbook
  174. advOptions, //- adventure options
  175. sysOptions,//- system options
  176. nextHero, //- next hero
  177. endTurn;//- end turn
  178. //CHeroList herolist;
  179. CTerrainRect terrain; //visible terrain
  180. CStatusBar statusbar;
  181. CHeroList heroList;
  182. CTownList townList;
  183. //fuctions binded to buttons
  184. void fshowOverview();
  185. void fswitchLevel();
  186. void fshowQuestlog();
  187. void fsleepWake();
  188. void fmoveHero();
  189. void fshowSpellbok();
  190. void fadventureOPtions();
  191. void fsystemOptions();
  192. void fnextHero();
  193. void fendTurn();
  194. void show(); //shows and activates adv. map interface
  195. void update(); //redraws terrain
  196. void centerOn(int3 on);
  197. struct CurrentSelection
  198. {
  199. const type_info* type;
  200. const void* selected;
  201. CurrentSelection(); //ctor
  202. } selection;
  203. };
  204. #endif //CADVENTUREMAPINTERFACE_H