CAdvmapInterface.h 6.5 KB

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