From 3b60b08a114cfaee233b2a905eee67f0310cbf02 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 22 Dec 2019 11:45:28 -0600 Subject: [PATCH] inherit ToolFormBase for a few tools --- .../tools/Debugger/GenericDebugger.cs | 8 ++-- .../MultiDiskBundler/MultiDiskBundler.cs | 44 +++++++------------ 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs index 246e8e6fc1..1b9a1c6123 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs @@ -7,7 +7,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { - public partial class GenericDebugger : Form, IToolFormAutoConfig, IControlMainform + public partial class GenericDebugger : ToolFormBase, IToolFormAutoConfig, IControlMainform { private const string AddressColumnName = "Address"; private const string InstructionColumnName = "Instruction"; @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk private void EngageDebugger() { _disassemblyLines.Clear(); - GlobalWin.MainForm.OnPauseChanged += OnPauseChanged; + MainForm.OnPauseChanged += OnPauseChanged; CancelSeekBtn.Enabled = false; if (CanDisassemble) { @@ -157,7 +157,7 @@ namespace BizHawk.Client.EmuHawk private void DisengageDebugger() { BreakPointControl1.Shutdown(); - GlobalWin.MainForm.OnPauseChanged -= OnPauseChanged; + MainForm.OnPauseChanged -= OnPauseChanged; } public void DisableRegisterBox() @@ -196,7 +196,7 @@ namespace BizHawk.Client.EmuHawk private void RunBtn_Click(object sender, EventArgs e) { - GlobalWin.MainForm.UnpauseEmulator(); + MainForm.UnpauseEmulator(); } private void StepIntoMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs index c1aee6eb9a..1de2f1e6bb 100644 --- a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs +++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs @@ -14,7 +14,7 @@ using BizHawk.Common; namespace BizHawk.Client.EmuHawk { - public partial class MultiDiskBundler : Form, IToolFormAutoConfig + public partial class MultiDiskBundler : ToolFormBase, IToolFormAutoConfig { private XElement _currentXml; @@ -31,11 +31,11 @@ namespace BizHawk.Client.EmuHawk AddButton_Click(null, null); AddButton_Click(null, null); - if (!Global.Game.IsNullInstance() && !GlobalWin.MainForm.CurrentlyOpenRom.EndsWith(".xml")) + if (!Global.Game.IsNullInstance() && !MainForm.CurrentlyOpenRom.EndsWith(".xml")) { - if (GlobalWin.MainForm.CurrentlyOpenRom.Contains("|")) + if (MainForm.CurrentlyOpenRom.Contains("|")) { - var pieces = GlobalWin.MainForm.CurrentlyOpenRom.Split('|'); + var pieces = MainForm.CurrentlyOpenRom.Split('|'); var directory = Path.GetDirectoryName(pieces[0]); var filename = Path.ChangeExtension(pieces[1], ".xml"); @@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk } else { - NameBox.Text = Path.ChangeExtension(GlobalWin.MainForm.CurrentlyOpenRom, ".xml"); + NameBox.Text = Path.ChangeExtension(MainForm.CurrentlyOpenRom, ".xml"); } if (SystemDropDown.Items.Contains(Emulator.SystemId)) @@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk SystemDropDown.SelectedItem = Emulator.SystemId; } - FileSelectors.First().SetName(GlobalWin.MainForm.CurrentlyOpenRom); + FileSelectors.First().SetName(MainForm.CurrentlyOpenRom); } } @@ -62,23 +62,17 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - } public void FastUpdate() { - } public void Restart() { - } - public bool AskSaveChanges() - { - return true; - } + public bool AskSaveChanges() => true; public bool UpdateBefore => true; @@ -110,7 +104,7 @@ namespace BizHawk.Client.EmuHawk Close(); var lra = new MainForm.LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = fileInfo.FullName } }; - GlobalWin.MainForm.LoadRom(fileInfo.FullName, lra); + MainForm.LoadRom(fileInfo.FullName, lra); } } @@ -166,15 +160,10 @@ namespace BizHawk.Client.EmuHawk Recalculate(); } - private IEnumerable FileSelectors - { - get - { - return FileSelectorPanel.Controls - .OfType() - .SelectMany(g => g.Controls.OfType()); - } - } + private IEnumerable FileSelectors => + FileSelectorPanel.Controls + .OfType() + .SelectMany(g => g.Controls.OfType()); private bool Recalculate() { @@ -189,17 +178,18 @@ namespace BizHawk.Client.EmuHawk throw new Exception("Xml Filename can not be blank"); } - if (names.Any(n => string.IsNullOrWhiteSpace(n))) + if (names.Any(string.IsNullOrWhiteSpace)) { throw new Exception("Rom Names can not be blank"); } - var system = SystemDropDown.SelectedItem.ToString(); + var system = SystemDropDown.SelectedItem?.ToString(); - if (system == null) + if (string.IsNullOrWhiteSpace(system)) { throw new Exception("System Id can not be blank"); } + var basePath = Path.GetDirectoryName(name.Split('|').First()); if (string.IsNullOrEmpty(basePath)) @@ -238,7 +228,7 @@ namespace BizHawk.Client.EmuHawk private void BrowseBtn_Click(object sender, EventArgs e) { string filename = ""; - string initialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MultiDiskBundlesFragment, "Global_NULL"); + string initialDirectory = PathManager.MakeAbsolutePath(Config.PathEntries.MultiDiskBundlesFragment, "Global_NULL"); if (!Global.Game.IsNullInstance()) {