CAdvmapInterface.h 5.1 KB

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