mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Block feature is battle against human
This commit is contained in:
@@ -41,6 +41,8 @@
|
|||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
#include "../../lib/filesystem/ResourcePath.h"
|
#include "../../lib/filesystem/ResourcePath.h"
|
||||||
#include "../../lib/StartInfo.h"
|
#include "../../lib/StartInfo.h"
|
||||||
|
#include "../../lib/battle/BattleInfo.h"
|
||||||
|
#include "../../lib/CPlayerState.h"
|
||||||
#include "../windows/settings/SettingsMainWindow.h"
|
#include "../windows/settings/SettingsMainWindow.h"
|
||||||
|
|
||||||
BattleWindow::BattleWindow(BattleInterface & owner):
|
BattleWindow::BattleWindow(BattleInterface & owner):
|
||||||
@@ -52,6 +54,12 @@ BattleWindow::BattleWindow(BattleInterface & owner):
|
|||||||
pos.h = 600;
|
pos.h = 600;
|
||||||
pos = center();
|
pos = center();
|
||||||
|
|
||||||
|
PlayerColor defenderColor = owner.getBattle()->getBattle()->getSidePlayer(BattleSide::DEFENDER);
|
||||||
|
PlayerColor attackerColor = owner.getBattle()->getBattle()->getSidePlayer(BattleSide::ATTACKER);
|
||||||
|
bool isDefenderHuman = defenderColor != PlayerColor::NEUTRAL && LOCPLINT->cb->getStartInfo()->playerInfos.at(defenderColor).isControlledByHuman();
|
||||||
|
bool isAttackerHuman = attackerColor != PlayerColor::NEUTRAL && LOCPLINT->cb->getStartInfo()->playerInfos.at(attackerColor).isControlledByHuman();
|
||||||
|
onlyOnePlayerHuman = isDefenderHuman != isAttackerHuman;
|
||||||
|
|
||||||
REGISTER_BUILDER("battleConsole", &BattleWindow::buildBattleConsole);
|
REGISTER_BUILDER("battleConsole", &BattleWindow::buildBattleConsole);
|
||||||
|
|
||||||
const JsonNode config(JsonPath::builtin("config/widgets/BattleWindow2.json"));
|
const JsonNode config(JsonPath::builtin("config/widgets/BattleWindow2.json"));
|
||||||
@@ -552,7 +560,7 @@ void BattleWindow::bAutofightf()
|
|||||||
if (owner.actionsController->spellcastingModeActive())
|
if (owner.actionsController->spellcastingModeActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(settings["battle"]["endWithAutocombat"].Bool())
|
if(settings["battle"]["endWithAutocombat"].Bool() && onlyOnePlayerHuman)
|
||||||
{
|
{
|
||||||
endWithAutocombat();
|
endWithAutocombat();
|
||||||
return;
|
return;
|
||||||
@@ -728,8 +736,8 @@ void BattleWindow::blockUI(bool on)
|
|||||||
setShortcutBlocked(EShortcut::BATTLE_WAIT, on || owner.tacticsMode || !canWait);
|
setShortcutBlocked(EShortcut::BATTLE_WAIT, on || owner.tacticsMode || !canWait);
|
||||||
setShortcutBlocked(EShortcut::BATTLE_DEFEND, on || owner.tacticsMode);
|
setShortcutBlocked(EShortcut::BATTLE_DEFEND, on || owner.tacticsMode);
|
||||||
setShortcutBlocked(EShortcut::BATTLE_SELECT_ACTION, on || owner.tacticsMode);
|
setShortcutBlocked(EShortcut::BATTLE_SELECT_ACTION, on || owner.tacticsMode);
|
||||||
setShortcutBlocked(EShortcut::BATTLE_AUTOCOMBAT, settings["battle"]["endWithAutocombat"].Bool() ? on || owner.tacticsMode : owner.actionsController->spellcastingModeActive());
|
setShortcutBlocked(EShortcut::BATTLE_AUTOCOMBAT, (settings["battle"]["endWithAutocombat"].Bool() && onlyOnePlayerHuman) ? on || owner.tacticsMode || owner.actionsController->spellcastingModeActive() : owner.actionsController->spellcastingModeActive());
|
||||||
setShortcutBlocked(EShortcut::BATTLE_END_WITH_AUTOCOMBAT, on || owner.tacticsMode);
|
setShortcutBlocked(EShortcut::BATTLE_END_WITH_AUTOCOMBAT, on || owner.tacticsMode || !onlyOnePlayerHuman || owner.actionsController->spellcastingModeActive());
|
||||||
setShortcutBlocked(EShortcut::BATTLE_TACTICS_END, on && owner.tacticsMode);
|
setShortcutBlocked(EShortcut::BATTLE_TACTICS_END, on && owner.tacticsMode);
|
||||||
setShortcutBlocked(EShortcut::BATTLE_TACTICS_NEXT, on && owner.tacticsMode);
|
setShortcutBlocked(EShortcut::BATTLE_TACTICS_NEXT, on && owner.tacticsMode);
|
||||||
setShortcutBlocked(EShortcut::BATTLE_CONSOLE_DOWN, on && !owner.tacticsMode);
|
setShortcutBlocked(EShortcut::BATTLE_CONSOLE_DOWN, on && !owner.tacticsMode);
|
||||||
|
@@ -76,6 +76,8 @@ class BattleWindow : public InterfaceObjectConfigurable
|
|||||||
|
|
||||||
std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
|
std::shared_ptr<BattleConsole> buildBattleConsole(const JsonNode &) const;
|
||||||
|
|
||||||
|
bool onlyOnePlayerHuman;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BattleWindow(BattleInterface & owner );
|
BattleWindow(BattleInterface & owner );
|
||||||
~BattleWindow();
|
~BattleWindow();
|
||||||
|
Reference in New Issue
Block a user