make savestate library its own object, also removed savestate.registersave and savestate.registerload (users should now use the events library instead). Todo: update documentation and remove references to these in any checked in lua scripts that might use them
This commit is contained in:
parent
18f0704a7c
commit
21a21ac7b7
|
@ -121,7 +121,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public string event_onloadstate(LuaFunction luaf, object name = null)
|
||||
{
|
||||
return savestate_registerload(luaf, name);
|
||||
NamedLuaFunction nlf = new NamedLuaFunction(luaf, "OnSavestateLoad", name != null ? name.ToString() : null);
|
||||
lua_functions.Add(nlf);
|
||||
return nlf.GUID.ToString();
|
||||
}
|
||||
|
||||
public void event_onmemoryread(LuaFunction luaf, object address = null)
|
||||
|
@ -199,7 +201,9 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public string event_onsavestate(LuaFunction luaf, object name = null)
|
||||
{
|
||||
return savestate_registersave(luaf, name);
|
||||
NamedLuaFunction nlf = new NamedLuaFunction(luaf, "OnSavestateSave", name != null ? name.ToString() : null);
|
||||
lua_functions.Add(nlf);
|
||||
return nlf.GUID.ToString();
|
||||
}
|
||||
|
||||
public bool event_unregisterbyid(object guid)
|
||||
|
|
|
@ -4,8 +4,23 @@ using BizHawk.Client.Common;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public partial class EmuLuaLibrary
|
||||
public class SavestateLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public override string Name { get { return "savestate"; } }
|
||||
public override string[] Functions
|
||||
{
|
||||
get
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
"load",
|
||||
"loadslot",
|
||||
"save",
|
||||
"saveslot",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void savestate_load(object lua_input)
|
||||
{
|
||||
if (lua_input is string)
|
||||
|
@ -16,35 +31,12 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void savestate_loadslot(object lua_input)
|
||||
{
|
||||
int x;
|
||||
int slot = LuaInt(lua_input);
|
||||
|
||||
try //adelikat: This crap might not be necessary, need to test for a more elegant solution
|
||||
if (slot >= 0 && slot <= 9)
|
||||
{
|
||||
x = int.Parse(lua_input.ToString());
|
||||
GlobalWinF.MainForm.LoadState("QuickSave" + slot.ToString(), true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (x < 0 || x > 9)
|
||||
return;
|
||||
|
||||
GlobalWinF.MainForm.LoadState("QuickSave" + x.ToString(), true);
|
||||
}
|
||||
|
||||
public string savestate_registerload(LuaFunction luaf, object name)
|
||||
{
|
||||
NamedLuaFunction nlf = new NamedLuaFunction(luaf, "OnSavestateLoad", name != null ? name.ToString() : null);
|
||||
lua_functions.Add(nlf);
|
||||
return nlf.GUID.ToString();
|
||||
}
|
||||
|
||||
public string savestate_registersave(LuaFunction luaf, object name)
|
||||
{
|
||||
NamedLuaFunction nlf = new NamedLuaFunction(luaf, "OnSavestateSave", name != null ? name.ToString() : null);
|
||||
lua_functions.Add(nlf);
|
||||
return nlf.GUID.ToString();
|
||||
}
|
||||
|
||||
public void savestate_save(object lua_input)
|
||||
|
@ -58,21 +50,12 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void savestate_saveslot(object lua_input)
|
||||
{
|
||||
int x;
|
||||
int slot = LuaInt(lua_input);
|
||||
|
||||
try //adelikat: This crap might not be necessary, need to test for a more elegant solution
|
||||
if (slot >= 0 && slot <= 9)
|
||||
{
|
||||
x = int.Parse(lua_input.ToString());
|
||||
GlobalWinF.MainForm.SaveState("QuickSave" + slot.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (x < 0 || x > 9)
|
||||
return;
|
||||
|
||||
GlobalWinF.MainForm.SaveState("QuickSave" + x.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace BizHawk.MultiClient
|
|||
"frameskip",
|
||||
"getsystemid",
|
||||
"islagged",
|
||||
"ispaused",
|
||||
"ispaused",
|
||||
"lagcount",
|
||||
"limitframerate",
|
||||
"minimizeframeskip",
|
||||
|
@ -106,16 +106,6 @@ namespace BizHawk.MultiClient
|
|||
"textbox",
|
||||
};
|
||||
|
||||
public static string[] SaveStateFunctions = new[]
|
||||
{
|
||||
"load",
|
||||
"loadslot",
|
||||
"registerload",
|
||||
"registersave",
|
||||
"save",
|
||||
"saveslot",
|
||||
};
|
||||
|
||||
public void LuaRegister(Lua lua)
|
||||
{
|
||||
lua.RegisterFunction("print", this, GetType().GetMethod("print"));
|
||||
|
@ -129,6 +119,7 @@ namespace BizHawk.MultiClient
|
|||
new MainMemoryLuaLibrary(_lua).LuaRegister(lua, Docs);
|
||||
new MovieLuaLibrary(_lua).LuaRegister(lua, Docs);
|
||||
new NESLuaLibrary().LuaRegister(lua, Docs);
|
||||
new SavestateLuaLibrary().LuaRegister(lua, Docs);
|
||||
new SNESLuaLibrary().LuaRegister(lua, Docs);
|
||||
|
||||
lua.NewTable("gui");
|
||||
|
@ -145,14 +136,6 @@ namespace BizHawk.MultiClient
|
|||
Docs.Add("emu", t, GetType().GetMethod("emu_" + t));
|
||||
}
|
||||
|
||||
lua.NewTable("savestate");
|
||||
foreach (string t in SaveStateFunctions)
|
||||
{
|
||||
lua.RegisterFunction("savestate." + t, this,
|
||||
GetType().GetMethod("savestate_" + t));
|
||||
Docs.Add("savestate", t, GetType().GetMethod("savestate_" + t));
|
||||
}
|
||||
|
||||
lua.NewTable("forms");
|
||||
foreach (string t in FormsFunctions)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue