1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/*
* BattleWindow.h, part of VCMI engine
*
* 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"
#include "../gui/InterfaceObjectConfigurable.h"
#include "../../lib/battle/CBattleInfoCallback.h"
#include "../../lib/battle/PossiblePlayerBattleAction.h"
VCMI_LIB_NAMESPACE_BEGIN
class CStack;
VCMI_LIB_NAMESPACE_END
class CButton;
class BattleInterface;
class BattleConsole;
class BattleRenderer;
class StackQueue;
class TurnTimerWidget;
class HeroInfoBasicPanel;
class StackInfoBasicPanel;
class QuickSpellPanel;
/// GUI object that handles functionality of panel at the bottom of combat screen
class BattleWindow : public InterfaceObjectConfigurable
{
BattleInterface & owner;
std::shared_ptr<StackQueue> queue;
std::shared_ptr<BattleConsole> console;
std::shared_ptr<HeroInfoBasicPanel> attackerHeroWindow;
std::shared_ptr<HeroInfoBasicPanel> defenderHeroWindow;
std::shared_ptr<StackInfoBasicPanel> attackerStackWindow;
std::shared_ptr<StackInfoBasicPanel> defenderStackWindow;
std::shared_ptr<QuickSpellPanel> quickSpellWindow;
std::shared_ptr<TurnTimerWidget> attackerTimerWidget;
std::shared_ptr<TurnTimerWidget> defenderTimerWidget;
/// button press handling functions
void bOptionsf();
void bSurrenderf();
void bFleef();
void bAutofightf();
void bSpellf();
void bWaitf();
void bSwitchActionf();
void bDefencef();
void bConsoleUpf();
void bConsoleDownf();
void bTacticNextStack();
void bTacticPhaseEnd();
void bOpenActiveUnit();
void bOpenHoveredUnit();
/// functions for handling actions after they were confirmed by popup window
void reallyFlee();
void reallySurrender();
/// management of alternative actions
std::list<PossiblePlayerBattleAction> alternativeActions;
PossiblePlayerBattleAction lastAlternativeAction;
void showAlternativeActionIcon(PossiblePlayerBattleAction);
void useSpellIfPossible(int slot);
/// flip battle queue visibility to opposite
void toggleQueueVisibility();
void createQueue();
void toggleStickyHeroWindowsVisibility();
void toggleStickyQuickSpellVisibility();
void createStickyHeroInfoWindows();
void createQuickSpellWindow();
void createTimerInfoWindows();
std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
bool onlyOnePlayerHuman;
public:
BattleWindow(BattleInterface & owner );
/// Closes window once battle finished
void close();
/// Toggle StackQueue visibility
void hideQueue();
void showQueue();
/// Toggle permanent hero info windows visibility (HD mod feature)
void hideStickyHeroWindows();
void showStickyHeroWindows();
/// Toggle permanent quickspell windows visibility
void hideStickyQuickSpellWindow();
void showStickyQuickSpellWindow();
/// Event handler for netpack changing hero mana points
void heroManaPointsChanged(const CGHeroInstance * hero);
/// block all UI elements when player is not allowed to act, e.g. during enemy turn
void blockUI(bool on);
/// Refresh queue after turn order changes
void updateQueue();
// Set positions for hero & stack info window
void setPositionInfoWindow();
/// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
void updateHeroInfoWindow(uint8_t side, const InfoAboutHero & hero);
/// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
void updateStackInfoWindow(const CStack * stack);
/// Get mouse-hovered battle queue unit ID if any found
std::optional<uint32_t> getQueueHoveredUnitId();
void activate() override;
void deactivate() override;
void keyPressed(EShortcut key) override;
bool captureThisKey(EShortcut key) override;
void clickPressed(const Point & cursorPosition) override;
void show(Canvas & to) override;
void showAll(Canvas & to) override;
/// Toggle UI to displaying tactics phase
void tacticPhaseStarted();
/// Toggle UI to displaying battle log in place of tactics UI
void tacticPhaseEnded();
/// Set possible alternative options. If more than 1 - the last will be considered as default option
void setAlternativeActions(const std::list<PossiblePlayerBattleAction> &);
/// ends battle with autocombat
void endWithAutocombat();
};
|