Save cheats even if the cheat dialog was never opened (for instance, if the cheat were added via a game genie dialog or lua)

This commit is contained in:
adelikat 2014-04-26 17:28:43 +00:00
parent f3766249bf
commit 4fc81991d7
2 changed files with 14 additions and 2 deletions

View File

@ -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;

View File

@ -128,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
// If Cheat tool is loaded, restarting will restart the list too anyway
if (!GlobalWin.Tools.Has<Cheats>())
{
Global.CheatList.NewList(GenerateDefaultCheatFilename());
Global.CheatList.NewList(GenerateDefaultCheatFilename(), autosave: true);
}
_tools.ForEach(x => x.Restart());