Lua - tastudio library - supress lua console updates when invoking tastudio methods that cause tool udpates, fixes #2172
This commit is contained in:
parent
b5cf9cb241
commit
e4d4c3a9d8
|
@ -104,13 +104,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
bool wasPaused = MainForm.EmulatorPaused;
|
bool wasPaused = MainForm.EmulatorPaused;
|
||||||
|
|
||||||
// can't re-enter lua while doing this
|
// can't re-enter lua while doing this
|
||||||
GlobalWin.Tools.LuaConsole.LuaImp.SuppressLua = true;
|
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
|
||||||
while (Emulator.Frame != frame)
|
while (Emulator.Frame != frame)
|
||||||
{
|
{
|
||||||
MainForm.SeekFrameAdvance();
|
MainForm.SeekFrameAdvance();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalWin.Tools.LuaConsole.LuaImp.SuppressLua = false;
|
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
|
||||||
|
|
||||||
if (!wasPaused)
|
if (!wasPaused)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,18 +21,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public void Load(string path, bool suppressOSD = false)
|
public void Load(string path, bool suppressOSD = false)
|
||||||
{
|
{
|
||||||
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
||||||
var luaImp = GlobalWin.Tools.LuaConsole?.LuaImp;
|
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
|
||||||
if (luaImp != null)
|
|
||||||
{
|
|
||||||
luaImp.SuppressLua = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
APIs.SaveState.Load(path, suppressOSD);
|
APIs.SaveState.Load(path, suppressOSD);
|
||||||
|
|
||||||
if (luaImp != null)
|
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
|
||||||
{
|
|
||||||
luaImp.SuppressLua = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethodExample("savestate.loadslot( 7 );")]
|
[LuaMethodExample("savestate.loadslot( 7 );")]
|
||||||
|
@ -40,18 +33,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public void LoadSlot(int slotNum, bool suppressOSD = false)
|
public void LoadSlot(int slotNum, bool suppressOSD = false)
|
||||||
{
|
{
|
||||||
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
||||||
var luaImp = GlobalWin.Tools.LuaConsole?.LuaImp;
|
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
|
||||||
if (luaImp != null)
|
|
||||||
{
|
|
||||||
luaImp.SuppressLua = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
APIs.SaveState.LoadSlot(slotNum, suppressOSD);
|
APIs.SaveState.LoadSlot(slotNum, suppressOSD);
|
||||||
|
|
||||||
if (luaImp != null)
|
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
|
||||||
{
|
|
||||||
luaImp.SuppressLua = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethodExample("savestate.save( \"C:\\state.bin\" );")]
|
[LuaMethodExample("savestate.save( \"C:\\state.bin\" );")]
|
||||||
|
|
|
@ -137,6 +137,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (Engaged())
|
if (Engaged())
|
||||||
{
|
{
|
||||||
|
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
||||||
|
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
|
||||||
|
|
||||||
int f;
|
int f;
|
||||||
if (frame is double frameNumber)
|
if (frame is double frameNumber)
|
||||||
{
|
{
|
||||||
|
@ -157,6 +160,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Tastudio.GoToFrame(f, true);
|
Tastudio.GoToFrame(f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,6 +294,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (Engaged())
|
if (Engaged())
|
||||||
{
|
{
|
||||||
|
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
||||||
|
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
|
||||||
|
|
||||||
if (_changeList.Count > 0)
|
if (_changeList.Count > 0)
|
||||||
{
|
{
|
||||||
int size = _changeList.Count;
|
int size = _changeList.Count;
|
||||||
|
@ -324,6 +332,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Tastudio.JumpToGreenzone();
|
Tastudio.JumpToGreenzone();
|
||||||
Tastudio.DoAutoRestore();
|
Tastudio.DoAutoRestore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +428,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (Engaged())
|
if (Engaged())
|
||||||
{
|
{
|
||||||
|
// TODO: find a non-global way to access LuaImp from Lua libraries!
|
||||||
|
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
|
||||||
|
|
||||||
Tastudio.LoadBranchByIndex(index);
|
Tastudio.LoadBranchByIndex(index);
|
||||||
|
|
||||||
|
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -559,7 +559,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void UpdateBefore()
|
protected override void UpdateBefore()
|
||||||
{
|
{
|
||||||
if (LuaImp.SuppressLua)
|
if (LuaImp.IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
protected override void UpdateAfter()
|
protected override void UpdateAfter()
|
||||||
{
|
{
|
||||||
if (LuaImp.SuppressLua)
|
if (LuaImp.IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LuaImp.SuppressLua)
|
if (LuaImp.IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public readonly LuaFileList ScriptList = new LuaFileList();
|
public readonly LuaFileList ScriptList = new LuaFileList();
|
||||||
|
|
||||||
public bool IsRebootingCore { get; set; } // pretty hacky.. we don't want a lua script to be able to restart itself by rebooting the core
|
public bool IsRebootingCore { get; set; } // pretty hacky.. we don't want a lua script to be able to restart itself by rebooting the core
|
||||||
public bool SuppressLua { get; set; }
|
|
||||||
|
public bool IsUpdateSupressed { get; private set;}
|
||||||
|
|
||||||
|
public void SupressUpdate()
|
||||||
|
{
|
||||||
|
IsUpdateSupressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableUpdate()
|
||||||
|
{
|
||||||
|
IsUpdateSupressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
public EventWaitHandle LuaWait { get; protected set; }
|
public EventWaitHandle LuaWait { get; protected set; }
|
||||||
|
|
||||||
public abstract void CallExitEvent(LuaFile lf);
|
public abstract void CallExitEvent(LuaFile lf);
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public override void StartLuaDrawing()
|
public override void StartLuaDrawing()
|
||||||
{
|
{
|
||||||
if (ScriptList.Count != 0 && GuiLibrary.SurfaceIsNull && !SuppressLua)
|
if (ScriptList.Count != 0 && GuiLibrary.SurfaceIsNull && !IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
GuiLibrary.DrawNew("emu");
|
GuiLibrary.DrawNew("emu");
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public override void EndLuaDrawing()
|
public override void EndLuaDrawing()
|
||||||
{
|
{
|
||||||
if (ScriptList.Count != 0 && !SuppressLua)
|
if (ScriptList.Count != 0 && !IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
GuiLibrary.DrawFinish();
|
GuiLibrary.DrawFinish();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public override void CallFrameBeforeEvent()
|
public override void CallFrameBeforeEvent()
|
||||||
{
|
{
|
||||||
if (!SuppressLua)
|
if (!IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
EventsLibrary.CallFrameBeforeEvent();
|
EventsLibrary.CallFrameBeforeEvent();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public override void CallFrameAfterEvent()
|
public override void CallFrameAfterEvent()
|
||||||
{
|
{
|
||||||
if (!SuppressLua)
|
if (!IsUpdateSupressed)
|
||||||
{
|
{
|
||||||
EventsLibrary.CallFrameAfterEvent();
|
EventsLibrary.CallFrameAfterEvent();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue