BattleWindow.h 3.4 KB

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