BattleWindow.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. VCMI_LIB_NAMESPACE_BEGIN
  15. class CStack;
  16. VCMI_LIB_NAMESPACE_END
  17. class CButton;
  18. class BattleInterface;
  19. class BattleConsole;
  20. class BattleRenderer;
  21. class StackQueue;
  22. /// GUI object that handles functionality of panel at the bottom of combat screen
  23. class BattleWindow : public InterfaceObjectConfigurable
  24. {
  25. BattleInterface & owner;
  26. std::shared_ptr<StackQueue> queue;
  27. std::shared_ptr<BattleConsole> console;
  28. /// button press handling functions
  29. void bOptionsf();
  30. void bSurrenderf();
  31. void bFleef();
  32. void bAutofightf();
  33. void bSpellf();
  34. void bWaitf();
  35. void bSwitchActionf();
  36. void bDefencef();
  37. void bConsoleUpf();
  38. void bConsoleDownf();
  39. void bTacticNextStack();
  40. void bTacticPhaseEnd();
  41. /// functions for handling actions after they were confirmed by popup window
  42. void reallyFlee();
  43. void reallySurrender();
  44. /// management of alternative actions
  45. std::list<PossiblePlayerBattleAction> alternativeActions;
  46. PossiblePlayerBattleAction defaultAction;
  47. void showAlternativeActionIcon(PossiblePlayerBattleAction);
  48. /// Toggle StackQueue visibility
  49. void hideQueue();
  50. void showQueue();
  51. std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
  52. public:
  53. BattleWindow(BattleInterface & owner );
  54. ~BattleWindow();
  55. /// Closes window once battle finished
  56. void close();
  57. /// block all UI elements when player is not allowed to act, e.g. during enemy turn
  58. void blockUI(bool on);
  59. /// Refresh queue after turn order changes
  60. void updateQueue();
  61. void activate() override;
  62. void deactivate() override;
  63. void keyPressed(const SDL_KeyboardEvent & key) override;
  64. void clickRight(tribool down, bool previousState) override;
  65. void show(SDL_Surface *to) override;
  66. void showAll(SDL_Surface *to) override;
  67. /// Toggle UI to displaying tactics phase
  68. void tacticPhaseStarted();
  69. /// Toggle UI to displaying battle log in place of tactics UI
  70. void tacticPhaseEnded();
  71. /// Set possible alternative options. If more than 1 - the last will be considered as default option
  72. void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
  73. };