atari7800 settings dialog - set up a pattern of constructor declaring dependencies in the constructor, rather than relying on Global variables. We should be doing this for other dialogs (and in general)

This commit is contained in:
adelikat 2019-12-13 16:01:04 -06:00
parent 2c66e3043c
commit 92768858f7
3 changed files with 21 additions and 9 deletions

View File

@ -23,6 +23,7 @@ using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Emulation.Cores.Computers.AppleII;
using BizHawk.Client.ApiHawk;
using BizHawk.Common;
using BizHawk.Emulation.Cores.Atari.A7800Hawk;
using BizHawk.Emulation.Cores.Computers.Commodore64;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
@ -2038,8 +2039,11 @@ namespace BizHawk.Client.EmuHawk
private void A7800ControllerSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
using var form = new A7800ControllerSettings();
form.ShowDialog();
if (Emulator is A7800Hawk atari7800Hawk)
{
using var form = new A7800ControllerSettings(this, atari7800Hawk.GetSyncSettings().Clone());
form.ShowDialog();
}
}
private void A7800FilterSettingsToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -727,6 +727,11 @@ namespace BizHawk.Client.EmuHawk
#region Public Methods
public void AddOnScreenMessage(string message)
{
GlobalWin.OSD.AddMessage(message);
}
public void ClearHolds()
{
Global.StickyXORAdapter.ClearStickies();
@ -741,7 +746,7 @@ namespace BizHawk.Client.EmuHawk
public void FlagNeedsReboot()
{
RebootStatusBarIcon.Visible = true;
GlobalWin.OSD.AddMessage("Core reboot needed for this setting");
AddOnScreenMessage("Core reboot needed for this setting");
}
/// <summary>

View File

@ -9,17 +9,20 @@ namespace BizHawk.Client.EmuHawk
{
public partial class A7800ControllerSettings : Form
{
private A7800Hawk.A7800SyncSettings _syncSettings;
private readonly MainForm _mainForm;
private readonly A7800Hawk.A7800SyncSettings _syncSettings;
public A7800ControllerSettings()
public A7800ControllerSettings(
MainForm mainForm,
A7800Hawk.A7800SyncSettings syncSettings)
{
_mainForm = mainForm;
_syncSettings = syncSettings;
InitializeComponent();
}
private void IntvControllerSettings_Load(object sender, EventArgs e)
{
_syncSettings = ((A7800Hawk)Global.Emulator).GetSyncSettings().Clone();
var possibleControllers = A7800HawkControllerDeck.ValidControllerTypes.Select(t => t.Key);
foreach (var val in possibleControllers)
@ -43,7 +46,7 @@ namespace BizHawk.Client.EmuHawk
_syncSettings.Port1 = Port1ComboBox.SelectedItem.ToString();
_syncSettings.Port2 = Port2ComboBox.SelectedItem.ToString();
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
_mainForm.PutCoreSyncSettings(_syncSettings);
}
DialogResult = DialogResult.OK;
@ -52,7 +55,7 @@ namespace BizHawk.Client.EmuHawk
private void CancelBtn_Click(object sender, EventArgs e)
{
GlobalWin.OSD.AddMessage("Controller settings aborted");
_mainForm.AddOnScreenMessage("Controller settings aborted");
DialogResult = DialogResult.Cancel;
Close();
}