CAdvmapInterface.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #pragma once
  2. #include "../widgets/AdventureMapClasses.h"
  3. #include "CWindowObject.h"
  4. #include "../widgets/TextControls.h"
  5. #include "../widgets/Buttons.h"
  6. class CDefHandler;
  7. class CCallback;
  8. struct CGPath;
  9. class CAdvMapInt;
  10. class CGHeroInstance;
  11. class CGTownInstance;
  12. class CHeroWindow;
  13. class CSpell;
  14. class IShipyard;
  15. /*****************************/
  16. /*
  17. * CAdvmapInterface.h, part of VCMI engine
  18. *
  19. * Authors: listed in file AUTHORS in main folder
  20. *
  21. * License: GNU General Public License v2.0 or later
  22. * Full text of license available in license.txt file, in main folder
  23. *
  24. */
  25. /// Adventure options dialogue where you can view the world, dig, play the replay of the last turn,...
  26. class CAdventureOptions : public CWindowObject
  27. {
  28. public:
  29. CButton *exit, *viewWorld, *puzzle, *dig, *scenInfo, *replay;
  30. CAdventureOptions();
  31. static void showScenarioInfo();
  32. };
  33. /// Holds information about which tiles of the terrain are shown/not shown at the screen
  34. class CTerrainRect
  35. : public CIntObject
  36. {
  37. public:
  38. int tilesw, tilesh; //width and height of terrain to blit in tiles
  39. int3 curHoveredTile;
  40. int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
  41. CTerrainRect();
  42. CGPath * currentPath;
  43. void deactivate();
  44. void clickLeft(tribool down, bool previousState);
  45. void clickRight(tribool down, bool previousState);
  46. void hover(bool on);
  47. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  48. void show(SDL_Surface * to);
  49. void showPath(const SDL_Rect * extRect, SDL_Surface * to);
  50. int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position
  51. int3 whichTileIsIt(); //uses current cursor pos
  52. };
  53. /// Resources bar which shows information about how many gold, crystals,... you have
  54. /// Current date is displayed too
  55. class CResDataBar : public CIntObject
  56. {
  57. public:
  58. SDL_Surface * bg;
  59. std::vector<std::pair<int,int> > txtpos;
  60. std::string datetext;
  61. void clickRight(tribool down, bool previousState);
  62. CResDataBar();
  63. CResDataBar(const std::string &defname, int x, int y, int offx, int offy, int resdist, int datedist);
  64. ~CResDataBar();
  65. void draw(SDL_Surface * to);
  66. void show(SDL_Surface * to);
  67. void showAll(SDL_Surface * to);
  68. };
  69. /// That's a huge class which handles general adventure map actions and
  70. /// shows the right menu(questlog, spellbook, end turn,..) from where you
  71. /// can get to the towns and heroes.
  72. class CAdvMapInt : public CIntObject
  73. {
  74. //Return object that must be active at this tile (=clickable)
  75. const CGObjectInstance *getActiveObject(const int3 &tile);
  76. public:
  77. CAdvMapInt();
  78. ~CAdvMapInt();
  79. int3 position; //top left corner of visible map part
  80. PlayerColor player;
  81. bool duringAITurn;
  82. enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
  83. ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
  84. enum{NA, INGAME, WAITING} state;
  85. bool updateScreen;
  86. ui8 anim, animValHitCount; //animation frame
  87. ui8 heroAnim, heroAnimValHitCount; //animation frame
  88. SDL_Surface * bg;
  89. std::vector<CDefHandler *> gems;
  90. CMinimap minimap;
  91. CGStatusBar statusbar;
  92. CButton * kingOverview;
  93. CButton * underground;
  94. CButton * questlog;
  95. CButton * sleepWake;
  96. CButton * moveHero;
  97. CButton * spellbook;
  98. CButton * advOptions;
  99. CButton * sysOptions;
  100. CButton * nextHero;
  101. CButton * endTurn;
  102. CTerrainRect terrain; //visible terrain
  103. CResDataBar resdatabar;
  104. CHeroList heroList;
  105. CTownList townList;
  106. CInfoBar infoBar;
  107. const CSpell *spellBeingCasted; //nullptr if none
  108. const CArmedInstance *selection; //currently selected town/hero
  109. //functions bound to buttons
  110. void fshowOverview();
  111. void fswitchLevel();
  112. void fshowQuestlog();
  113. void fsleepWake();
  114. void fmoveHero();
  115. void fshowSpellbok();
  116. void fadventureOPtions();
  117. void fsystemOptions();
  118. void fnextHero();
  119. void fendTurn();
  120. void activate();
  121. void deactivate();
  122. void show(SDL_Surface * to); //redraws terrain
  123. void showAll(SDL_Surface * to); //shows and activates adv. map interface
  124. void select(const CArmedInstance *sel, bool centerView = true);
  125. void selectionChanged();
  126. void centerOn(int3 on);
  127. void centerOn(const CGObjectInstance *obj);
  128. int3 verifyPos(int3 ver);
  129. void handleRightClick(std::string text, tribool down);
  130. void keyPressed(const SDL_KeyboardEvent & key);
  131. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  132. bool isActive();
  133. bool isHeroSleeping(const CGHeroInstance *hero);
  134. void setHeroSleeping(const CGHeroInstance *hero, bool sleep);
  135. int getNextHeroIndex(int startIndex); //for Next Hero button - cycles awake heroes with movement only
  136. void setPlayer(PlayerColor Player);
  137. void startHotSeatWait(PlayerColor Player);
  138. void startTurn();
  139. void endingTurn();
  140. void aiTurnStarted();
  141. void adjustActiveness(bool aiTurnStart); //should be called every time at AI/human turn transition; blocks GUI during AI turn
  142. void tileLClicked(const int3 &mapPos);
  143. void tileHovered(const int3 &mapPos);
  144. void tileRClicked(const int3 &mapPos);
  145. void enterCastingMode(const CSpell * sp);
  146. void leaveCastingMode(bool cast = false, int3 dest = int3(-1, -1, -1));
  147. const CGHeroInstance * curHero() const;
  148. const CGTownInstance * curTown() const;
  149. const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or nullptr else
  150. //button updates
  151. void updateSleepWake(const CGHeroInstance *h);
  152. void updateMoveHero(const CGHeroInstance *h, tribool hasPath = boost::logic::indeterminate);
  153. void updateNextHero(const CGHeroInstance *h);
  154. };
  155. extern CAdvMapInt *adventureInt;