CAdvmapInterface.h 5.6 KB

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