From e8845244f71b629074a1b4f01bc4853d449189ee Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sun, 25 Dec 2022 14:33:10 +0400 Subject: [PATCH] Fix tactic button --- client/battle/BattleControlPanel.cpp | 8 +++----- client/gui/InterfaceObjectConfigurable.cpp | 7 +++++++ client/gui/InterfaceObjectConfigurable.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/battle/BattleControlPanel.cpp b/client/battle/BattleControlPanel.cpp index 7167a4ecc..f78299d76 100644 --- a/client/battle/BattleControlPanel.cpp +++ b/client/battle/BattleControlPanel.cpp @@ -99,12 +99,10 @@ void BattleControlPanel::tacticPhaseStarted() } void BattleControlPanel::tacticPhaseEnded() { - build(variables["battleItems"]); + deleteWidget("tacticNext"); + deleteWidget("tacticEnd"); - if(auto w = widget("tacticNext")) - w.reset(); - if(auto w = widget("tacticEnd")) - w.reset(); + build(variables["battleItems"]); if(auto w = widget("menu")) { diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index fe57565b1..a67570c15 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -66,6 +66,13 @@ void InterfaceObjectConfigurable::addCallback(const std::string & callbackName, callbacks[callbackName] = callback; } +void InterfaceObjectConfigurable::deleteWidget(const std::string & name) +{ + auto iter = widgets.find(name); + if(iter != widgets.end()) + widgets.erase(iter); +} + void InterfaceObjectConfigurable::build(const JsonNode &config) { OBJ_CONSTRUCTION; diff --git a/client/gui/InterfaceObjectConfigurable.h b/client/gui/InterfaceObjectConfigurable.h index 90347ad78..ccdb11efa 100644 --- a/client/gui/InterfaceObjectConfigurable.h +++ b/client/gui/InterfaceObjectConfigurable.h @@ -52,6 +52,8 @@ protected: return nullptr; return std::dynamic_pointer_cast(iter->second); } + + void deleteWidget(const std::string & name); //basic serializers Point readPosition(const JsonNode &) const;