Lua - hook up savestate library and implement saveslot() and loadslot() methods
This commit is contained in:
parent
363b913e52
commit
8e241067e6
|
@ -31,8 +31,8 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
LuaKillThread();
|
|
||||||
lua.Close();
|
lua.Close();
|
||||||
|
LuaKillThread();
|
||||||
LuaWait.Dispose();
|
LuaWait.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ namespace BizHawk.MultiClient
|
||||||
lua.NewTable("savestate");
|
lua.NewTable("savestate");
|
||||||
for (int i = 0; i < SaveStateFunctions.Length; i++)
|
for (int i = 0; i < SaveStateFunctions.Length; i++)
|
||||||
{
|
{
|
||||||
//lua.RegisterFunction("statestate." + SaveStateFunctions[i], this, this.GetType().GetMethod("savestate_" + SaveStateFunctions[i]));
|
lua.RegisterFunction("savestate." + SaveStateFunctions[i], this, this.GetType().GetMethod("savestate_" + SaveStateFunctions[i]));
|
||||||
//LuaLibraryList += "savestate." + SaveStateFunctions[i] + "\n";
|
LuaLibraryList += "savestate." + SaveStateFunctions[i] + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
lua.NewTable("movie");
|
lua.NewTable("movie");
|
||||||
|
@ -110,7 +110,8 @@ namespace BizHawk.MultiClient
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lua.DoFile(F);
|
if (LuaThread != null)
|
||||||
|
lua.DoFile(F);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -119,11 +120,12 @@ namespace BizHawk.MultiClient
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
LuaWait.Set();
|
LuaWait.Set();
|
||||||
}
|
}
|
||||||
public void LuaKillThread()
|
|
||||||
{
|
public void LuaKillThread()
|
||||||
if (LuaThread != null)
|
{
|
||||||
LuaThread.Abort();
|
if (LuaThread != null)
|
||||||
}
|
LuaThread.Abort();
|
||||||
|
}
|
||||||
|
|
||||||
public void DoLuaFile(string File)
|
public void DoLuaFile(string File)
|
||||||
{
|
{
|
||||||
|
@ -204,19 +206,21 @@ namespace BizHawk.MultiClient
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] SaveStateFunctions = new string[] {
|
public static string[] SaveStateFunctions = new string[] {
|
||||||
//"create",
|
"saveslot",
|
||||||
|
"loadslot",
|
||||||
"save",
|
"save",
|
||||||
"load"
|
"load"
|
||||||
//"write"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] MovieFunctions = new string[] {
|
public static string[] MovieFunctions = new string[] {
|
||||||
"mode",
|
"mode",
|
||||||
"rerecordcount",
|
"rerecordcount",
|
||||||
"stop"
|
"stop"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] JoypadFunctions = new string[] {
|
public static string[] JoypadFunctions = new string[] {
|
||||||
"set",
|
"set"
|
||||||
//"get",
|
//"get"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] MultiClientFunctions = new string[] {
|
public static string[] MultiClientFunctions = new string[] {
|
||||||
|
@ -272,9 +276,6 @@ namespace BizHawk.MultiClient
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y.GetType() != typeof(int))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString());
|
Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString());
|
||||||
Global.RenderPanel.AddGUIText(lua_input.ToString(), x, y);
|
Global.RenderPanel.AddGUIText(lua_input.ToString(), x, y);
|
||||||
}
|
}
|
||||||
|
@ -412,6 +413,43 @@ namespace BizHawk.MultiClient
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//Savestate library
|
//Savestate library
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
public void savestate_saveslot(object lua_input)
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
try //adelikat: This crap might not be necessary, need to test for a more elegant solution
|
||||||
|
{
|
||||||
|
x = int.Parse(lua_input.ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 0 || x > 9)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Global.MainForm.SaveState("QuickSave" + x.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savestate_loadslot(object lua_input)
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
try //adelikat: This crap might not be necessary, need to test for a more elegant solution
|
||||||
|
{
|
||||||
|
x = int.Parse(lua_input.ToString());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 0 || x > 9)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Global.MainForm.LoadState("QuickLoad" + x.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
public void savestate_save(object lua_input)
|
public void savestate_save(object lua_input)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,7 +118,7 @@ namespace BizHawk.MultiClient
|
||||||
Global.CheatList.SaveSettings();
|
Global.CheatList.SaveSettings();
|
||||||
CloseGame();
|
CloseGame();
|
||||||
Global.MovieSession.Movie.StopMovie();
|
Global.MovieSession.Movie.StopMovie();
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
ResizeBegin += (o, e) =>
|
ResizeBegin += (o, e) =>
|
||||||
|
@ -1790,7 +1790,7 @@ namespace BizHawk.MultiClient
|
||||||
MakeScreenshot(String.Format(PathManager.ScreenshotPrefix(Global.Game) + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now));
|
MakeScreenshot(String.Format(PathManager.ScreenshotPrefix(Global.Game) + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveState(string name)
|
public void SaveState(string name)
|
||||||
{
|
{
|
||||||
string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State";
|
string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State";
|
||||||
|
|
||||||
|
@ -1874,7 +1874,7 @@ namespace BizHawk.MultiClient
|
||||||
Global.RenderPanel.AddMessage("Loadstate error!");
|
Global.RenderPanel.AddMessage("Loadstate error!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadState(string name)
|
public void LoadState(string name)
|
||||||
{
|
{
|
||||||
string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State";
|
string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State";
|
||||||
if (File.Exists(path) == false)
|
if (File.Exists(path) == false)
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace BizHawk.MultiClient
|
||||||
private void StopAllScripts()
|
private void StopAllScripts()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < luaList.Count; x++)
|
for (int x = 0; x < luaList.Count; x++)
|
||||||
luaList[x].Enabled = false;
|
luaList[x].Enabled = false;
|
||||||
LuaImp.Close();
|
LuaImp.Close();
|
||||||
LuaImp = new LuaImplementation(this);
|
LuaImp = new LuaImplementation(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue