Revert "Remove GuiLibrary from Win32LuaLibraries (fixes #2571)"
This reverts commit 9cca7c4a31
.
This commit is contained in:
parent
4a58ff2a0c
commit
de0d0d19e2
|
@ -134,7 +134,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
MainForm.FrameBufferResized();
|
||||
}
|
||||
|
||||
(LuaImp as Win32LuaLibraries)?.Close();
|
||||
if (LuaImp is Win32LuaLibraries luaLibsImpl)
|
||||
{
|
||||
luaLibsImpl.GuiLibrary?.DrawFinish();
|
||||
luaLibsImpl.Close();
|
||||
}
|
||||
DisplayManager.OSD.ClearGuiText();
|
||||
}
|
||||
else
|
||||
|
@ -217,6 +221,11 @@ 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)
|
||||
|
@ -563,6 +572,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
luaLibsImpl.CallFrameBeforeEvent();
|
||||
luaLibsImpl.StartLuaDrawing();
|
||||
}
|
||||
|
||||
protected override void UpdateAfter()
|
||||
|
@ -574,6 +584,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
luaLibsImpl.CallFrameAfterEvent();
|
||||
ResumeScripts(true);
|
||||
luaLibsImpl.EndLuaDrawing();
|
||||
}
|
||||
|
||||
protected override void FastUpdateBefore()
|
||||
|
@ -606,6 +617,11 @@ 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
|
||||
|
@ -939,7 +955,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
item.State = LuaFile.RunState.Disabled;
|
||||
});
|
||||
|
||||
// there used to be a call here which did a redraw of the Gui/OSD, which included a call to `Tools.UpdateToolsAfter` --yoshi
|
||||
ReDraw();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
@ -951,6 +967,17 @@ 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)
|
||||
|
@ -1554,7 +1581,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
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
|
||||
ReDraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,6 +125,8 @@ 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; }
|
||||
|
@ -153,6 +155,22 @@ 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();
|
||||
|
@ -234,6 +252,7 @@ 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)
|
||||
|
|
Loading…
Reference in New Issue