CAdvmapInterface.h 5.2 KB

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