Merge branch 'evictthosewindows' into 'master'

Force windows to exit when popping their GUI mode through Lua

Closes #7834

See merge request OpenMW/openmw!4185
pull/3236/head
psi29a 6 months ago
commit cc28396617

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

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

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

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

Loading…
Cancel
Save