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