CAdvmapInterface.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. class 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 (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;
  47. int3 curHoveredTile;
  48. CDefHandler * arrows;
  49. CTerrainRect();
  50. CPath * currentPath;
  51. void activate();
  52. void deactivate();
  53. void clickLeft(tribool down);
  54. void clickRight(tribool down);
  55. void hover(bool on);
  56. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  57. void keyPressed (SDL_KeyboardEvent & key);
  58. void show();
  59. void showPath();
  60. int3 whichTileIsIt(int x, int y); //x,y are cursor position
  61. int3 whichTileIsIt(); //uses current cursor pos
  62. };
  63. class CResDataBar
  64. :public ClickableR, public virtual CIntObject
  65. {
  66. public:
  67. SDL_Surface * bg;
  68. std::vector<std::pair<int,int> > txtpos;
  69. std::string datetext;
  70. void clickRight (tribool down);
  71. void activate();
  72. void deactivate();
  73. CResDataBar();
  74. ~CResDataBar();
  75. void draw();
  76. };
  77. class CInfoBar
  78. :public virtual CIntObject, public TimeInterested
  79. {
  80. public:
  81. CDefHandler *day, *week1, *week2, *week3, *week4;
  82. SComponent * current;
  83. int mode;
  84. int pom;
  85. CInfoBar();
  86. ~CInfoBar();
  87. void newDay(int Day);
  88. void showComp(SComponent * comp, int time=5000);
  89. void tick();
  90. void draw(const CGObjectInstance * specific=NULL); // if specific==0 function draws info about selected hero/town
  91. void blitAnim(int mode);//0 - day, 1 - week
  92. CDefHandler * getAnim(int mode);
  93. };
  94. /*****************************/
  95. class CAdvMapInt : public IActivable //adventure map interface
  96. {
  97. public:
  98. CAdvMapInt(int Player);
  99. ~CAdvMapInt();
  100. int3 position; //top left corner of visible map part
  101. int player;
  102. std::vector<CDefHandler *> gems;
  103. bool scrollingLeft ;
  104. bool scrollingRight ;
  105. bool scrollingUp ;
  106. bool scrollingDown ;
  107. bool updateScreen, updateMinimap ;
  108. unsigned char anim, animValHitCount; //animation frame
  109. unsigned char heroAnim, heroAnimValHitCount; //animation frame
  110. CMinimap minimap;
  111. SDL_Surface * bg;
  112. AdventureMapButton<> kingOverview,//- kingdom overview
  113. underground,//- underground switch
  114. questlog,//- questlog
  115. sleepWake, //- sleep/wake hero
  116. moveHero, //- move hero
  117. spellbook,//- spellbook
  118. advOptions, //- adventure options
  119. sysOptions,//- system options
  120. nextHero, //- next hero
  121. endTurn;//- end turn
  122. //CHeroList herolist;
  123. CTerrainRect terrain; //visible terrain
  124. CStatusBar statusbar;
  125. CResDataBar resdatabar;
  126. CHeroList heroList;
  127. CTownList<CAdvMapInt> townList;
  128. CInfoBar infoBar;
  129. CHeroWindow * heroWindow;
  130. struct CurrentSelection
  131. {
  132. int type; //0 - hero, 1 - town
  133. const void* selected;
  134. CurrentSelection(); //ctor
  135. } selection;
  136. //fuctions binded to buttons
  137. void fshowOverview();
  138. void fswitchLevel();
  139. void fshowQuestlog();
  140. void fsleepWake();
  141. void fmoveHero();
  142. void fshowSpellbok();
  143. void fadventureOPtions();
  144. void fsystemOptions();
  145. void fnextHero();
  146. void fendTurn();
  147. void activate();
  148. void deactivate();
  149. void show(); //shows and activates adv. map interface
  150. void hide(); //deactivates advmap interface
  151. void update(); //redraws terrain
  152. void selectionChanged();
  153. void centerOn(int3 on);
  154. int3 verifyPos(int3 ver);
  155. void handleRightClick(std::string text, tribool down, CIntObject * client);
  156. };
  157. #endif //CADVENTUREMAPINTERFACE_H