diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 14674e4503..0b2e85f3e1 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -120,7 +120,7 @@ namespace MWBase virtual void pushGuiMode(MWGui::GuiMode mode, const MWWorld::Ptr& arg) = 0; virtual void pushGuiMode(MWGui::GuiMode mode) = 0; - virtual void popGuiMode() = 0; + virtual void popGuiMode(bool forceExit = false) = 0; virtual void removeGuiMode(MWGui::GuiMode mode) = 0; ///< can be anywhere in the stack diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 012c19275c..64bb0c66ca 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1306,7 +1306,7 @@ namespace MWGui return mViewer->getCamera()->getCullMask(); } - void WindowManager::popGuiMode() + void WindowManager::popGuiMode(bool forceExit) { if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop) { @@ -1316,6 +1316,12 @@ namespace MWGui if (!mGuiModes.empty()) { const GuiMode mode = mGuiModes.back(); + if (forceExit) + { + GuiModeState& state = mGuiModeStates[mode]; + for (const auto& window : state.mWindows) + window->exit(); + } mKeyboardNavigation->saveFocus(mode); mGuiModes.pop_back(); mGuiModeStates[mode].update(false); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 6f880efd7e..f7c778e10a 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -150,7 +150,7 @@ namespace MWGui void pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg) override; void pushGuiMode(GuiMode mode) override; - void popGuiMode() override; + void popGuiMode(bool forceExit = false) override; void removeGuiMode(GuiMode mode) override; ///< can be anywhere in the stack void goToJail(int days) override; diff --git a/apps/openmw/mwlua/uibindings.cpp b/apps/openmw/mwlua/uibindings.cpp index 6bbda4c762..4ac9940b92 100644 --- a/apps/openmw/mwlua/uibindings.cpp +++ b/apps/openmw/mwlua/uibindings.cpp @@ -260,7 +260,7 @@ namespace MWLua // TODO: Maybe disallow opening/closing special modes (main menu, settings, loading screen) // from player scripts. Add new Lua context "menu" that can do it. for (unsigned i = stack.size() - common; i > 0; i--) - windowManager->popGuiMode(); + windowManager->popGuiMode(true); if (common == newStack.size() && !newStack.empty() && arg.has_value()) windowManager->pushGuiMode(newStack.back(), ptr); for (unsigned i = common; i < newStack.size(); ++i)