From 5f0e6f7ce18fa6de10eb8cecf3096ac73ba4cfa6 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 29 Jul 2024 15:57:49 +0000 Subject: [PATCH] Close all dialogs on start of new turn in MP --- client/CPlayerInterface.cpp | 61 ++++++++++++++++++++----------------- client/CPlayerInterface.h | 1 + 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 0129cf9c6..ad44404ce 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -169,40 +169,44 @@ void CPlayerInterface::initGameInterface(std::shared_ptr ENV, std:: adventureInt.reset(new AdventureMapInterface()); } +void CPlayerInterface::closeAllDialogs() +{ + // remove all active dialogs that do not expect query answer + for (;;) + { + auto adventureWindow = GH.windows().topWindow(); + auto infoWindow = GH.windows().topWindow(); + + if(adventureWindow != nullptr) + break; + + if(infoWindow && infoWindow->ID != QueryID::NONE) + break; + + if (infoWindow) + infoWindow->close(); + else + GH.windows().popWindows(1); + } + + if(castleInt) + castleInt->close(); + + castleInt = nullptr; + + // remove all pending dialogs that do not expect query answer + vstd::erase_if(dialogs, [](const std::shared_ptr & window){ + return window->ID == QueryID::NONE; + }); +} + void CPlayerInterface::playerEndsTurn(PlayerColor player) { EVENT_HANDLER_CALLED_BY_CLIENT; if (player == playerID) { makingTurn = false; - - // remove all active dialogs that do not expect query answer - for (;;) - { - auto adventureWindow = GH.windows().topWindow(); - auto infoWindow = GH.windows().topWindow(); - - if(adventureWindow != nullptr) - break; - - if(infoWindow && infoWindow->ID != QueryID::NONE) - break; - - if (infoWindow) - infoWindow->close(); - else - GH.windows().popWindows(1); - } - - if(castleInt) - castleInt->close(); - - castleInt = nullptr; - - // remove all pending dialogs that do not expect query answer - vstd::erase_if(dialogs, [](const std::shared_ptr & window){ - return window->ID == QueryID::NONE; - }); + closeAllDialogs(); } } @@ -284,6 +288,7 @@ void CPlayerInterface::gamePause(bool pause) void CPlayerInterface::yourTurn(QueryID queryID) { + closeAllDialogs(); CTutorialWindow::openWindowFirstTime(TutorialMode::TOUCH_ADVENTUREMAP); EVENT_HANDLER_CALLED_BY_CLIENT; diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index fd03f76ed..1d1dcd01f 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -203,6 +203,7 @@ public: // public interface for use by client via LOCPLINT access void performAutosave(); void gamePause(bool pause); void endNetwork(); + void closeAllDialogs(); ///returns true if all events are processed internally bool capturedAllEvents();