BizHawk/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs

58 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using LuaInterface;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public sealed class SavestateLuaLibrary : LuaLibraryBase
{
public SavestateLuaLibrary(Lua lua)
: base(lua) { }
public SavestateLuaLibrary(Lua lua, Action<string> logOutputCallback)
: base(lua, logOutputCallback) { }
2017-05-19 14:47:18 +00:00
public override string Name => "savestate";
2017-05-19 14:47:18 +00:00
[LuaMethodAttributes("load", "Loads a savestate with the given path")]
public void Load(string path)
{
if (!File.Exists(path))
{
2017-05-19 14:47:18 +00:00
Log($"could not find file: {path}");
}
else
{
GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true);
}
}
2017-05-19 14:47:18 +00:00
[LuaMethodAttributes("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9)")]
public void LoadSlot(int slotNum)
{
if (slotNum >= 0 && slotNum <= 9)
{
GlobalWin.MainForm.LoadQuickSave("QuickSave" + slotNum, true);
}
}
2017-05-19 14:47:18 +00:00
[LuaMethodAttributes("save", "Saves a state at the given path")]
public void Save(string path)
{
GlobalWin.MainForm.SaveState(path, path, true);
}
2017-05-19 14:47:18 +00:00
[LuaMethodAttributes("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9)")]
public void SaveSlot(int slotNum)
{
if (slotNum >= 0 && slotNum <= 9)
{
GlobalWin.MainForm.SaveQuickSave("QuickSave" + slotNum);
}
}
}
}