CAdvmapInterface.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #ifndef __CADVMAPINTERFACE_H__
  2. #define __CADVMAPINTERFACE_H__
  3. #include <typeinfo>
  4. #include "../global.h"
  5. #include "SDL.h"
  6. #include <map>
  7. #include "AdventureMapButton.h"
  8. #include "GUIClasses.h"
  9. class CDefHandler;
  10. class CCallback;
  11. struct CGPath;
  12. class CAdvMapInt;
  13. class CGHeroInstance;
  14. class CGTownInstance;
  15. class CHeroWindow;
  16. /*****************************/
  17. /*
  18. * CAdcmapInterface.h, part of VCMI engine
  19. *
  20. * Authors: listed in file AUTHORS in main folder
  21. *
  22. * License: GNU General Public License v2.0 or later
  23. * Full text of license available in license.txt file, in main folder
  24. *
  25. */
  26. class CAdventureOptions : public CIntObject
  27. {
  28. public:
  29. CPicture *bg;
  30. AdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
  31. CAdventureOptions();
  32. ~CAdventureOptions();
  33. static void showScenarioInfo();
  34. static void showPuzzleMap();
  35. };
  36. class CMinimap : public 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, flObjs; //one bitmap for each level (terrain, Fog of War, flaggable objects)
  44. std::string statusbarTxt, rcText;
  45. CMinimap(bool draw=true);
  46. ~CMinimap();
  47. void show(SDL_Surface * to);
  48. void draw(SDL_Surface * to);
  49. void redraw(int level=-1);// (level==-1) => redraw all levels
  50. void initMap(int level=-1);// (level==-1) => redraw all levels
  51. void initFoW(int level=-1);// (level==-1) => redraw all levels
  52. void initFlaggableObjs(int level=-1);// (level==-1) => redraw all levels
  53. void updateRadar();
  54. void clickRight(tribool down, bool previousState);
  55. void clickLeft(tribool down, bool previousState);
  56. void hover (bool on);
  57. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  58. void activate(); // makes button active
  59. void deactivate(); // makes button inactive (but don't deletes)
  60. void hideTile(const int3 &pos); //puts FoW
  61. void showTile(const int3 &pos); //removes FoW
  62. void showVisibleTiles(int level=-1);// (level==-1) => redraw all levels
  63. };
  64. class CTerrainRect
  65. : public CIntObject
  66. {
  67. public:
  68. int tilesw, tilesh; //width and height of terrain to blit in tiles
  69. int3 curHoveredTile;
  70. int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
  71. CDefHandler * arrows;
  72. CTerrainRect();
  73. ~CTerrainRect();
  74. CGPath * currentPath;
  75. void activate();
  76. void deactivate();
  77. void clickLeft(tribool down, bool previousState);
  78. void clickRight(tribool down, bool previousState);
  79. void hover(bool on);
  80. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  81. void show(SDL_Surface * to);
  82. void showPath(const SDL_Rect * extRect, SDL_Surface * to);
  83. int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position
  84. int3 whichTileIsIt(); //uses current cursor pos
  85. };
  86. class CResDataBar
  87. : public CIntObject
  88. {
  89. public:
  90. SDL_Surface * bg;
  91. std::vector<std::pair<int,int> > txtpos;
  92. std::string datetext;
  93. void clickRight(tribool down, bool previousState);
  94. void activate();
  95. void deactivate();
  96. CResDataBar();
  97. CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
  98. ~CResDataBar();
  99. void draw(SDL_Surface * to);
  100. void show(SDL_Surface * to);
  101. };
  102. class CInfoBar : public CIntObject
  103. {
  104. public:
  105. CDefHandler *day, *week1, *week2, *week3, *week4;
  106. SComponent * current;
  107. int mode;
  108. int pom;
  109. CInfoBar();
  110. ~CInfoBar();
  111. void newDay(int Day); //start showing new day/week animation
  112. void showComp(SComponent * comp, int time=5000);
  113. void tick();
  114. void draw(SDL_Surface * to, const CGObjectInstance * specific=NULL); // if specific==0 function draws info about selected hero/town
  115. void blitAnim(int mode);//0 - day, 1 - week
  116. CDefHandler * getAnim(int mode);
  117. void show(SDL_Surface * to);
  118. void activate();
  119. void deactivate();
  120. };
  121. /*****************************/
  122. class CAdvMapInt : public CIntObject //adventure map interface
  123. {
  124. public:
  125. CAdvMapInt(int Player);
  126. ~CAdvMapInt();
  127. int3 position; //top left corner of visible map part
  128. int player;
  129. enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
  130. ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
  131. bool updateScreen, updateMinimap ;
  132. unsigned char anim, animValHitCount; //animation frame
  133. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  134. SDL_Surface * bg;
  135. std::vector<CDefHandler *> gems;
  136. CMinimap minimap;
  137. CStatusBar statusbar;
  138. AdventureMapButton kingOverview,//- kingdom overview
  139. underground,//- underground switch
  140. questlog,//- questlog
  141. sleepWake, //- sleep/wake hero
  142. moveHero, //- move hero
  143. spellbook,//- spellbook
  144. advOptions, //- adventure options
  145. sysOptions,//- system options
  146. nextHero, //- next hero
  147. endTurn;//- end turn
  148. CTerrainRect terrain; //visible terrain
  149. CResDataBar resdatabar;
  150. CHeroList heroList;
  151. CTownList townList;
  152. CInfoBar infoBar;
  153. CHeroWindow * heroWindow;
  154. const CArmedInstance *selection; //currently selected town/hero
  155. std::map<const CGHeroInstance *, CGPath> paths; //maps hero => selected path in adventure map
  156. //functions bound to buttons
  157. void fshowOverview();
  158. void fswitchLevel();
  159. void fshowQuestlog();
  160. void fsleepWake();
  161. void fmoveHero();
  162. void fshowSpellbok();
  163. void fadventureOPtions();
  164. void fsystemOptions();
  165. void fnextHero();
  166. void fendTurn();
  167. void activate();
  168. void deactivate();
  169. void show(SDL_Surface * to); //redraws terrain
  170. void showAll(SDL_Surface * to); //shows and activates adv. map interface
  171. void select(const CArmedInstance *sel);
  172. void selectionChanged();
  173. void centerOn(int3 on);
  174. int3 verifyPos(int3 ver);
  175. void handleRightClick(std::string text, tribool down, CIntObject * client);
  176. void keyPressed(const SDL_KeyboardEvent & key);
  177. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  178. bool isActive();
  179. };
  180. #endif // __CADVMAPINTERFACE_H__