Remove the hacky Cheats_Restart() method and move the logic into the Restart method of ToolManager, also move over the generateDefaultCheatName to that object and make it static
This commit is contained in:
parent
d37796ab1c
commit
70078b24f2
|
@ -639,25 +639,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
SetPauseStatusbarIcon();
|
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()
|
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<Cheats>())
|
|
||||||
{
|
|
||||||
Global.CheatList.NewList(GenerateDefaultCheatFilename());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contains a mapping: profilename->exepath ; or null if the exe wasnt available
|
// Contains a mapping: profilename->exepath ; or null if the exe wasnt available
|
||||||
private string SNES_Prepare(string profile)
|
private string SNES_Prepare(string profile)
|
||||||
{
|
{
|
||||||
|
@ -3523,7 +3496,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalWin.Tools.Restart();
|
GlobalWin.Tools.Restart();
|
||||||
Cheats_Restart();
|
|
||||||
|
|
||||||
if (Global.Config.LoadCheatFileByGame)
|
if (Global.Config.LoadCheatFileByGame)
|
||||||
{
|
{
|
||||||
|
@ -3703,7 +3675,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
RewireSound();
|
RewireSound();
|
||||||
ResetRewindBuffer();
|
ResetRewindBuffer();
|
||||||
Cheats_Restart();
|
|
||||||
Text = "BizHawk" + (VersionInfo.INTERIM ? " (interim) " : String.Empty);
|
Text = "BizHawk" + (VersionInfo.INTERIM ? " (interim) " : String.Empty);
|
||||||
HandlePlatformMenus();
|
HandlePlatformMenus();
|
||||||
_stateSlots.Clear();
|
_stateSlots.Clear();
|
||||||
|
|
|
@ -494,7 +494,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void StartNewList()
|
private void StartNewList()
|
||||||
{
|
{
|
||||||
Global.CheatList.NewList(GlobalWin.MainForm.GenerateDefaultCheatFilename());
|
Global.CheatList.NewList(ToolManager.GenerateDefaultCheatFilename());
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
ToggleGameGenieButton();
|
ToggleGameGenieButton();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
|
||||||
|
@ -117,6 +118,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
|
// If Cheat tool is loaded, restarting will restart the list too anyway
|
||||||
|
if (!GlobalWin.Tools.Has<Cheats>())
|
||||||
|
{
|
||||||
|
Global.CheatList.NewList(GenerateDefaultCheatFilename());
|
||||||
|
}
|
||||||
|
|
||||||
_tools.ForEach(x => x.Restart());
|
_tools.ForEach(x => x.Restart());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +202,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var tool = Activator.CreateInstance(typeof(T));
|
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);
|
_tools.Add(tool as IToolForm);
|
||||||
return _tools.FirstOrDefault(x => x is T);
|
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
|
#region Tools
|
||||||
|
|
||||||
public RamWatch RamWatch
|
public RamWatch RamWatch
|
||||||
|
@ -452,5 +459,25 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue