diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index b80ed063db..2dddef676e 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -639,25 +639,7 @@ namespace BizHawk.Client.EmuHawk SetPauseStatusbarIcon(); } - public string GenerateDefaultCheatFilename() - { - var pathEntry = Global.Config.PathEntries[Global.Game.System, "Cheats"]; - - if (pathEntry == null) - { - pathEntry = Global.Config.PathEntries[Global.Game.System, "Base"]; - } - - var path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Game.System); - - var f = new FileInfo(path); - if (f.Directory != null && f.Directory.Exists == false) - { - f.Directory.Create(); - } - - return Path.Combine(path, PathManager.FilesystemSafeName(Global.Game) + ".cht"); - } + public void TakeScreenshotToClipboard() { @@ -1673,15 +1655,6 @@ namespace BizHawk.Client.EmuHawk } } - private void Cheats_Restart() - { - // If Cheat tool is loaded, restarting will restart the list too anyway - if (!GlobalWin.Tools.Has()) - { - Global.CheatList.NewList(GenerateDefaultCheatFilename()); - } - } - // Contains a mapping: profilename->exepath ; or null if the exe wasnt available private string SNES_Prepare(string profile) { @@ -3523,7 +3496,6 @@ namespace BizHawk.Client.EmuHawk } GlobalWin.Tools.Restart(); - Cheats_Restart(); if (Global.Config.LoadCheatFileByGame) { @@ -3703,7 +3675,6 @@ namespace BizHawk.Client.EmuHawk RewireSound(); ResetRewindBuffer(); - Cheats_Restart(); Text = "BizHawk" + (VersionInfo.INTERIM ? " (interim) " : String.Empty); HandlePlatformMenus(); _stateSlots.Clear(); diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index ac4ca2e706..ac91f8ac96 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -494,7 +494,7 @@ namespace BizHawk.Client.EmuHawk private void StartNewList() { - Global.CheatList.NewList(GlobalWin.MainForm.GenerateDefaultCheatFilename()); + Global.CheatList.NewList(ToolManager.GenerateDefaultCheatFilename()); UpdateDialog(); UpdateMessageLabel(); ToggleGameGenieButton(); diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index a42691b99b..df9d6dc8be 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using BizHawk.Client.Common; @@ -117,6 +118,12 @@ namespace BizHawk.Client.EmuHawk public void Restart() { + // If Cheat tool is loaded, restarting will restart the list too anyway + if (!GlobalWin.Tools.Has()) + { + Global.CheatList.NewList(GenerateDefaultCheatFilename()); + } + _tools.ForEach(x => x.Restart()); } @@ -195,7 +202,7 @@ namespace BizHawk.Client.EmuHawk { var tool = Activator.CreateInstance(typeof(T)); - //Add to the list and extract it, so it will be strongly typed as T + // Add to the list and extract it, so it will be strongly typed as T _tools.Add(tool as IToolForm); return _tools.FirstOrDefault(x => x is T); } @@ -242,7 +249,7 @@ namespace BizHawk.Client.EmuHawk } } - //Note: Referencing these properties creates an instance of the tool and persists it. They should be referenced by type if this is not desired + // Note: Referencing these properties creates an instance of the tool and persists it. They should be referenced by type if this is not desired #region Tools public RamWatch RamWatch @@ -452,5 +459,25 @@ namespace BizHawk.Client.EmuHawk } #endregion + + public static string GenerateDefaultCheatFilename() + { + var pathEntry = Global.Config.PathEntries[Global.Game.System, "Cheats"]; + + if (pathEntry == null) + { + pathEntry = Global.Config.PathEntries[Global.Game.System, "Base"]; + } + + var path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Game.System); + + var f = new FileInfo(path); + if (f.Directory != null && f.Directory.Exists == false) + { + f.Directory.Create(); + } + + return Path.Combine(path, PathManager.FilesystemSafeName(Global.Game) + ".cht"); + } } }