BattleWindow.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. /// GUI object that handles functionality of panel at the bottom of combat screen
  27. class BattleWindow : public InterfaceObjectConfigurable
  28. {
  29. BattleInterface & owner;
  30. std::shared_ptr<StackQueue> queue;
  31. std::shared_ptr<BattleConsole> console;
  32. std::shared_ptr<HeroInfoBasicPanel> attackerHeroWindow;
  33. std::shared_ptr<HeroInfoBasicPanel> defenderHeroWindow;
  34. std::shared_ptr<StackInfoBasicPanel> attackerStackWindow;
  35. std::shared_ptr<StackInfoBasicPanel> defenderStackWindow;
  36. std::shared_ptr<TurnTimerWidget> attackerTimerWidget;
  37. std::shared_ptr<TurnTimerWidget> defenderTimerWidget;
  38. /// button press handling functions
  39. void bOptionsf();
  40. void bSurrenderf();
  41. void bFleef();
  42. void bAutofightf();
  43. void bSpellf();
  44. void bWaitf();
  45. void bSwitchActionf();
  46. void bDefencef();
  47. void bConsoleUpf();
  48. void bConsoleDownf();
  49. void bTacticNextStack();
  50. void bTacticPhaseEnd();
  51. /// functions for handling actions after they were confirmed by popup window
  52. void reallyFlee();
  53. void reallySurrender();
  54. /// management of alternative actions
  55. std::list<PossiblePlayerBattleAction> alternativeActions;
  56. PossiblePlayerBattleAction defaultAction;
  57. void showAlternativeActionIcon(PossiblePlayerBattleAction);
  58. /// flip battle queue visibility to opposite
  59. void toggleQueueVisibility();
  60. void createQueue();
  61. void toggleStickyHeroWindowsVisibility();
  62. void createStickyHeroInfoWindows();
  63. void createTimerInfoWindows();
  64. std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
  65. bool onlyOnePlayerHuman;
  66. public:
  67. BattleWindow(BattleInterface & owner );
  68. ~BattleWindow();
  69. /// Closes window once battle finished
  70. void close();
  71. /// Toggle StackQueue visibility
  72. void hideQueue();
  73. void showQueue();
  74. /// Toggle permanent hero info windows visibility (HD mod feature)
  75. void hideStickyHeroWindows();
  76. void showStickyHeroWindows();
  77. /// Event handler for netpack changing hero mana points
  78. void heroManaPointsChanged(const CGHeroInstance * hero);
  79. /// block all UI elements when player is not allowed to act, e.g. during enemy turn
  80. void blockUI(bool on);
  81. /// Refresh queue after turn order changes
  82. void updateQueue();
  83. // Set positions for hero & stack info window
  84. void setPositionInfoWindow();
  85. /// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
  86. void updateHeroInfoWindow(uint8_t side, const InfoAboutHero & hero);
  87. /// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
  88. void updateStackInfoWindow(const CStack * stack);
  89. /// Get mouse-hovered battle queue unit ID if any found
  90. std::optional<uint32_t> getQueueHoveredUnitId();
  91. void activate() override;
  92. void deactivate() override;
  93. void keyPressed(EShortcut key) override;
  94. bool captureThisKey(EShortcut key) override;
  95. void clickPressed(const Point & cursorPosition) override;
  96. void show(Canvas & to) override;
  97. void showAll(Canvas & to) override;
  98. /// Toggle UI to displaying tactics phase
  99. void tacticPhaseStarted();
  100. /// Toggle UI to displaying battle log in place of tactics UI
  101. void tacticPhaseEnded();
  102. /// Set possible alternative options. If more than 1 - the last will be considered as default option
  103. void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
  104. /// ends battle with autocombat
  105. void endWithAutocombat();
  106. };