N64 controller config - pass dependencies in
This commit is contained in:
parent
a58411efa0
commit
0b19090fc2
|
@ -2292,15 +2292,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void N64ControllerSettingsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var form = new N64ControllersSetup();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (Emulator is N64 n64)
|
||||
{
|
||||
FlagNeedsReboot();
|
||||
GlobalWin.OSD.AddMessage("Controller settings saved but a core reboot is required");
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalWin.OSD.AddMessage("Controller settings aborted");
|
||||
using var form = new N64ControllersSetup(this, n64.GetSyncSettings().Clone());
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Linq;
|
|||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common.ReflectionExtensions;
|
||||
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -21,11 +20,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public int ControllerNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _controllerNumber;
|
||||
}
|
||||
|
||||
get => _controllerNumber;
|
||||
set
|
||||
{
|
||||
_controllerNumber = value;
|
||||
|
@ -35,11 +30,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public bool IsConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
return EnabledCheckbox.Checked;
|
||||
}
|
||||
|
||||
get => EnabledCheckbox.Checked;
|
||||
set
|
||||
{
|
||||
EnabledCheckbox.Checked = value;
|
||||
|
|
|
@ -4,54 +4,49 @@ using System.Linq;
|
|||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class N64ControllersSetup : Form
|
||||
{
|
||||
private List<N64ControllerSettingControl> ControllerSettingControls
|
||||
{
|
||||
get
|
||||
{
|
||||
return Controls
|
||||
.OfType<N64ControllerSettingControl>()
|
||||
.OrderBy(n => n.ControllerNumber)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
private readonly MainForm _mainForm;
|
||||
private readonly N64SyncSettings _syncSettings;
|
||||
|
||||
public N64ControllersSetup()
|
||||
private List<N64ControllerSettingControl> ControllerSettingControls => Controls
|
||||
.OfType<N64ControllerSettingControl>()
|
||||
.OrderBy(n => n.ControllerNumber)
|
||||
.ToList();
|
||||
|
||||
public N64ControllersSetup(
|
||||
MainForm mainForm,
|
||||
N64SyncSettings syncSettings)
|
||||
{
|
||||
_mainForm = mainForm;
|
||||
_syncSettings = syncSettings;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void N64ControllersSetup_Load(object sender, EventArgs e)
|
||||
{
|
||||
var n64Settings = ((N64)Global.Emulator).GetSyncSettings();
|
||||
|
||||
ControllerSettingControls
|
||||
.ForEach(c =>
|
||||
{
|
||||
c.IsConnected = n64Settings.Controllers[c.ControllerNumber - 1].IsConnected;
|
||||
c.PakType = n64Settings.Controllers[c.ControllerNumber - 1].PakType;
|
||||
c.IsConnected = _syncSettings.Controllers[c.ControllerNumber - 1].IsConnected;
|
||||
c.PakType = _syncSettings.Controllers[c.ControllerNumber - 1].PakType;
|
||||
c.Refresh();
|
||||
});
|
||||
}
|
||||
|
||||
private void OkBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var n64 = (N64)Global.Emulator;
|
||||
var n64Settings = n64.GetSyncSettings();
|
||||
|
||||
ControllerSettingControls
|
||||
.ForEach(c =>
|
||||
{
|
||||
n64Settings.Controllers[c.ControllerNumber - 1].IsConnected = c.IsConnected;
|
||||
n64Settings.Controllers[c.ControllerNumber - 1].PakType = c.PakType;
|
||||
_syncSettings.Controllers[c.ControllerNumber - 1].IsConnected = c.IsConnected;
|
||||
_syncSettings.Controllers[c.ControllerNumber - 1].PakType = c.PakType;
|
||||
});
|
||||
|
||||
n64.PutSyncSettings(n64Settings);
|
||||
_mainForm.PutCoreSyncSettings(_syncSettings);
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
|
Loading…
Reference in New Issue