2014-05-21 00:17:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using LuaInterface;
|
2013-10-28 19:13:01 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-06-01 22:02:59 +00:00
|
|
|
|
public sealed class SavestateLuaLibrary : LuaLibraryBase
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-05-21 00:17:35 +00:00
|
|
|
|
public SavestateLuaLibrary(Lua lua)
|
|
|
|
|
: base(lua) { }
|
|
|
|
|
|
|
|
|
|
public SavestateLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
|
|
|
|
: base(lua, logOutputCallback) { }
|
|
|
|
|
|
2013-10-31 16:20:45 +00:00
|
|
|
|
public override string Name { get { return "savestate"; } }
|
|
|
|
|
|
2014-01-26 13:30:45 +00:00
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"load",
|
2014-01-26 18:36:27 +00:00
|
|
|
|
"Loads a savestate with the given path"
|
2014-01-26 13:30:45 +00:00
|
|
|
|
)]
|
|
|
|
|
public void Load(string path)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-01-26 13:30:45 +00:00
|
|
|
|
GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true);
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-26 13:30:45 +00:00
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"loadslot",
|
2014-01-26 18:36:27 +00:00
|
|
|
|
"Loads the savestate at the given slot number (must be an integer between 0 and 9)"
|
2014-01-26 13:30:45 +00:00
|
|
|
|
)]
|
2014-01-27 20:19:08 +00:00
|
|
|
|
public void LoadSlot(int slotNum)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-01-27 20:19:08 +00:00
|
|
|
|
if (slotNum >= 0 && slotNum <= 9)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-01-27 20:19:08 +00:00
|
|
|
|
GlobalWin.MainForm.LoadQuickSave("QuickSave" + slotNum, true);
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-26 13:30:45 +00:00
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"save",
|
2014-01-26 18:36:27 +00:00
|
|
|
|
"Saves a state at the given path"
|
2014-01-26 13:30:45 +00:00
|
|
|
|
)]
|
|
|
|
|
public void Save(string path)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-01-26 13:30:45 +00:00
|
|
|
|
GlobalWin.MainForm.SaveState(path, path, true);
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-26 13:30:45 +00:00
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"saveslot",
|
2014-01-26 18:36:27 +00:00
|
|
|
|
"Saves a state at the given save slot (must be an integer between 0 and 9)"
|
2014-01-26 13:30:45 +00:00
|
|
|
|
)]
|
2014-01-27 20:19:08 +00:00
|
|
|
|
public void SaveSlot(int slotNum)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-01-27 20:19:08 +00:00
|
|
|
|
if (slotNum >= 0 && slotNum <= 9)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2014-01-27 20:19:08 +00:00
|
|
|
|
GlobalWin.MainForm.SaveQuickSave("QuickSave" + slotNum);
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|