CAdvmapInterface.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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);
  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. };
  119. /*****************************/
  120. class CAdvMapInt : public CIntObject //adventure map interface
  121. {
  122. public:
  123. CAdvMapInt(int Player);
  124. ~CAdvMapInt();
  125. int3 position; //top left corner of visible map part
  126. int player, active;
  127. enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
  128. ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
  129. bool updateScreen, updateMinimap ;
  130. unsigned char anim, animValHitCount; //animation frame
  131. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  132. SDL_Surface * bg;
  133. std::vector<CDefHandler *> gems;
  134. CMinimap minimap;
  135. CStatusBar statusbar;
  136. AdventureMapButton kingOverview,//- kingdom overview
  137. underground,//- underground switch
  138. questlog,//- questlog
  139. sleepWake, //- sleep/wake hero
  140. moveHero, //- move hero
  141. spellbook,//- spellbook
  142. advOptions, //- adventure options
  143. sysOptions,//- system options
  144. nextHero, //- next hero
  145. endTurn;//- end turn
  146. CTerrainRect terrain; //visible terrain
  147. CResDataBar resdatabar;
  148. CHeroList heroList;
  149. CTownList townList;
  150. CInfoBar infoBar;
  151. CHeroWindow * heroWindow;
  152. const CArmedInstance *selection; //currently selected town/hero
  153. std::map<const CGHeroInstance *, CGPath> paths; //maps hero => selected path in adventure map
  154. //functions bound to buttons
  155. void fshowOverview();
  156. void fswitchLevel();
  157. void fshowQuestlog();
  158. void fsleepWake();
  159. void fmoveHero();
  160. void fshowSpellbok();
  161. void fadventureOPtions();
  162. void fsystemOptions();
  163. void fnextHero();
  164. void fendTurn();
  165. void activate();
  166. void deactivate();
  167. void show(SDL_Surface * to); //redraws terrain
  168. void showAll(SDL_Surface * to); //shows and activates adv. map interface
  169. void select(const CArmedInstance *sel);
  170. void selectionChanged();
  171. void centerOn(int3 on);
  172. int3 verifyPos(int3 ver);
  173. void handleRightClick(std::string text, tribool down, CIntObject * client);
  174. void keyPressed(const SDL_KeyboardEvent & key);
  175. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  176. };
  177. #endif // __CADVMAPINTERFACE_H__