CAdvmapInterface.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifndef CADVENTUREMAPINTERFACE_H
  2. #define CADVENTUREMAPINTERFACE_H
  3. #include <typeinfo>
  4. #include "global.h"
  5. #include "SDL.h"
  6. #include "CPlayerInterface.h"
  7. #include <map>
  8. #include "AdventureMapButton.h"
  9. class CDefHandler;
  10. class CCallback;
  11. struct CPath;
  12. class CAdvMapInt;
  13. class CGHeroInstance;
  14. class CGTownInstance;
  15. class CHeroWindow;
  16. /*****************************/
  17. class CMinimap
  18. : public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
  19. {
  20. public:
  21. SDL_Surface * radar;
  22. SDL_Surface * temps;
  23. std::map<int,SDL_Color> colors;
  24. std::map<int,SDL_Color> colorsBlocked;
  25. std::vector<SDL_Surface *> map, FoW; //one bitmap for each level (terrain, Fog of War)
  26. //TODO flagged buildings
  27. std::string statusbarTxt, rcText;
  28. CMinimap(bool draw=true);
  29. void draw();
  30. void redraw(int level=-1);// (level==-1) => redraw all levels
  31. void updateRadar();
  32. void clickRight (tribool down);
  33. void clickLeft (tribool down);
  34. void hover (bool on);
  35. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  36. void activate(); // makes button active
  37. void deactivate(); // makes button inactive (but don't deletes)
  38. void hideTile(int3 pos); //puts FoW
  39. void showTile(int3 pos); //removes FoW
  40. };
  41. class CTerrainRect
  42. : public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested,
  43. public MotionInterested
  44. {
  45. public:
  46. int tilesw, tilesh; //width and height of terrain to blit in tiles
  47. int3 curHoveredTile;
  48. int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
  49. CDefHandler * arrows;
  50. CTerrainRect();
  51. CPath * currentPath;
  52. void activate();
  53. void deactivate();
  54. void clickLeft(tribool down);
  55. void clickRight(tribool down);
  56. void hover(bool on);
  57. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  58. void keyPressed (const SDL_KeyboardEvent & key);
  59. void show();
  60. void showPath();
  61. int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position
  62. int3 whichTileIsIt(); //uses current cursor pos
  63. };
  64. class CResDataBar
  65. :public ClickableR, public virtual CIntObject
  66. {
  67. public:
  68. SDL_Surface * bg;
  69. std::vector<std::pair<int,int> > txtpos;
  70. std::string datetext;
  71. void clickRight (tribool down);
  72. void activate();
  73. void deactivate();
  74. CResDataBar();
  75. ~CResDataBar();
  76. void draw();
  77. };
  78. class CInfoBar
  79. :public virtual CIntObject, public TimeInterested
  80. {
  81. public:
  82. CDefHandler *day, *week1, *week2, *week3, *week4;
  83. SComponent * current;
  84. int mode;
  85. int pom;
  86. CInfoBar();
  87. ~CInfoBar();
  88. void newDay(int Day);
  89. void showComp(SComponent * comp, int time=5000);
  90. void tick();
  91. void draw(const CGObjectInstance * specific=NULL); // if specific==0 function draws info about selected hero/town
  92. void blitAnim(int mode);//0 - day, 1 - week
  93. CDefHandler * getAnim(int mode);
  94. };
  95. /*****************************/
  96. class CAdvMapInt : public CMainInterface //adventure map interface
  97. {
  98. public:
  99. CAdvMapInt(int Player);
  100. ~CAdvMapInt();
  101. int3 position; //top left corner of visible map part
  102. int player;
  103. std::vector<CDefHandler *> gems;
  104. bool scrollingLeft ;
  105. bool scrollingRight ;
  106. bool scrollingUp ;
  107. bool scrollingDown ;
  108. bool updateScreen, updateMinimap ;
  109. unsigned char anim, animValHitCount; //animation frame
  110. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  111. CMinimap minimap;
  112. SDL_Surface * bg;
  113. AdventureMapButton kingOverview,//- kingdom overview
  114. underground,//- underground switch
  115. questlog,//- questlog
  116. sleepWake, //- sleep/wake hero
  117. moveHero, //- move hero
  118. spellbook,//- spellbook
  119. advOptions, //- adventure options
  120. sysOptions,//- system options
  121. nextHero, //- next hero
  122. endTurn;//- end turn
  123. //CHeroList herolist;
  124. CTerrainRect terrain; //visible terrain
  125. CStatusBar statusbar;
  126. CResDataBar resdatabar;
  127. CHeroList heroList;
  128. CTownList townList;
  129. CInfoBar infoBar;
  130. CHeroWindow * heroWindow;
  131. const CArmedInstance *selection;
  132. //fuctions binded to buttons
  133. void fshowOverview();
  134. void fswitchLevel();
  135. void fshowQuestlog();
  136. void fsleepWake();
  137. void fmoveHero();
  138. void fshowSpellbok();
  139. void fadventureOPtions();
  140. void fsystemOptions();
  141. void fnextHero();
  142. void fendTurn();
  143. void activate();
  144. void deactivate();
  145. void show(SDL_Surface * to=NULL); //shows and activates adv. map interface
  146. void hide(); //deactivates advmap interface
  147. void update(); //redraws terrain
  148. void select(const CArmedInstance *sel);
  149. void selectionChanged();
  150. void centerOn(int3 on);
  151. int3 verifyPos(int3 ver);
  152. void handleRightClick(std::string text, tribool down, CIntObject * client);
  153. };
  154. #endif //CADVENTUREMAPINTERFACE_H