From 7030fa8fe7844c5a07113d933becefea6570ea96 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 5 Mar 2023 16:36:28 +0200 Subject: [PATCH] Allow changing queue size instantly on option toggle --- client/battle/BattleInterface.cpp | 3 +-- client/battle/BattleWindow.cpp | 34 +++++++++++++++---------------- client/battle/BattleWindow.h | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index b9f80a42b..10cec82ab 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -745,8 +745,7 @@ void BattleInterface::executeOnAnimationCondition( EAnimationEvents event, bool void BattleInterface::setBattleQueueVisibility(bool visible) { + windowObject->hideQueue(); if(visible) windowObject->showQueue(); - else - windowObject->hideQueue(); } diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index 1bb73ceb5..dd71da022 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -72,6 +72,20 @@ BattleWindow::BattleWindow(BattleInterface & owner): owner.fieldController.reset( new BattleFieldController(owner)); owner.fieldController->createHeroes(); + createQueue(); + + if ( owner.tacticsMode ) + tacticPhaseStarted(); + else + tacticPhaseEnded(); + + addUsedEvents(RCLICK | KEYBOARD); +} + +void BattleWindow::createQueue() +{ + OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; + //create stack queue and adjust our own position bool embedQueue; std::string queueSize = settings["battle"]["queueSize"].String(); @@ -89,13 +103,6 @@ BattleWindow::BattleWindow(BattleInterface & owner): pos.h += queue->pos.h; pos = center(); } - - if ( owner.tacticsMode ) - tacticPhaseStarted(); - else - tacticPhaseEnded(); - - addUsedEvents(RCLICK | KEYBOARD); } BattleWindow::~BattleWindow() @@ -147,16 +154,9 @@ void BattleWindow::showQueue() Settings showQueue = settings.write["battle"]["showQueue"]; showQueue->Bool() = true; - queue->enable(); - - if (!queue->embedded) - { - //re-center, taking into account stack queue position - pos.y -= queue->pos.h; - pos.h += queue->pos.h; - pos = center(); - GH.totalRedraw(); - } + createQueue(); + updateQueue(); + GH.totalRedraw(); } void BattleWindow::updateQueue() diff --git a/client/battle/BattleWindow.h b/client/battle/BattleWindow.h index 32df209a6..ee4ba1449 100644 --- a/client/battle/BattleWindow.h +++ b/client/battle/BattleWindow.h @@ -57,7 +57,7 @@ class BattleWindow : public InterfaceObjectConfigurable /// flip battle queue visibility to opposite void toggleQueueVisibility(); - + void createQueue(); std::shared_ptr buildBattleConsole(const JsonNode &) const;