CAdvmapInterface.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 * 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. SDL_Surface *selInfoWin; //info box for selection
  110. CInfoBar();
  111. ~CInfoBar();
  112. void newDay(int Day); //start showing new day/week animation
  113. void showComp(SComponent * comp, int time=5000);
  114. void tick();
  115. void showAll(SDL_Surface * to); // if specific==0 function draws info about selected hero/town
  116. void blitAnim(int mode);//0 - day, 1 - week
  117. CDefHandler * getAnim(int mode);
  118. void show(SDL_Surface * to);
  119. void activate();
  120. void deactivate();
  121. void updateSelection(const CGObjectInstance *obj);
  122. };
  123. /*****************************/
  124. class CAdvMapInt : public CIntObject //adventure map interface
  125. {
  126. public:
  127. CAdvMapInt();
  128. ~CAdvMapInt();
  129. int3 position; //top left corner of visible map part
  130. int player;
  131. enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
  132. ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
  133. enum{NA, INGAME, WAITING} state;
  134. bool updateScreen, updateMinimap ;
  135. unsigned char anim, animValHitCount; //animation frame
  136. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  137. SDL_Surface * bg;
  138. std::vector<CDefHandler *> gems;
  139. CMinimap minimap;
  140. CStatusBar statusbar;
  141. AdventureMapButton kingOverview,//- kingdom overview
  142. underground,//- underground switch
  143. questlog,//- questlog
  144. sleepWake, //- sleep/wake hero
  145. moveHero, //- move hero
  146. spellbook,//- spellbook
  147. advOptions, //- adventure options
  148. sysOptions,//- system options
  149. nextHero, //- next hero
  150. endTurn;//- end turn
  151. CTerrainRect terrain; //visible terrain
  152. CResDataBar resdatabar;
  153. CHeroList heroList;
  154. CTownList townList;
  155. CInfoBar infoBar;
  156. const CSpell *spellBeingCasted; //NULL if none
  157. const CArmedInstance *selection; //currently selected town/hero
  158. //functions bound to buttons
  159. void fshowOverview();
  160. void fswitchLevel();
  161. void fshowQuestlog();
  162. void fsleepWake();
  163. void fmoveHero();
  164. void fshowSpellbok();
  165. void fadventureOPtions();
  166. void fsystemOptions();
  167. void fnextHero();
  168. void fendTurn();
  169. void activate();
  170. void deactivate();
  171. void show(SDL_Surface * to); //redraws terrain
  172. void showAll(SDL_Surface * to); //shows and activates adv. map interface
  173. void select(const CArmedInstance *sel, bool centerView = true);
  174. void selectionChanged();
  175. void centerOn(int3 on);
  176. void centerOn(const CGObjectInstance *obj);
  177. int3 verifyPos(int3 ver);
  178. void handleRightClick(std::string text, tribool down);
  179. void keyPressed(const SDL_KeyboardEvent & key);
  180. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  181. bool isActive();
  182. void setPlayer(int Player);
  183. void startHotSeatWait(int Player);
  184. void startTurn();
  185. void tileLClicked(const int3 &mp);
  186. void tileHovered(const int3 &tile);
  187. void tileRClicked(const int3 &mp);
  188. void enterCastingMode(const CSpell * sp);
  189. void leaveCastingMode(bool cast = false, int3 dest = int3(-1, -1, -1));
  190. const CGHeroInstance * curHero() const;
  191. const CGTownInstance * curTown() const;
  192. const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or NULL else
  193. };
  194. extern CAdvMapInt *adventureInt;
  195. #endif // __CADVMAPINTERFACE_H__