From 4fc81991d777a52d900a21d5ca33d298fd204e0a Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 26 Apr 2014 17:28:43 +0000 Subject: [PATCH] Save cheats even if the cheat dialog was never opened (for instance, if the cheat were added via a game genie dialog or lua) --- BizHawk.Client.Common/tools/CheatList.cs | 14 +++++++++++++- BizHawk.Client.EmuHawk/tools/ToolManager.cs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 5a35393467..6fb53ca27d 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -101,9 +101,21 @@ namespace BizHawk.Client.Common return false; } - public void NewList(string defaultFileName) + public void NewList(string defaultFileName, bool autosave = false) { _defaultFileName = defaultFileName; + + if (_cheatList.Any() && _changes && autosave) + { + if (string.IsNullOrEmpty(_currentFileName)) + { + _currentFileName = _defaultFileName; + } + + Save(); + } + + _cheatList.Clear(); _currentFileName = string.Empty; Changes = false; diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 2cc8882d95..dd4ed20846 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -128,7 +128,7 @@ namespace BizHawk.Client.EmuHawk // If Cheat tool is loaded, restarting will restart the list too anyway if (!GlobalWin.Tools.Has()) { - Global.CheatList.NewList(GenerateDefaultCheatFilename()); + Global.CheatList.NewList(GenerateDefaultCheatFilename(), autosave: true); } _tools.ForEach(x => x.Restart());