BattleWindow.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. /// GUI object that handles functionality of panel at the bottom of combat screen
  24. class BattleWindow : public InterfaceObjectConfigurable
  25. {
  26. BattleInterface & owner;
  27. std::shared_ptr<StackQueue> queue;
  28. std::shared_ptr<BattleConsole> console;
  29. /// button press handling functions
  30. void bOptionsf();
  31. void bSurrenderf();
  32. void bFleef();
  33. void bAutofightf();
  34. void bSpellf();
  35. void bWaitf();
  36. void bSwitchActionf();
  37. void bDefencef();
  38. void bConsoleUpf();
  39. void bConsoleDownf();
  40. void bTacticNextStack();
  41. void bTacticPhaseEnd();
  42. /// functions for handling actions after they were confirmed by popup window
  43. void reallyFlee();
  44. void reallySurrender();
  45. /// management of alternative actions
  46. std::list<PossiblePlayerBattleAction> alternativeActions;
  47. PossiblePlayerBattleAction defaultAction;
  48. void showAlternativeActionIcon(PossiblePlayerBattleAction);
  49. /// flip battle queue visibility to opposite
  50. void toggleQueueVisibility();
  51. void createQueue();
  52. std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
  53. public:
  54. BattleWindow(BattleInterface & owner );
  55. ~BattleWindow();
  56. /// Closes window once battle finished
  57. void close();
  58. /// Toggle StackQueue visibility
  59. void hideQueue();
  60. void showQueue();
  61. /// block all UI elements when player is not allowed to act, e.g. during enemy turn
  62. void blockUI(bool on);
  63. /// Refresh queue after turn order changes
  64. void updateQueue();
  65. /// Get mouse-hovered battle queue unit ID if any found
  66. std::optional<uint32_t> getQueueHoveredUnitId();
  67. void activate() override;
  68. void deactivate() override;
  69. void keyPressed(const SDL_Keycode & key) override;
  70. void keyReleased(const SDL_Keycode& key) override;
  71. void clickRight(tribool down, bool previousState) override;
  72. void show(SDL_Surface *to) override;
  73. void showAll(SDL_Surface *to) override;
  74. /// Toggle UI to displaying tactics phase
  75. void tacticPhaseStarted();
  76. /// Toggle UI to displaying battle log in place of tactics UI
  77. void tacticPhaseEnded();
  78. /// Set possible alternative options. If more than 1 - the last will be considered as default option
  79. void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
  80. private:
  81. /// used to save the state of this setting on toggle.
  82. bool movementHighlightOnHoverCache;
  83. };