1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 03:32:36 +00:00

Force windows to exit when popping their GUI mode through Lua

This commit is contained in:
Evil Eye 2024-06-18 20:02:39 +02:00
parent 6653502567
commit 989686500c
4 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -1303,7 +1303,7 @@ namespace MWGui
return mViewer->getCamera()->getCullMask();
}
void WindowManager::popGuiMode()
void WindowManager::popGuiMode(bool forceExit)
{
if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop)
{
@ -1313,6 +1313,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);

View File

@ -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;

View File

@ -255,7 +255,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)