BattleWindow.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * BattleWindow.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../gui/CIntObject.h"
  12. #include "../gui/InterfaceObjectConfigurable.h"
  13. #include "../../lib/battle/CBattleInfoCallback.h"
  14. #include "../../lib/battle/PossiblePlayerBattleAction.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. class CStack;
  17. VCMI_LIB_NAMESPACE_END
  18. class CButton;
  19. class BattleInterface;
  20. class BattleConsole;
  21. class BattleRenderer;
  22. class StackQueue;
  23. class TurnTimerWidget;
  24. class HeroInfoBasicPanel;
  25. class StackInfoBasicPanel;
  26. class QuickSpellPanel;
  27. class UnitActionPanel;
  28. /// GUI object that handles functionality of panel at the bottom of combat screen
  29. class BattleWindow : public InterfaceObjectConfigurable
  30. {
  31. BattleInterface & owner;
  32. std::shared_ptr<StackQueue> queue;
  33. std::shared_ptr<BattleConsole> console;
  34. std::shared_ptr<HeroInfoBasicPanel> attackerHeroWindow;
  35. std::shared_ptr<HeroInfoBasicPanel> defenderHeroWindow;
  36. std::shared_ptr<StackInfoBasicPanel> attackerStackWindow;
  37. std::shared_ptr<StackInfoBasicPanel> defenderStackWindow;
  38. std::shared_ptr<QuickSpellPanel> quickSpellWindow;
  39. std::shared_ptr<UnitActionPanel> unitActionWindow;
  40. std::shared_ptr<TurnTimerWidget> attackerTimerWidget;
  41. std::shared_ptr<TurnTimerWidget> defenderTimerWidget;
  42. /// button press handling functions
  43. void bOptionsf();
  44. void bSurrenderf();
  45. void bFleef();
  46. void bAutofightf();
  47. void bSpellf();
  48. void bWaitf();
  49. void bDefencef();
  50. void bConsoleUpf();
  51. void bConsoleDownf();
  52. void bTacticNextStack();
  53. void bTacticPhaseEnd();
  54. void bOpenActiveUnit();
  55. void bOpenHoveredUnit();
  56. /// functions for handling actions after they were confirmed by popup window
  57. void reallyFlee();
  58. void reallySurrender();
  59. void useSpellIfPossible(int slot);
  60. /// flip battle queue visibility to opposite
  61. void toggleQueueVisibility();
  62. void createQueue();
  63. void toggleStickyHeroWindowsVisibility();
  64. void toggleStickyQuickSpellVisibility();
  65. void createStickyHeroInfoWindows();
  66. void createQuickSpellWindow();
  67. void createTimerInfoWindows();
  68. std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
  69. bool onlyOnePlayerHuman;
  70. bool hasSpaceForQuickActions() const;
  71. bool quickActionsPanelActive() const;
  72. bool placeInfoWindowsOutside() const;
  73. public:
  74. BattleWindow(BattleInterface & owner );
  75. /// Closes window once battle finished
  76. void close();
  77. /// Toggle StackQueue visibility
  78. void hideQueue();
  79. void showQueue();
  80. /// Toggle permanent hero info windows visibility (HD mod feature)
  81. void hideStickyHeroWindows();
  82. void showStickyHeroWindows();
  83. /// Toggle permanent quickspell windows visibility
  84. void hideStickyQuickSpellWindow();
  85. void showStickyQuickSpellWindow();
  86. /// Event handler for netpack changing hero mana points
  87. void heroManaPointsChanged(const CGHeroInstance * hero);
  88. /// block all UI elements when player is not allowed to act, e.g. during enemy turn
  89. void blockUI(bool on);
  90. /// Refresh queue after turn order changes
  91. void updateQueue();
  92. // Set positions for hero & stack info window
  93. void setPositionInfoWindow();
  94. /// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
  95. void updateHeroInfoWindow(uint8_t side, const InfoAboutHero & hero);
  96. /// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
  97. void updateStackInfoWindow(const CStack * stack);
  98. /// Get mouse-hovered battle queue unit ID if any found
  99. std::optional<uint32_t> getQueueHoveredUnitId();
  100. void activate() override;
  101. void deactivate() override;
  102. void keyPressed(EShortcut key) override;
  103. bool captureThisKey(EShortcut key) override;
  104. void clickPressed(const Point & cursorPosition) override;
  105. void show(Canvas & to) override;
  106. void showAll(Canvas & to) override;
  107. void onScreenResize() override;
  108. /// Toggle UI to displaying tactics phase
  109. void tacticPhaseStarted();
  110. /// Toggle UI to displaying battle log in place of tactics UI
  111. void tacticPhaseEnded();
  112. /// Set possible alternative options to fill unit actions panel
  113. void setPossibleActions(const std::vector<PossiblePlayerBattleAction> & allActions);
  114. /// ends battle with autocombat
  115. void endWithAutocombat();
  116. };