BattleWindow.h 3.5 KB

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