allow suppressing more OSD savestate reports from lua

This commit is contained in:
feos 2019-11-10 17:09:10 +03:00
parent 46ea09da10
commit 8a7e495039
2 changed files with 15 additions and 12 deletions

View File

@ -3977,7 +3977,7 @@ namespace BizHawk.Client.EmuHawk
LoadState(path, quickSlotName, fromLua, suppressOSD); LoadState(path, quickSlotName, fromLua, suppressOSD);
} }
public void SaveState(string path, string userFriendlyStateName, bool fromLua) public void SaveState(string path, string userFriendlyStateName, bool fromLua = false, bool suppressOSD = false)
{ {
if (!Emulator.HasSavestates()) if (!Emulator.HasSavestates())
{ {
@ -3996,8 +3996,11 @@ namespace BizHawk.Client.EmuHawk
ClientApi.OnStateSaved(this, userFriendlyStateName); ClientApi.OnStateSaved(this, userFriendlyStateName);
if (!suppressOSD)
{
GlobalWin.OSD.AddMessage($"Saved state: {userFriendlyStateName}"); GlobalWin.OSD.AddMessage($"Saved state: {userFriendlyStateName}");
} }
}
catch (IOException) catch (IOException)
{ {
GlobalWin.OSD.AddMessage($"Unable to save state {path}"); GlobalWin.OSD.AddMessage($"Unable to save state {path}");
@ -4010,7 +4013,7 @@ namespace BizHawk.Client.EmuHawk
} }
// TODO: should backup logic be stuffed in into Client.Common.SaveStateManager? // TODO: should backup logic be stuffed in into Client.Common.SaveStateManager?
public void SaveQuickSave(string quickSlotName) public void SaveQuickSave(string quickSlotName, bool fromLua = false, bool suppressOSD = false)
{ {
if (!Emulator.HasSavestates()) if (!Emulator.HasSavestates())
{ {
@ -4044,7 +4047,7 @@ namespace BizHawk.Client.EmuHawk
Util.TryMoveBackupFile(path, $"{path}.bak"); Util.TryMoveBackupFile(path, $"{path}.bak");
} }
SaveState(path, quickSlotName, false); SaveState(path, quickSlotName, fromLua, suppressOSD);
if (GlobalWin.Tools.Has<LuaConsole>()) if (GlobalWin.Tools.Has<LuaConsole>())
{ {

View File

@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk
[LuaMethodExample("savestate.load( \"C:\\state.bin\" );")] [LuaMethodExample("savestate.load( \"C:\\state.bin\" );")]
[LuaMethod("load", "Loads a savestate with the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).")] [LuaMethod("load", "Loads a savestate with the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).")]
public void Load(string path) public void Load(string path, bool suppressOSD = false)
{ {
if (!File.Exists(path)) if (!File.Exists(path))
{ {
@ -27,34 +27,34 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true); GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true, suppressOSD);
} }
} }
[LuaMethodExample("savestate.loadslot( 7 );")] [LuaMethodExample("savestate.loadslot( 7 );")]
[LuaMethod("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.")] [LuaMethod("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.")]
public void LoadSlot(int slotNum) public void LoadSlot(int slotNum, bool suppressOSD = false)
{ {
if (slotNum >= 0 && slotNum <= 9) if (slotNum >= 0 && slotNum <= 9)
{ {
GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true); GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true, suppressOSD);
} }
} }
[LuaMethodExample("savestate.save( \"C:\\state.bin\" );")] [LuaMethodExample("savestate.save( \"C:\\state.bin\" );")]
[LuaMethod("save", "Saves a state at the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).")] [LuaMethod("save", "Saves a state at the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).")]
public void Save(string path) public void Save(string path, bool suppressOSD = false)
{ {
GlobalWin.MainForm.SaveState(path, path, true); GlobalWin.MainForm.SaveState(path, path, true, suppressOSD);
} }
[LuaMethodExample("savestate.saveslot( 7 );")] [LuaMethodExample("savestate.saveslot( 7 );")]
[LuaMethod("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.")] [LuaMethod("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.")]
public void SaveSlot(int slotNum) public void SaveSlot(int slotNum, bool suppressOSD = false)
{ {
if (slotNum >= 0 && slotNum <= 9) if (slotNum >= 0 && slotNum <= 9)
{ {
GlobalWin.MainForm.SaveQuickSave($"QuickSave{slotNum}"); GlobalWin.MainForm.SaveQuickSave($"QuickSave{slotNum}", true, suppressOSD);
} }
} }
} }