declare dependencies in PCE config dialogs

This commit is contained in:
adelikat 2019-12-16 17:06:29 -06:00
parent 89c87b0581
commit bdc8be2f6b
3 changed files with 37 additions and 31 deletions

View File

@ -1716,16 +1716,20 @@ namespace BizHawk.Client.EmuHawk
private void PceControllerSettingsMenuItem_Click(object sender, EventArgs e) private void PceControllerSettingsMenuItem_Click(object sender, EventArgs e)
{ {
using (var dlg = new PCEControllerConfig()) if (Emulator is PCEngine pce)
{ {
using var dlg = new PCEControllerConfig(this, pce.GetSyncSettings().Clone());
dlg.ShowDialog(); dlg.ShowDialog();
} }
} }
private void PceGraphicsSettingsMenuItem_Click(object sender, EventArgs e) private void PceGraphicsSettingsMenuItem_Click(object sender, EventArgs e)
{ {
using var form = new PCEGraphicsConfig(); if (Emulator is PCEngine pce)
form.ShowDialog(); {
using var form = new PCEGraphicsConfig(this, pce.GetSettings().Clone());
form.ShowDialog();
}
} }
private void PceBgViewerMenuItem_Click(object sender, EventArgs e) private void PceBgViewerMenuItem_Click(object sender, EventArgs e)

View File

@ -1,30 +1,31 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.PCEngine;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class PCEControllerConfig : Form public partial class PCEControllerConfig : Form
{ {
private PCEngine.PCESyncSettings _controllerSettings; private readonly MainForm _mainForm;
private readonly PCEngine.PCESyncSettings _syncSettings;
public PCEControllerConfig() public PCEControllerConfig(
MainForm mainForm,
PCEngine.PCESyncSettings syncSettings)
{ {
_mainForm = mainForm;
_syncSettings = syncSettings;
InitializeComponent(); InitializeComponent();
} }
private void PCEControllerConfig_Load(object sender, EventArgs e) private void PCEControllerConfig_Load(object sender, EventArgs e)
{ {
var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings(); ControllerPropertyGrid.SelectedObject = _syncSettings;
_controllerSettings = pceSettings; // Assumes only controller data is in sync settings! If there are ever more sync settings, this dialog should just become a general sync settings dialog (or both settings/sync settings)
ControllerPropertyGrid.SelectedObject = _controllerSettings;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
GlobalWin.MainForm.PutCoreSyncSettings(_controllerSettings); _mainForm.PutCoreSyncSettings(_syncSettings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }

View File

@ -1,41 +1,42 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.PCEngine;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class PCEGraphicsConfig : Form public partial class PCEGraphicsConfig : Form
{ {
public PCEGraphicsConfig() private readonly MainForm _mainForm;
private readonly PCEngine.PCESettings _settings;
public PCEGraphicsConfig(
MainForm mainForm,
PCEngine.PCESettings settings)
{ {
_mainForm = mainForm;
_settings = settings;
InitializeComponent(); InitializeComponent();
} }
private void PCEGraphicsConfig_Load(object sender, EventArgs e) private void PCEGraphicsConfig_Load(object sender, EventArgs e)
{ {
PCEngine.PCESettings s = ((PCEngine)Global.Emulator).GetSettings(); DispOBJ1.Checked = _settings.ShowOBJ1;
DispBG1.Checked = _settings.ShowBG1;
DispOBJ1.Checked = s.ShowOBJ1; DispOBJ2.Checked = _settings.ShowOBJ2;
DispBG1.Checked = s.ShowBG1; DispBG2.Checked = _settings.ShowBG2;
DispOBJ2.Checked = s.ShowOBJ2; NTSC_FirstLineNumeric.Value = _settings.Top_Line;
DispBG2.Checked = s.ShowBG2; NTSC_LastLineNumeric.Value = _settings.Bottom_Line;
NTSC_FirstLineNumeric.Value = s.Top_Line;
NTSC_LastLineNumeric.Value = s.Bottom_Line;
} }
private void Ok_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
var pce = (PCEngine)Global.Emulator; _settings.ShowOBJ1 = DispOBJ1.Checked;
PCEngine.PCESettings s = pce.GetSettings(); _settings.ShowBG1 = DispBG1.Checked;
s.ShowOBJ1 = DispOBJ1.Checked; _settings.ShowOBJ2 = DispOBJ2.Checked;
s.ShowBG1 = DispBG1.Checked; _settings.ShowBG2 = DispBG2.Checked;
s.ShowOBJ2 = DispOBJ2.Checked; _settings.Top_Line = (int)NTSC_FirstLineNumeric.Value;
s.ShowBG2 = DispBG2.Checked; _settings.Bottom_Line = (int)NTSC_LastLineNumeric.Value;
s.Top_Line = (int)NTSC_FirstLineNumeric.Value; _mainForm.PutCoreSettings(_settings);
s.Bottom_Line = (int)NTSC_LastLineNumeric.Value;
pce.PutSettings(s);
Close(); Close();
} }