From 8a7e495039d735fffa99ca0c5380c443e257fd3c Mon Sep 17 00:00:00 2001 From: feos Date: Sun, 10 Nov 2019 17:09:10 +0300 Subject: [PATCH] allow suppressing more OSD savestate reports from lua --- BizHawk.Client.EmuHawk/MainForm.cs | 11 +++++++---- .../Lua/Libraries/EmuLuaLibrary.Savestate.cs | 16 ++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index cfa46037f9..68e61a66f9 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -3977,7 +3977,7 @@ namespace BizHawk.Client.EmuHawk 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()) { @@ -3996,7 +3996,10 @@ namespace BizHawk.Client.EmuHawk ClientApi.OnStateSaved(this, userFriendlyStateName); - GlobalWin.OSD.AddMessage($"Saved state: {userFriendlyStateName}"); + if (!suppressOSD) + { + GlobalWin.OSD.AddMessage($"Saved state: {userFriendlyStateName}"); + } } catch (IOException) { @@ -4010,7 +4013,7 @@ namespace BizHawk.Client.EmuHawk } // 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()) { @@ -4044,7 +4047,7 @@ namespace BizHawk.Client.EmuHawk Util.TryMoveBackupFile(path, $"{path}.bak"); } - SaveState(path, quickSlotName, false); + SaveState(path, quickSlotName, fromLua, suppressOSD); if (GlobalWin.Tools.Has()) { diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs index 8c251f94c2..87830add11 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk [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).")] - public void Load(string path) + public void Load(string path, bool suppressOSD = false) { if (!File.Exists(path)) { @@ -27,34 +27,34 @@ namespace BizHawk.Client.EmuHawk } else { - GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true); + GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true, suppressOSD); } } [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.")] - public void LoadSlot(int slotNum) + public void LoadSlot(int slotNum, bool suppressOSD = false) { if (slotNum >= 0 && slotNum <= 9) { - GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true); + GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true, suppressOSD); } } [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).")] - 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 );")] [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) { - GlobalWin.MainForm.SaveQuickSave($"QuickSave{slotNum}"); + GlobalWin.MainForm.SaveQuickSave($"QuickSave{slotNum}", true, suppressOSD); } } }