Refactor disabling Lua script into separate method
This commit is contained in:
parent
7c7ac64ae6
commit
3a70fb65f8
|
@ -203,9 +203,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// we don't use runningScripts here as the other scripts need to be stopped too
|
||||
foreach (var file in luaLibsImpl.ScriptList)
|
||||
{
|
||||
if (file.Enabled) luaLibsImpl.CallExitEvent(file);
|
||||
luaLibsImpl.RegisteredFunctions.RemoveForFile(file, Emulator);
|
||||
file.Stop();
|
||||
DisableLuaScript(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1508,12 +1506,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
EnableLuaFile(file);
|
||||
}
|
||||
else if (!file.Enabled && file.Thread is not null)
|
||||
{
|
||||
DisableLuaScript(file);
|
||||
// there used to be a call here which did a redraw of the Gui/OSD, which included a call to `Tools.UpdateToolsAfter` --yoshi
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableLuaScript(LuaFile file)
|
||||
{
|
||||
if (LuaImp is not Win32LuaLibraries luaLibsImpl) return;
|
||||
|
||||
if (file.IsSeparator) return;
|
||||
|
||||
file.State = LuaFile.RunState.Disabled;
|
||||
|
||||
if (file.Thread is not null)
|
||||
{
|
||||
luaLibsImpl.CallExitEvent(file);
|
||||
luaLibsImpl.RegisteredFunctions.RemoveForFile(file, Emulator);
|
||||
luaLibsImpl.CallExitEvent(file);
|
||||
file.Stop();
|
||||
// there used to be a call here which did a redraw of the Gui/OSD, which included a call to `Tools.UpdateToolsAfter` --yoshi
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue