CAdvmapInterface.h 5.3 KB

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