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();
}
if (LuaImp is Win32LuaLibraries luaLibsImpl)
{
luaLibsImpl.GuiLibrary?.DrawFinish();
luaLibsImpl.Close();
}
(LuaImp as Win32LuaLibraries)?.Close();
DisplayManager.OSD.ClearGuiText();
}
else
@ -221,11 +217,6 @@ namespace BizHawk.Client.EmuHawk
return;
}
if (luaLibsImpl.GuiLibrary != null && luaLibsImpl.GuiLibrary.HasLuaSurface)
{
luaLibsImpl.GuiLibrary.DrawFinish();
}
runningScripts = luaLibsImpl.ScriptList.Where(lf => lf.Enabled).ToList();
foreach (var file in runningScripts)
@ -572,7 +563,6 @@ namespace BizHawk.Client.EmuHawk
}
luaLibsImpl.CallFrameBeforeEvent();
luaLibsImpl.StartLuaDrawing();
}
protected override void UpdateAfter()
@ -584,7 +574,6 @@ namespace BizHawk.Client.EmuHawk
luaLibsImpl.CallFrameAfterEvent();
ResumeScripts(true);
luaLibsImpl.EndLuaDrawing();
}
protected override void FastUpdateBefore()
@ -617,11 +606,6 @@ namespace BizHawk.Client.EmuHawk
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))
{
try
@ -955,7 +939,7 @@ namespace BizHawk.Client.EmuHawk
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)
{
@ -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)
{
foreach (var s in SelectedFiles)
@ -1581,7 +1554,7 @@ namespace BizHawk.Client.EmuHawk
luaLibsImpl.RegisteredFunctions.RemoveForFile(file, Emulator);
luaLibsImpl.CallExitEvent(file);
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 GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
public bool IsRebootingCore { 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 LuaFunctionList RegisteredFunctions { get; } = new LuaFunctionList();
@ -252,7 +234,6 @@ namespace BizHawk.Client.EmuHawk
FormsLibrary.DestroyAll();
_lua.Close();
_lua = new Lua();
GuiLibrary.Dispose();
}
public INamedLuaFunction CreateAndRegisterNamedFunction(LuaFunction function, string theEvent, Action<string> logCallback, LuaFile luaFile, string name = null)