CAdvmapInterface.h 5.2 KB

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