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)
{
using (var dlg = new PCEControllerConfig())
if (Emulator is PCEngine pce)
{
using var dlg = new PCEControllerConfig(this, pce.GetSyncSettings().Clone());
dlg.ShowDialog();
}
}
private void PceGraphicsSettingsMenuItem_Click(object sender, EventArgs e)
{
using var form = new PCEGraphicsConfig();
form.ShowDialog();
if (Emulator is PCEngine pce)
{
using var form = new PCEGraphicsConfig(this, pce.GetSettings().Clone());
form.ShowDialog();
}
}
private void PceBgViewerMenuItem_Click(object sender, EventArgs e)

View File

@ -1,30 +1,31 @@
using System;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.PCEngine;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
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();
}
private void PCEControllerConfig_Load(object sender, EventArgs e)
{
var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings();
_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;
ControllerPropertyGrid.SelectedObject = _syncSettings;
}
private void OkBtn_Click(object sender, EventArgs e)
{
GlobalWin.MainForm.PutCoreSyncSettings(_controllerSettings);
_mainForm.PutCoreSyncSettings(_syncSettings);
DialogResult = DialogResult.OK;
Close();
}

View File

@ -1,41 +1,42 @@
using System;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.PCEngine;
namespace BizHawk.Client.EmuHawk
{
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();
}
private void PCEGraphicsConfig_Load(object sender, EventArgs e)
{
PCEngine.PCESettings s = ((PCEngine)Global.Emulator).GetSettings();
DispOBJ1.Checked = s.ShowOBJ1;
DispBG1.Checked = s.ShowBG1;
DispOBJ2.Checked = s.ShowOBJ2;
DispBG2.Checked = s.ShowBG2;
NTSC_FirstLineNumeric.Value = s.Top_Line;
NTSC_LastLineNumeric.Value = s.Bottom_Line;
DispOBJ1.Checked = _settings.ShowOBJ1;
DispBG1.Checked = _settings.ShowBG1;
DispOBJ2.Checked = _settings.ShowOBJ2;
DispBG2.Checked = _settings.ShowBG2;
NTSC_FirstLineNumeric.Value = _settings.Top_Line;
NTSC_LastLineNumeric.Value = _settings.Bottom_Line;
}
private void Ok_Click(object sender, EventArgs e)
{
var pce = (PCEngine)Global.Emulator;
PCEngine.PCESettings s = pce.GetSettings();
s.ShowOBJ1 = DispOBJ1.Checked;
s.ShowBG1 = DispBG1.Checked;
s.ShowOBJ2 = DispOBJ2.Checked;
s.ShowBG2 = DispBG2.Checked;
s.Top_Line = (int)NTSC_FirstLineNumeric.Value;
s.Bottom_Line = (int)NTSC_LastLineNumeric.Value;
pce.PutSettings(s);
_settings.ShowOBJ1 = DispOBJ1.Checked;
_settings.ShowBG1 = DispBG1.Checked;
_settings.ShowOBJ2 = DispOBJ2.Checked;
_settings.ShowBG2 = DispBG2.Checked;
_settings.Top_Line = (int)NTSC_FirstLineNumeric.Value;
_settings.Bottom_Line = (int)NTSC_LastLineNumeric.Value;
_mainForm.PutCoreSettings(_settings);
Close();
}