inherit ToolFormBase for a few tools

This commit is contained in:
adelikat 2019-12-22 11:45:28 -06:00
parent 264b27475e
commit 3b60b08a11
2 changed files with 21 additions and 31 deletions

View File

@ -7,7 +7,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk 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 AddressColumnName = "Address";
private const string InstructionColumnName = "Instruction"; private const string InstructionColumnName = "Instruction";
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk
private void EngageDebugger() private void EngageDebugger()
{ {
_disassemblyLines.Clear(); _disassemblyLines.Clear();
GlobalWin.MainForm.OnPauseChanged += OnPauseChanged; MainForm.OnPauseChanged += OnPauseChanged;
CancelSeekBtn.Enabled = false; CancelSeekBtn.Enabled = false;
if (CanDisassemble) if (CanDisassemble)
{ {
@ -157,7 +157,7 @@ namespace BizHawk.Client.EmuHawk
private void DisengageDebugger() private void DisengageDebugger()
{ {
BreakPointControl1.Shutdown(); BreakPointControl1.Shutdown();
GlobalWin.MainForm.OnPauseChanged -= OnPauseChanged; MainForm.OnPauseChanged -= OnPauseChanged;
} }
public void DisableRegisterBox() public void DisableRegisterBox()
@ -196,7 +196,7 @@ namespace BizHawk.Client.EmuHawk
private void RunBtn_Click(object sender, EventArgs e) private void RunBtn_Click(object sender, EventArgs e)
{ {
GlobalWin.MainForm.UnpauseEmulator(); MainForm.UnpauseEmulator();
} }
private void StepIntoMenuItem_Click(object sender, EventArgs e) private void StepIntoMenuItem_Click(object sender, EventArgs e)

View File

@ -14,7 +14,7 @@ using BizHawk.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class MultiDiskBundler : Form, IToolFormAutoConfig public partial class MultiDiskBundler : ToolFormBase, IToolFormAutoConfig
{ {
private XElement _currentXml; private XElement _currentXml;
@ -31,11 +31,11 @@ namespace BizHawk.Client.EmuHawk
AddButton_Click(null, null); AddButton_Click(null, null);
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 directory = Path.GetDirectoryName(pieces[0]);
var filename = Path.ChangeExtension(pieces[1], ".xml"); var filename = Path.ChangeExtension(pieces[1], ".xml");
@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
NameBox.Text = Path.ChangeExtension(GlobalWin.MainForm.CurrentlyOpenRom, ".xml"); NameBox.Text = Path.ChangeExtension(MainForm.CurrentlyOpenRom, ".xml");
} }
if (SystemDropDown.Items.Contains(Emulator.SystemId)) if (SystemDropDown.Items.Contains(Emulator.SystemId))
@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk
SystemDropDown.SelectedItem = Emulator.SystemId; 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 UpdateValues()
{ {
} }
public void FastUpdate() public void FastUpdate()
{ {
} }
public void Restart() public void Restart()
{ {
} }
public bool AskSaveChanges() public bool AskSaveChanges() => true;
{
return true;
}
public bool UpdateBefore => true; public bool UpdateBefore => true;
@ -110,7 +104,7 @@ namespace BizHawk.Client.EmuHawk
Close(); Close();
var lra = new MainForm.LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = fileInfo.FullName } }; 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(); Recalculate();
} }
private IEnumerable<MultiDiskFileSelector> FileSelectors private IEnumerable<MultiDiskFileSelector> FileSelectors =>
{ FileSelectorPanel.Controls
get
{
return FileSelectorPanel.Controls
.OfType<GroupBox>() .OfType<GroupBox>()
.SelectMany(g => g.Controls.OfType<MultiDiskFileSelector>()); .SelectMany(g => g.Controls.OfType<MultiDiskFileSelector>());
}
}
private bool Recalculate() private bool Recalculate()
{ {
@ -189,17 +178,18 @@ namespace BizHawk.Client.EmuHawk
throw new Exception("Xml Filename can not be blank"); 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"); 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"); throw new Exception("System Id can not be blank");
} }
var basePath = Path.GetDirectoryName(name.Split('|').First()); var basePath = Path.GetDirectoryName(name.Split('|').First());
if (string.IsNullOrEmpty(basePath)) if (string.IsNullOrEmpty(basePath))
@ -238,7 +228,7 @@ namespace BizHawk.Client.EmuHawk
private void BrowseBtn_Click(object sender, EventArgs e) private void BrowseBtn_Click(object sender, EventArgs e)
{ {
string filename = ""; 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()) if (!Global.Game.IsNullInstance())
{ {