refactor UpdateCheatRelatedTools to be a ToolManager method

This commit is contained in:
adelikat 2019-12-22 12:47:34 -06:00
parent 68e45d6108
commit 1c57622032
4 changed files with 28 additions and 26 deletions

View File

@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk
PlayRecordStatusButton.Visible = false;
AVIStatusLabel.Visible = false;
SetPauseStatusBarIcon();
ToolFormBase.UpdateCheatRelatedTools(null, null);
Tools.UpdateCheatRelatedTools(null, null);
RebootStatusBarIcon.Visible = false;
UpdateNotification.Visible = false;
_statusBarDiskLightOnImage = Properties.Resources.LightOn;
@ -231,8 +231,11 @@ namespace BizHawk.Client.EmuHawk
_throttle = new Throttle();
var comm = CreateCoreComm();
Emulator = new NullEmulator(comm);
GlobalWin.Tools = new ToolManager(this, Config, Emulator);
Global.CheatList = new CheatCollection();
CheatList.Changed += ToolFormBase.UpdateCheatRelatedTools;
CheatList.Changed += Tools.UpdateCheatRelatedTools;
UpdateStatusSlots();
UpdateKeyPriorityIcon();
@ -330,9 +333,7 @@ namespace BizHawk.Client.EmuHawk
Input.Initialize();
InitControls();
var comm = CreateCoreComm();
CoreFileProvider.SyncCoreCommInputSignals(comm);
Emulator = new NullEmulator(comm);
Global.ActiveController = new Controller(NullController.Instance.Definition);
Global.AutoFireController = _autofireNullControls;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
@ -356,7 +357,6 @@ namespace BizHawk.Client.EmuHawk
Sound.StartSound();
InputManager.RewireInputChain();
GlobalWin.Tools = new ToolManager(this, Config, Emulator);
RewireSound();
// Workaround for windows, location is -32000 when minimized, if they close it during this time, that's what gets saved
@ -3856,7 +3856,7 @@ namespace BizHawk.Client.EmuHawk
Global.AutofireStickyXORAdapter.ClearStickies();
RewireSound();
ToolFormBase.UpdateCheatRelatedTools(null, null);
Tools.UpdateCheatRelatedTools(null, null);
if (Config.AutoLoadLastSaveSlot && _stateSlots.HasSlot(Config.SaveSlot))
{
LoadQuickSave($"QuickSave{Config.SaveSlot}");
@ -4001,7 +4001,7 @@ namespace BizHawk.Client.EmuHawk
Tools.Restart(Emulator);
RewireSound();
ClearHolds();
ToolFormBase.UpdateCheatRelatedTools(null, null);
Tools.UpdateCheatRelatedTools(null, null);
PauseOnFrame = null;
CurrentlyOpenRom = null;
CurrentlyOpenRomArgs = null;

View File

@ -1622,7 +1622,7 @@ namespace BizHawk.Client.EmuHawk
}
}
UpdateCheatRelatedTools(null, null);
Tools.UpdateCheatRelatedTools(null, null);
MemoryViewerBox.Refresh();
}

View File

@ -3,7 +3,6 @@ using System.IO;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions;
@ -79,23 +78,6 @@ namespace BizHawk.Client.EmuHawk
return SaveFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch");
}
public static void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e)
{
if (Global.Emulator.HasMemoryDomains())
{
GlobalWin.Tools.UpdateValues<RamWatch>();
GlobalWin.Tools.UpdateValues<RamSearch>();
GlobalWin.Tools.UpdateValues<HexEditor>();
if (GlobalWin.Tools.Has<Cheats>())
{
GlobalWin.Tools.Cheats.UpdateDialog();
}
GlobalWin.MainForm.UpdateCheatStatus();
}
}
public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size)
{
Tools.Load<HexEditor>();

View File

@ -14,6 +14,7 @@ using BizHawk.Client.EmuHawk.CoreExtensions;
using BizHawk.Common;
using BizHawk.Common.ReflectionExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
namespace BizHawk.Client.EmuHawk
{
@ -859,5 +860,24 @@ namespace BizHawk.Client.EmuHawk
return Path.Combine(path, $"{PathManager.FilesystemSafeName(Global.Game)}.cht");
}
public void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e)
{
if (!_emulator.HasMemoryDomains())
{
return;
}
UpdateValues<RamWatch>();
UpdateValues<RamSearch>();
UpdateValues<HexEditor>();
if (Has<Cheats>())
{
Cheats.UpdateDialog();
}
_owner.UpdateCheatStatus();
}
}
}