Lua - implement emu.registerbefore and emu.registerafter. Note that all lua work is done on the beginning of the frame (before) by default. also note that Registerbefore will run before normal lua processing.
This commit is contained in:
parent
b45a9b80a3
commit
63ef0c0832
|
@ -25,6 +25,8 @@ namespace BizHawk.MultiClient
|
|||
private Lua currThread;
|
||||
private LuaFunction savestate_registersavefunc;
|
||||
private LuaFunction savestate_registerloadfunc;
|
||||
private LuaFunction frame_registerbeforefunc;
|
||||
private LuaFunction frame_registerafterfunc;
|
||||
|
||||
public void SavestateRegisterSave(string name)
|
||||
{
|
||||
|
@ -60,6 +62,40 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void FrameRegisterBefore()
|
||||
{
|
||||
if (frame_registerbeforefunc != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
frame_registerbeforefunc.Call();
|
||||
}
|
||||
catch (SystemException e)
|
||||
{
|
||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(
|
||||
"error running function attached by lua function emu.registerbefore" +
|
||||
"\nError message: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FrameRegisterAfter()
|
||||
{
|
||||
if (frame_registerafterfunc != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
frame_registerafterfunc.Call();
|
||||
}
|
||||
catch (SystemException e)
|
||||
{
|
||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(
|
||||
"error running function attached by lua function emu.registerafter" +
|
||||
"\nError message: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LuaImplementation(LuaConsole passed)
|
||||
{
|
||||
LuaWait = new AutoResetEvent(false);
|
||||
|
@ -312,7 +348,9 @@ namespace BizHawk.MultiClient
|
|||
"minimizeframeskip",
|
||||
"limitframerate",
|
||||
"displayvsync",
|
||||
"enablerewind"
|
||||
"enablerewind",
|
||||
"registerbefore",
|
||||
"registerafter",
|
||||
};
|
||||
|
||||
public static string[] MemoryFunctions = new string[]
|
||||
|
@ -1069,6 +1107,16 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void emu_registerbefore(LuaFunction luaf)
|
||||
{
|
||||
frame_registerbeforefunc = luaf;
|
||||
}
|
||||
|
||||
public void emu_registerafter(LuaFunction luaf)
|
||||
{
|
||||
frame_registerafterfunc = luaf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
//Memory library
|
||||
//----------------------------------------------------
|
||||
|
|
|
@ -1898,10 +1898,6 @@ namespace BizHawk.MultiClient
|
|||
if (!fff)
|
||||
{
|
||||
UpdateToolsBefore();
|
||||
#if WINDOWS
|
||||
LuaConsole1.ResumeScripts(true);
|
||||
Global.DisplayManager.PreFrameUpdateLuaSource();
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((DateTime.Now - runloop_second).TotalSeconds > 1)
|
||||
|
@ -2011,6 +2007,11 @@ namespace BizHawk.MultiClient
|
|||
/// </summary>
|
||||
public void UpdateToolsBefore()
|
||||
{
|
||||
LuaConsole1.LuaImp.FrameRegisterBefore();
|
||||
#if WINDOWS
|
||||
LuaConsole1.ResumeScripts(true);
|
||||
Global.DisplayManager.PreFrameUpdateLuaSource();
|
||||
#endif
|
||||
RamWatch1.UpdateValues();
|
||||
RamSearch1.UpdateValues();
|
||||
HexEditor1.UpdateValues();
|
||||
|
@ -2027,6 +2028,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
//The other tool updates are earlier, TAStudio needs to be later so it can display the latest
|
||||
//frame of execution in its list view.
|
||||
LuaConsole1.LuaImp.FrameRegisterAfter();
|
||||
TAStudio1.UpdateValues();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue