mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 05:09:43 +00:00
Queue Lua handler uiModeChanged
This commit is contained in:
parent
b9c986b0b8
commit
4d66679204
3 changed files with 18 additions and 3 deletions
|
@ -246,6 +246,13 @@ namespace MWLua
|
|||
reloadAllScriptsImpl();
|
||||
mReloadAllScriptsRequested = false;
|
||||
}
|
||||
|
||||
if (mDelayedUiModeChangedArg)
|
||||
{
|
||||
if (playerScripts)
|
||||
playerScripts->uiModeChanged(*mDelayedUiModeChangedArg, true);
|
||||
mDelayedUiModeChangedArg = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void LuaManager::applyDelayedActions()
|
||||
|
@ -275,6 +282,7 @@ namespace MWLua
|
|||
mGlobalScripts.removeAllScripts();
|
||||
mGlobalScriptsStarted = false;
|
||||
mNewGameStarted = false;
|
||||
mDelayedUiModeChangedArg = std::nullopt;
|
||||
if (!mPlayer.isEmpty())
|
||||
{
|
||||
mPlayer.getCellRef().unsetRefNum();
|
||||
|
@ -325,9 +333,15 @@ namespace MWLua
|
|||
{
|
||||
if (mPlayer.isEmpty())
|
||||
return;
|
||||
ObjectId argId = arg.isEmpty() ? ObjectId() : getId(arg);
|
||||
if (mApplyingDelayedActions)
|
||||
{
|
||||
mDelayedUiModeChangedArg = argId;
|
||||
return;
|
||||
}
|
||||
PlayerScripts* playerScripts = dynamic_cast<PlayerScripts*>(mPlayer.getRefData().getLuaScripts());
|
||||
if (playerScripts)
|
||||
playerScripts->uiModeChanged(arg, mApplyingDelayedActions);
|
||||
playerScripts->uiModeChanged(argId, false);
|
||||
}
|
||||
|
||||
void LuaManager::objectAddedToScene(const MWWorld::Ptr& ptr)
|
||||
|
|
|
@ -204,6 +204,7 @@ namespace MWLua
|
|||
std::optional<DelayedAction> mTeleportPlayerAction;
|
||||
std::vector<std::string> mUIMessages;
|
||||
std::vector<std::pair<std::string, Misc::Color>> mInGameConsoleMessages;
|
||||
std::optional<ObjectId> mDelayedUiModeChangedArg;
|
||||
|
||||
LuaUtil::LuaStorage mGlobalStorage{ mLua.sol() };
|
||||
LuaUtil::LuaStorage mPlayerStorage{ mLua.sol() };
|
||||
|
|
|
@ -66,9 +66,9 @@ namespace MWLua
|
|||
}
|
||||
|
||||
// `arg` is either forwarded from MWGui::pushGuiMode or empty
|
||||
void uiModeChanged(const MWWorld::Ptr& arg, bool byLuaAction)
|
||||
void uiModeChanged(ObjectId arg, bool byLuaAction)
|
||||
{
|
||||
if (arg.isEmpty())
|
||||
if (arg.isZeroOrUnset())
|
||||
callEngineHandlers(mUiModeChanged, byLuaAction);
|
||||
else
|
||||
callEngineHandlers(mUiModeChanged, byLuaAction, LObject(arg));
|
||||
|
|
Loading…
Reference in a new issue