CAdvmapInterface.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #ifndef __CADVMAPINTERFACE_H__
  2. #define __CADVMAPINTERFACE_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, flObjs; //one bitmap for each level (terrain, Fog of War, flaggable objects)
  26. std::string statusbarTxt, rcText;
  27. CMinimap(bool draw=true);
  28. ~CMinimap();
  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(const int3 &pos); //puts FoW
  39. void showTile(const int3 &pos); //removes FoW
  40. };
  41. class CTerrainRect
  42. : public ClickableL, public ClickableR, public Hoverable, public MotionInterested
  43. {
  44. public:
  45. int tilesw, tilesh; //width and height of terrain to blit in tiles
  46. int3 curHoveredTile;
  47. int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
  48. CDefHandler * arrows;
  49. CTerrainRect();
  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 show();
  59. void showPath(const SDL_Rect * extRect);
  60. int3 whichTileIsIt(const int & x, const 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(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
  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, public KeyInterested //adventure map interface
  97. {
  98. void hide(); //deactivates advmap interface
  99. public:
  100. CAdvMapInt(int Player);
  101. ~CAdvMapInt();
  102. int3 position; //top left corner of visible map part
  103. int player, active;
  104. std::vector<CDefHandler *> gems;
  105. enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
  106. ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
  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 townList;
  128. CInfoBar infoBar;
  129. CHeroWindow * heroWindow;
  130. const CArmedInstance *selection;
  131. //fuctions binded to buttons
  132. void fshowOverview();
  133. void fswitchLevel();
  134. void fshowQuestlog();
  135. void fsleepWake();
  136. void fmoveHero();
  137. void fshowSpellbok();
  138. void fadventureOPtions();
  139. void fsystemOptions();
  140. void fnextHero();
  141. void fendTurn();
  142. void activate();
  143. void deactivate();
  144. void show(SDL_Surface * to=NULL); //shows and activates adv. map interface
  145. void update(); //redraws terrain
  146. void select(const CArmedInstance *sel);
  147. void selectionChanged();
  148. void centerOn(int3 on);
  149. int3 verifyPos(int3 ver);
  150. void handleRightClick(std::string text, tribool down, CIntObject * client);
  151. void keyPressed(const SDL_KeyboardEvent & key);
  152. };
  153. #endif // __CADVMAPINTERFACE_H__