2022-11-18 17:54:10 +02:00
|
|
|
/*
|
2022-12-21 17:06:47 +02:00
|
|
|
* BattleWindow.h, part of VCMI engine
|
2022-11-18 17:54:10 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../gui/CIntObject.h"
|
2022-12-25 12:22:07 +02:00
|
|
|
#include "../gui/InterfaceObjectConfigurable.h"
|
2022-12-20 01:28:20 +02:00
|
|
|
#include "../../lib/battle/CBattleInfoCallback.h"
|
2023-03-25 00:48:14 +02:00
|
|
|
#include "../../lib/battle/PossiblePlayerBattleAction.h"
|
2022-11-18 17:54:10 +02:00
|
|
|
|
2022-11-29 02:00:08 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2022-11-18 17:54:10 +02:00
|
|
|
class CStack;
|
2022-11-29 02:00:08 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2022-11-18 17:54:10 +02:00
|
|
|
class CButton;
|
2022-12-09 13:26:17 +02:00
|
|
|
class BattleInterface;
|
|
|
|
class BattleConsole;
|
2022-12-21 17:02:53 +02:00
|
|
|
class BattleRenderer;
|
|
|
|
class StackQueue;
|
2023-07-17 23:25:16 +02:00
|
|
|
class HeroInfoBasicPanel;
|
2022-11-18 17:54:10 +02:00
|
|
|
|
2022-12-11 23:16:23 +02:00
|
|
|
/// GUI object that handles functionality of panel at the bottom of combat screen
|
2023-01-04 16:20:53 +02:00
|
|
|
class BattleWindow : public InterfaceObjectConfigurable
|
2022-11-18 17:54:10 +02:00
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
BattleInterface & owner;
|
2022-11-18 17:54:10 +02:00
|
|
|
|
2022-12-21 17:02:53 +02:00
|
|
|
std::shared_ptr<StackQueue> queue;
|
|
|
|
std::shared_ptr<BattleConsole> console;
|
2023-07-17 23:25:16 +02:00
|
|
|
std::shared_ptr<HeroInfoBasicPanel> attackerHeroWindow;
|
|
|
|
std::shared_ptr<HeroInfoBasicPanel> defenderHeroWindow;
|
2022-12-21 17:02:53 +02:00
|
|
|
|
2022-12-11 23:16:23 +02:00
|
|
|
/// button press handling functions
|
2022-11-18 17:54:10 +02:00
|
|
|
void bOptionsf();
|
|
|
|
void bSurrenderf();
|
|
|
|
void bFleef();
|
|
|
|
void bAutofightf();
|
|
|
|
void bSpellf();
|
|
|
|
void bWaitf();
|
2022-12-20 01:28:20 +02:00
|
|
|
void bSwitchActionf();
|
2022-11-18 17:54:10 +02:00
|
|
|
void bDefencef();
|
|
|
|
void bConsoleUpf();
|
|
|
|
void bConsoleDownf();
|
|
|
|
void bTacticNextStack();
|
|
|
|
void bTacticPhaseEnd();
|
|
|
|
|
2022-12-11 23:16:23 +02:00
|
|
|
/// functions for handling actions after they were confirmed by popup window
|
|
|
|
void reallyFlee();
|
|
|
|
void reallySurrender();
|
2022-12-20 01:28:20 +02:00
|
|
|
|
|
|
|
/// management of alternative actions
|
|
|
|
std::list<PossiblePlayerBattleAction> alternativeActions;
|
|
|
|
PossiblePlayerBattleAction defaultAction;
|
|
|
|
void showAlternativeActionIcon(PossiblePlayerBattleAction);
|
2022-11-25 11:46:47 +02:00
|
|
|
|
2023-02-15 23:38:41 +02:00
|
|
|
/// flip battle queue visibility to opposite
|
|
|
|
void toggleQueueVisibility();
|
2023-03-05 16:36:28 +02:00
|
|
|
void createQueue();
|
2022-12-21 17:02:53 +02:00
|
|
|
|
2023-07-17 23:25:16 +02:00
|
|
|
void toggleStickyHeroWindowsVisibility();
|
|
|
|
void createStickyHeroInfoWindows();
|
|
|
|
|
2023-01-04 16:20:53 +02:00
|
|
|
std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
|
|
|
|
|
2022-11-18 17:54:10 +02:00
|
|
|
public:
|
2022-12-21 17:06:47 +02:00
|
|
|
BattleWindow(BattleInterface & owner );
|
2022-12-21 18:04:19 +02:00
|
|
|
~BattleWindow();
|
2022-12-21 17:02:53 +02:00
|
|
|
|
2023-01-04 16:20:53 +02:00
|
|
|
/// Closes window once battle finished
|
|
|
|
void close();
|
2022-11-18 17:54:10 +02:00
|
|
|
|
2023-02-15 23:38:41 +02:00
|
|
|
/// Toggle StackQueue visibility
|
|
|
|
void hideQueue();
|
|
|
|
void showQueue();
|
|
|
|
|
2023-07-17 23:25:16 +02:00
|
|
|
void hideStickyHeroWindows();
|
|
|
|
void showStickyHeroWindows();
|
|
|
|
|
2022-12-11 23:16:23 +02:00
|
|
|
/// block all UI elements when player is not allowed to act, e.g. during enemy turn
|
2022-11-18 17:54:10 +02:00
|
|
|
void blockUI(bool on);
|
|
|
|
|
2022-12-21 17:02:53 +02:00
|
|
|
/// Refresh queue after turn order changes
|
|
|
|
void updateQueue();
|
|
|
|
|
2023-01-22 21:03:11 +02:00
|
|
|
/// Get mouse-hovered battle queue unit ID if any found
|
2023-04-16 19:42:56 +02:00
|
|
|
std::optional<uint32_t> getQueueHoveredUnitId();
|
2023-01-22 21:03:11 +02:00
|
|
|
|
2022-12-21 17:02:53 +02:00
|
|
|
void activate() override;
|
|
|
|
void deactivate() override;
|
2023-04-27 19:21:06 +02:00
|
|
|
void keyPressed(EShortcut key) override;
|
2023-05-07 19:03:57 +02:00
|
|
|
bool captureThisKey(EShortcut key) override;
|
2023-07-15 21:18:04 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2023-06-02 15:42:18 +02:00
|
|
|
void show(Canvas & to) override;
|
|
|
|
void showAll(Canvas & to) override;
|
2022-11-27 02:26:02 +02:00
|
|
|
|
2022-12-11 23:16:23 +02:00
|
|
|
/// Toggle UI to displaying tactics phase
|
2022-11-18 17:54:10 +02:00
|
|
|
void tacticPhaseStarted();
|
2022-12-11 23:16:23 +02:00
|
|
|
|
|
|
|
/// Toggle UI to displaying battle log in place of tactics UI
|
2022-11-18 17:54:10 +02:00
|
|
|
void tacticPhaseEnded();
|
2023-01-04 16:20:53 +02:00
|
|
|
|
2022-12-20 01:28:20 +02:00
|
|
|
/// Set possible alternative options. If more than 1 - the last will be considered as default option
|
|
|
|
void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
|
2022-11-18 17:54:10 +02:00
|
|
|
};
|
2022-11-27 02:26:02 +02:00
|
|
|
|