Use new _luaLibsImpl prop instead of LuaConsole.LuaImp via globals

This commit is contained in:
YoshiRulz 2020-11-25 19:46:52 +10:00
parent a6d1c6595a
commit db63222f32
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 17 additions and 22 deletions

View File

@ -101,13 +101,13 @@ namespace BizHawk.Client.EmuHawk
bool wasPaused = MainForm.EmulatorPaused;
// can't re-enter lua while doing this
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
_luaLibsImpl.SupressUpdate();
while (Emulator.Frame != frame)
{
MainForm.SeekFrameAdvance();
}
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
_luaLibsImpl.EnableUpdate();
if (!wasPaused)
{
@ -199,9 +199,9 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod("reboot_core", "Reboots the currently loaded core")]
public void RebootCore()
{
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = true;
_luaLibsImpl.IsRebootingCore = true;
APIs.EmuClient.RebootCore();
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = false;
_luaLibsImpl.IsRebootingCore = false;
}
[LuaMethodExample("local incliscr = client.screenheight( );")]

View File

@ -26,10 +26,10 @@ namespace BizHawk.Client.EmuHawk
[LuaMethodExample("local stconget = console.getluafunctionslist( );")]
[LuaMethod("getluafunctionslist", "returns a list of implemented functions")]
public static string GetLuaFunctionsList()
public string GetLuaFunctionsList()
{
var list = new StringBuilder();
foreach (var function in GlobalWin.Tools.LuaConsole.LuaImp.Docs)
foreach (var function in _luaLibsImpl.Docs)
{
list.AppendLine(function.Name);
}

View File

@ -353,7 +353,7 @@ namespace BizHawk.Client.EmuHawk
"newform", "creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created.")]
public int NewForm(int? width = null, int? height = null, string title = null, LuaFunction onClose = null)
{
var form = new LuaWinform(CurrentFile, GlobalWin.Tools.LuaConsole.LuaImp);
var form = new LuaWinform(CurrentFile, _luaLibsImpl);
_luaForms.Add(form);
if (width.HasValue && height.HasValue)
{

View File

@ -17,24 +17,22 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod("load", "Loads a savestate with the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).")]
public void Load(string path, bool suppressOSD = false)
{
// TODO: find a non-global way to access LuaImp from Lua libraries!
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
_luaLibsImpl.SupressUpdate();
APIs.SaveState.Load(path, suppressOSD);
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
_luaLibsImpl.EnableUpdate();
}
[LuaMethodExample("savestate.loadslot( 7 );")]
[LuaMethod("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.")]
public void LoadSlot(int slotNum, bool suppressOSD = false)
{
// TODO: find a non-global way to access LuaImp from Lua libraries!
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
_luaLibsImpl.SupressUpdate();
APIs.SaveState.LoadSlot(slotNum, suppressOSD);
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
_luaLibsImpl.EnableUpdate();
}
[LuaMethodExample("savestate.save( \"C:\\state.bin\" );")]

View File

@ -134,8 +134,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Engaged())
{
// TODO: find a non-global way to access LuaImp from Lua libraries!
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
_luaLibsImpl.SupressUpdate();
int f;
if (frame is double frameNumber)
@ -158,7 +157,7 @@ namespace BizHawk.Client.EmuHawk
Tastudio.GoToFrame(f, true);
}
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
_luaLibsImpl.EnableUpdate();
}
}
@ -291,8 +290,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Engaged())
{
// TODO: find a non-global way to access LuaImp from Lua libraries!
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
_luaLibsImpl.SupressUpdate();
if (_changeList.Count > 0)
{
@ -330,7 +328,7 @@ namespace BizHawk.Client.EmuHawk
Tastudio.DoAutoRestore();
}
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
_luaLibsImpl.EnableUpdate();
}
}
@ -425,12 +423,11 @@ namespace BizHawk.Client.EmuHawk
{
if (Engaged())
{
// TODO: find a non-global way to access LuaImp from Lua libraries!
GlobalWin.Tools.LuaConsole?.LuaImp.SupressUpdate();
_luaLibsImpl.SupressUpdate();
Tastudio.LoadBranchByIndex(index);
GlobalWin.Tools.LuaConsole?.LuaImp.EnableUpdate();
_luaLibsImpl.EnableUpdate();
}
}