Lua - savestate.registerload() implemented

This commit is contained in:
andres.delikat 2012-03-27 21:17:20 +00:00
parent be807c3def
commit 655af69326
2 changed files with 23 additions and 0 deletions

View File

@ -23,6 +23,7 @@ namespace BizHawk.MultiClient
public bool FrameAdvanceRequested; public bool FrameAdvanceRequested;
Lua currThread; Lua currThread;
LuaFunction savestate_registersavefunc; LuaFunction savestate_registersavefunc;
LuaFunction savestate_registerloadfunc;
public void SavestateRegisterSave() public void SavestateRegisterSave()
{ {
@ -39,6 +40,21 @@ namespace BizHawk.MultiClient
} }
} }
public void SavestateRegisterLoad()
{
if (savestate_registerloadfunc != null)
{
try
{
savestate_registerloadfunc.Call();
}
catch
{
Global.RenderPanel.AddMessage("error running function attached by lua function savestate.registerload");
}
}
}
public LuaImplementation(LuaConsole passed) public LuaImplementation(LuaConsole passed)
{ {
LuaWait = new AutoResetEvent(false); LuaWait = new AutoResetEvent(false);
@ -302,6 +318,7 @@ namespace BizHawk.MultiClient
"save", "save",
"load", "load",
"registersave", "registersave",
"registerload",
}; };
public static string[] MovieFunctions = new string[] { public static string[] MovieFunctions = new string[] {
@ -1095,6 +1112,11 @@ namespace BizHawk.MultiClient
savestate_registersavefunc = luaf; savestate_registersavefunc = luaf;
} }
public void savestate_registerload(LuaFunction luaf)
{
savestate_registerloadfunc = luaf;
}
//---------------------------------------------------- //----------------------------------------------------
//Movie library //Movie library
//---------------------------------------------------- //----------------------------------------------------

View File

@ -1938,6 +1938,7 @@ namespace BizHawk.MultiClient
public void LoadStateFile(string path, string name) public void LoadStateFile(string path, string name)
{ {
LuaConsole1.LuaImp.SavestateRegisterLoad();
if (HandleMovieLoadState(path)) if (HandleMovieLoadState(path))
{ {
var reader = new StreamReader(path); var reader = new StreamReader(path);