From 9cca7c4a315683aa8d872555aa86c1563bb412ed Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 17 Jan 2021 04:18:27 +1000 Subject: [PATCH] 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) --- .../tools/Lua/LuaConsole.cs | 33 ++----------------- .../tools/Lua/Win32LuaLibraries.cs | 19 ----------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 57d7a3578d..9b110024e2 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -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 } } diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs index 91dbab46ec..5220d0c855 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs @@ -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 logCallback, LuaFile luaFile, string name = null)