Remove GuiLibrary from Win32LuaLibraries (fixes #2571)

Wrapping draw calls in DrawNew/DrawFinish is the responsibility of the script
author. This removes the feature which allowed scripts to draw as soon as they
became enabled. see also #2501 (still broken)
This commit is contained in:
YoshiRulz 2021-01-17 04:18:27 +10:00
parent c28a12a410
commit 9cca7c4a31
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 3 additions and 49 deletions

View File

@ -134,11 +134,7 @@ namespace BizHawk.Client.EmuHawk
MainForm.FrameBufferResized(); MainForm.FrameBufferResized();
} }
if (LuaImp is Win32LuaLibraries luaLibsImpl) (LuaImp as Win32LuaLibraries)?.Close();
{
luaLibsImpl.GuiLibrary?.DrawFinish();
luaLibsImpl.Close();
}
DisplayManager.OSD.ClearGuiText(); DisplayManager.OSD.ClearGuiText();
} }
else else
@ -221,11 +217,6 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
if (luaLibsImpl.GuiLibrary != null && luaLibsImpl.GuiLibrary.HasLuaSurface)
{
luaLibsImpl.GuiLibrary.DrawFinish();
}
runningScripts = luaLibsImpl.ScriptList.Where(lf => lf.Enabled).ToList(); runningScripts = luaLibsImpl.ScriptList.Where(lf => lf.Enabled).ToList();
foreach (var file in runningScripts) foreach (var file in runningScripts)
@ -572,7 +563,6 @@ namespace BizHawk.Client.EmuHawk
} }
luaLibsImpl.CallFrameBeforeEvent(); luaLibsImpl.CallFrameBeforeEvent();
luaLibsImpl.StartLuaDrawing();
} }
protected override void UpdateAfter() protected override void UpdateAfter()
@ -584,7 +574,6 @@ namespace BizHawk.Client.EmuHawk
luaLibsImpl.CallFrameAfterEvent(); luaLibsImpl.CallFrameAfterEvent();
ResumeScripts(true); ResumeScripts(true);
luaLibsImpl.EndLuaDrawing();
} }
protected override void FastUpdateBefore() protected override void FastUpdateBefore()
@ -617,11 +606,6 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
if (luaLibsImpl.GuiLibrary?.SurfaceIsNull == true)
{
luaLibsImpl.GuiLibrary.DrawNew("emu");
}
foreach (var lf in luaLibsImpl.ScriptList.Where(l => l.Enabled && l.Thread != null && !l.Paused)) foreach (var lf in luaLibsImpl.ScriptList.Where(l => l.Enabled && l.Thread != null && !l.Paused))
{ {
try try
@ -955,7 +939,7 @@ namespace BizHawk.Client.EmuHawk
item.State = LuaFile.RunState.Disabled; item.State = LuaFile.RunState.Disabled;
}); });
ReDraw(); // there used to be a call here which did a redraw of the Gui/OSD, which included a call to `Tools.UpdateToolsAfter` --yoshi
} }
catch (IOException) catch (IOException)
{ {
@ -967,17 +951,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void ReDraw()
{
// Shenanigans
// We want any gui.text messages from a script to immediately update even when paused
DisplayManager.OSD.ClearGuiText();
Tools.UpdateToolsAfter();
if (!(LuaImp is Win32LuaLibraries luaLibsImpl)) return;
luaLibsImpl.EndLuaDrawing();
luaLibsImpl.StartLuaDrawing();
}
private void PauseScriptMenuItem_Click(object sender, EventArgs e) private void PauseScriptMenuItem_Click(object sender, EventArgs e)
{ {
foreach (var s in SelectedFiles) foreach (var s in SelectedFiles)
@ -1581,7 +1554,7 @@ namespace BizHawk.Client.EmuHawk
luaLibsImpl.RegisteredFunctions.RemoveForFile(file, Emulator); luaLibsImpl.RegisteredFunctions.RemoveForFile(file, Emulator);
luaLibsImpl.CallExitEvent(file); luaLibsImpl.CallExitEvent(file);
file.Stop(); file.Stop();
ReDraw(); // there used to be a call here which did a redraw of the Gui/OSD, which included a call to `Tools.UpdateToolsAfter` --yoshi
} }
} }

View File

@ -125,8 +125,6 @@ namespace BizHawk.Client.EmuHawk
public string EngineName => Lua.WhichLua; public string EngineName => Lua.WhichLua;
public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
public bool IsRebootingCore { get; set; } public bool IsRebootingCore { get; set; }
public bool IsUpdateSupressed { get; set; } public bool IsUpdateSupressed { get; set; }
@ -155,22 +153,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void StartLuaDrawing()
{
if (ScriptList.Count != 0 && GuiLibrary.SurfaceIsNull && !IsUpdateSupressed)
{
GuiLibrary.DrawNew("emu");
}
}
public void EndLuaDrawing()
{
if (ScriptList.Count != 0 && !IsUpdateSupressed)
{
GuiLibrary.DrawFinish();
}
}
public bool FrameAdvanceRequested { get; private set; } public bool FrameAdvanceRequested { get; private set; }
public LuaFunctionList RegisteredFunctions { get; } = new LuaFunctionList(); public LuaFunctionList RegisteredFunctions { get; } = new LuaFunctionList();
@ -252,7 +234,6 @@ namespace BizHawk.Client.EmuHawk
FormsLibrary.DestroyAll(); FormsLibrary.DestroyAll();
_lua.Close(); _lua.Close();
_lua = new Lua(); _lua = new Lua();
GuiLibrary.Dispose();
} }
public INamedLuaFunction CreateAndRegisterNamedFunction(LuaFunction function, string theEvent, Action<string> logCallback, LuaFile luaFile, string name = null) public INamedLuaFunction CreateAndRegisterNamedFunction(LuaFunction function, string theEvent, Action<string> logCallback, LuaFile luaFile, string name = null)