CAdvmapInterface.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. class CSpell;
  17. class IShipyard;
  18. /*****************************/
  19. /*
  20. * CAdcmapInterface.h, part of VCMI engine
  21. *
  22. * Authors: listed in file AUTHORS in main folder
  23. *
  24. * License: GNU General Public License v2.0 or later
  25. * Full text of license available in license.txt file, in main folder
  26. *
  27. */
  28. /// Adventure options dialogue where you can view the world, dig, play the replay of the last turn,...
  29. class CAdventureOptions : public CIntObject
  30. {
  31. public:
  32. CPicture *bg;
  33. AdventureMapButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
  34. CAdventureOptions();
  35. ~CAdventureOptions();
  36. static void showScenarioInfo();
  37. };
  38. /// Minimap which is displayed at the right upper corner of adventure map
  39. class CMinimap : public CIntObject
  40. {
  41. public:
  42. SDL_Surface * temps;
  43. std::map<int,SDL_Color> colors;
  44. std::map<int,SDL_Color> colorsBlocked;
  45. std::vector<SDL_Surface *> map, FoW, flObjs; //one bitmap for each level (terrain, Fog of War, flaggable objects)
  46. std::string statusbarTxt, rcText;
  47. CMinimap(bool draw=true);
  48. ~CMinimap();
  49. void show(SDL_Surface * to);
  50. void draw(SDL_Surface * to);
  51. void redraw(int level=-1);// (level==-1) => redraw all levels
  52. void initMap(int level=-1);// (level==-1) => redraw all levels
  53. void initFoW(int level=-1);// (level==-1) => redraw all levels
  54. void initFlaggableObjs(int level=-1);// (level==-1) => redraw all levels
  55. void updateRadar();
  56. void clickRight(tribool down, bool previousState);
  57. void clickLeft(tribool down, bool previousState);
  58. void hover (bool on);
  59. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  60. void activate(); // makes button active
  61. void deactivate(); // makes button inactive (but don't deletes)
  62. void hideTile(const int3 &pos); //puts FoW
  63. void showTile(const int3 &pos); //removes FoW
  64. void showVisibleTiles(int level=-1);// (level==-1) => redraw all levels
  65. };
  66. /// Holds information about which tiles of the terrain are shown/not shown at the screen
  67. class CTerrainRect
  68. : public CIntObject
  69. {
  70. public:
  71. int tilesw, tilesh; //width and height of terrain to blit in tiles
  72. int3 curHoveredTile;
  73. int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
  74. CTerrainRect();
  75. ~CTerrainRect();
  76. CGPath * currentPath;
  77. void activate();
  78. void deactivate();
  79. void clickLeft(tribool down, bool previousState);
  80. void clickRight(tribool down, bool previousState);
  81. void hover(bool on);
  82. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  83. void show(SDL_Surface * to);
  84. void showPath(const SDL_Rect * extRect, SDL_Surface * to);
  85. int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position
  86. int3 whichTileIsIt(); //uses current cursor pos
  87. };
  88. /// Resources bar which shows information about how many gold, crystals,... you have
  89. /// Current date is displayed too
  90. class CResDataBar
  91. : public CIntObject
  92. {
  93. public:
  94. SDL_Surface * bg;
  95. std::vector<std::pair<int,int> > txtpos;
  96. std::string datetext;
  97. void clickRight(tribool down, bool previousState);
  98. void activate();
  99. void deactivate();
  100. CResDataBar();
  101. CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
  102. ~CResDataBar();
  103. void draw(SDL_Surface * to);
  104. void show(SDL_Surface * to);
  105. };
  106. /// Info box which shows next week/day information, hold the current date
  107. class CInfoBar : public CIntObject
  108. {
  109. CDefHandler *day, *week1, *week2, *week3, *week4;
  110. SComponent * current;
  111. int pom;
  112. SDL_Surface *selInfoWin; //info box for selection
  113. CDefHandler * getAnim(int mode);
  114. public:
  115. int mode;
  116. const CGHeroInstance * curSel;
  117. CInfoBar();
  118. ~CInfoBar();
  119. void newDay(int Day); //start showing new day/week animation
  120. void showComp(SComponent * comp, int time=5000);
  121. void tick();
  122. void showAll(SDL_Surface * to); // if specific==0 function draws info about selected hero/town
  123. void blitAnim(int mode);//0 - day, 1 - week
  124. void show(SDL_Surface * to);
  125. void activate();
  126. void deactivate();
  127. void updateSelection(const CGObjectInstance *obj);
  128. };
  129. /// That's a huge class which handles general adventure map actions and
  130. /// shows the right menu(questlog, spellbook, end turn,..) from where you
  131. /// can get to the towns and heroes.
  132. class CAdvMapInt : public CIntObject
  133. {
  134. public:
  135. CAdvMapInt();
  136. ~CAdvMapInt();
  137. int3 position; //top left corner of visible map part
  138. int player;
  139. enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
  140. ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
  141. enum{NA, INGAME, WAITING} state;
  142. bool updateScreen, updateMinimap ;
  143. unsigned char anim, animValHitCount; //animation frame
  144. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  145. SDL_Surface * bg;
  146. std::vector<CDefHandler *> gems;
  147. CMinimap minimap;
  148. CStatusBar statusbar;
  149. AdventureMapButton kingOverview,//- kingdom overview
  150. underground,//- underground switch
  151. questlog,//- questlog
  152. sleepWake, //- sleep/wake hero
  153. moveHero, //- move hero
  154. spellbook,//- spellbook
  155. advOptions, //- adventure options
  156. sysOptions,//- system options
  157. nextHero, //- next hero
  158. endTurn;//- end turn
  159. CTerrainRect terrain; //visible terrain
  160. CResDataBar resdatabar;
  161. CHeroList heroList;
  162. CTownList townList;
  163. CInfoBar infoBar;
  164. const CSpell *spellBeingCasted; //NULL if none
  165. const CArmedInstance *selection; //currently selected town/hero
  166. //functions bound to buttons
  167. void fshowOverview();
  168. void fswitchLevel();
  169. void fshowQuestlog();
  170. void fsleepWake();
  171. void fmoveHero();
  172. void fshowSpellbok();
  173. void fadventureOPtions();
  174. void fsystemOptions();
  175. void fnextHero();
  176. void fendTurn();
  177. void activate();
  178. void deactivate();
  179. void show(SDL_Surface * to); //redraws terrain
  180. void showAll(SDL_Surface * to); //shows and activates adv. map interface
  181. void select(const CArmedInstance *sel, bool centerView = true);
  182. void selectionChanged();
  183. void centerOn(int3 on);
  184. void centerOn(const CGObjectInstance *obj);
  185. int3 verifyPos(int3 ver);
  186. void handleRightClick(std::string text, tribool down);
  187. void keyPressed(const SDL_KeyboardEvent & key);
  188. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  189. bool isActive();
  190. void setPlayer(int Player);
  191. void startHotSeatWait(int Player);
  192. void startTurn();
  193. void tileLClicked(const int3 &mp);
  194. void tileHovered(const int3 &tile);
  195. void tileRClicked(const int3 &mp);
  196. void enterCastingMode(const CSpell * sp);
  197. void leaveCastingMode(bool cast = false, int3 dest = int3(-1, -1, -1));
  198. const CGHeroInstance * curHero() const;
  199. const CGTownInstance * curTown() const;
  200. const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or NULL else
  201. };
  202. extern CAdvMapInt *adventureInt;
  203. #endif // __CADVMAPINTERFACE_H__