From 94bd987a7315a2118be37857e1943bf1e6944f9d Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 13 Dec 2014 22:57:51 +0000 Subject: [PATCH] Convert Cheats to EmuatorServices --- .../tools/Cheats/Cheats.Designer.cs | 2 +- BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs index 0280bce8b9..8ac9ff9804 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs @@ -757,7 +757,7 @@ this.MinimumSize = new System.Drawing.Size(285, 384); this.Name = "Cheats"; this.Text = "Cheats"; - this.Load += new System.EventHandler(this.NewCheatForm_Load); + this.Load += new System.EventHandler(this.Cheats_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.NewCheatForm_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.NewCheatForm_DragEnter); this.CheatsContextMenu.ResumeLayout(false); diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index 94a8d3c987..fc2e20e6ee 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -17,9 +17,11 @@ using BizHawk.Client.EmuHawk.WinFormExtensions; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(IMemoryDomains))] public partial class Cheats : Form, IToolForm { public IDictionary EmulatorServices { private get; set; } + private IMemoryDomains Core { get { return (IMemoryDomains)EmulatorServices[typeof(IMemoryDomains)]; } } public const string NAME = "NamesColumn"; public const string ADDRESS = "AddressColumn"; @@ -49,15 +51,11 @@ namespace BizHawk.Client.EmuHawk private string _sortedColumn = string.Empty; private bool _sortReverse; - private readonly IMemoryDomains Core; - public bool UpdateBefore { get { return false; } } public Cheats() { - Core = (IMemoryDomains)Global.Emulator; // Cast is intentional in order to get a cast excpetion rather than a null reference exception later InitializeComponent(); - CheatEditor.Core = Core; Closing += (o, e) => { @@ -92,11 +90,7 @@ namespace BizHawk.Client.EmuHawk public void Restart() { - if (!Global.Emulator.HasMemoryDomains()) - { - Close(); - } - + CheatEditor.Core = Core; StartNewList(); } @@ -188,8 +182,9 @@ namespace BizHawk.Client.EmuHawk return file != null && Global.CheatList.SaveFile(file.FullName); } - private void NewCheatForm_Load(object sender, EventArgs e) + private void Cheats_Load(object sender, EventArgs e) { + CheatEditor.Core = Core; LoadConfigSettings(); ToggleGameGenieButton(); CheatEditor.SetAddEvent(AddCheat);