1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-27 12:40:25 +00:00

Merge branch 'fix_hidden_window' into 'master'

Fix bug related to !3236

See merge request OpenMW/openmw!3406
This commit is contained in:
psi29a 2023-09-09 08:06:47 +00:00
commit bcc3365766
No known key found for this signature in database
4 changed files with 13 additions and 5 deletions

View file

@ -243,6 +243,7 @@ namespace MWLua
void LuaManager::applyDelayedActions() void LuaManager::applyDelayedActions()
{ {
mApplyingDelayedActions = true;
for (DelayedAction& action : mActionQueue) for (DelayedAction& action : mActionQueue)
action.apply(); action.apply();
mActionQueue.clear(); mActionQueue.clear();
@ -250,6 +251,7 @@ namespace MWLua
if (mTeleportPlayerAction) if (mTeleportPlayerAction)
mTeleportPlayerAction->apply(); mTeleportPlayerAction->apply();
mTeleportPlayerAction.reset(); mTeleportPlayerAction.reset();
mApplyingDelayedActions = false;
} }
void LuaManager::clear() void LuaManager::clear()
@ -318,7 +320,7 @@ namespace MWLua
return; return;
PlayerScripts* playerScripts = dynamic_cast<PlayerScripts*>(mPlayer.getRefData().getLuaScripts()); PlayerScripts* playerScripts = dynamic_cast<PlayerScripts*>(mPlayer.getRefData().getLuaScripts());
if (playerScripts) if (playerScripts)
playerScripts->uiModeChanged(arg); playerScripts->uiModeChanged(arg, mApplyingDelayedActions);
} }
void LuaManager::objectAddedToScene(const MWWorld::Ptr& ptr) void LuaManager::objectAddedToScene(const MWWorld::Ptr& ptr)
@ -558,6 +560,8 @@ namespace MWLua
void LuaManager::addAction(std::function<void()> action, std::string_view name) void LuaManager::addAction(std::function<void()> action, std::string_view name)
{ {
if (mApplyingDelayedActions)
throw std::runtime_error("DelayedAction is not allowed to create another DelayedAction");
mActionQueue.emplace_back(&mLua, std::move(action), name); mActionQueue.emplace_back(&mLua, std::move(action), name);
} }

View file

@ -153,6 +153,7 @@ namespace MWLua
bool mInitialized = false; bool mInitialized = false;
bool mGlobalScriptsStarted = false; bool mGlobalScriptsStarted = false;
bool mProcessingInputEvents = false; bool mProcessingInputEvents = false;
bool mApplyingDelayedActions = false;
bool mNewGameStarted = false; bool mNewGameStarted = false;
LuaUtil::ScriptsConfiguration mConfiguration; LuaUtil::ScriptsConfiguration mConfiguration;
LuaUtil::LuaState mLua; LuaUtil::LuaState mLua;

View file

@ -66,12 +66,12 @@ namespace MWLua
} }
// `arg` is either forwarded from MWGui::pushGuiMode or empty // `arg` is either forwarded from MWGui::pushGuiMode or empty
void uiModeChanged(const MWWorld::Ptr& arg) void uiModeChanged(const MWWorld::Ptr& arg, bool byLuaAction)
{ {
if (arg.isEmpty()) if (arg.isEmpty())
callEngineHandlers(mUiModeChanged); callEngineHandlers(mUiModeChanged, byLuaAction);
else else
callEngineHandlers(mUiModeChanged, LObject(arg)); callEngineHandlers(mUiModeChanged, byLuaAction, LObject(arg));
} }
private: private:

View file

@ -99,7 +99,7 @@ local function removeMode(mode)
end end
local oldMode = nil local oldMode = nil
local function onUiModeChanged(arg) local function onUiModeChanged(changedByLua, arg)
local newStack = ui._getUiModeStack() local newStack = ui._getUiModeStack()
for i = 1, math.max(#modeStack, #newStack) do for i = 1, math.max(#modeStack, #newStack) do
modeStack[i] = newStack[i] modeStack[i] = newStack[i]
@ -112,6 +112,9 @@ local function onUiModeChanged(arg)
end end
local mode = newStack[#newStack] local mode = newStack[#newStack]
if mode then if mode then
if not changedByLua then
updateHidden(mode)
end
for _, w in pairs(ui._getAllowedWindows(mode)) do for _, w in pairs(ui._getAllowedWindows(mode)) do
local state = replacedWindows[w] local state = replacedWindows[w]
if state and not hiddenWindows[w] then if state and not hiddenWindows[w] then