From 8743f11ba9cc6778bbe7c16b9a81020f71df9022 Mon Sep 17 00:00:00 2001 From: Souryo Date: Sun, 21 Feb 2016 23:02:42 -0500 Subject: [PATCH] Input: Fixed crash in config dialog caused by localization changes --- GUI.NET/Config/InputInfo.cs | 6 ++++++ GUI.NET/Forms/Config/frmInputConfig.cs | 19 +++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/GUI.NET/Config/InputInfo.cs b/GUI.NET/Config/InputInfo.cs index a1a3213e..2e266b28 100644 --- a/GUI.NET/Config/InputInfo.cs +++ b/GUI.NET/Config/InputInfo.cs @@ -106,6 +106,12 @@ namespace Mesen.GUI.Config public InteropEmu.ExpansionPortDevice ExpansionPortDevice = InteropEmu.ExpansionPortDevice.None; public bool UseFourScore = false; + [NonSerialized] + public InteropEmu.ControllerType ControllerType1; + public InteropEmu.ControllerType ControllerType2; + public InteropEmu.ControllerType ControllerType3; + public InteropEmu.ControllerType ControllerType4; + public List Controllers = new List(); public void InitializeDefaults() diff --git a/GUI.NET/Forms/Config/frmInputConfig.cs b/GUI.NET/Forms/Config/frmInputConfig.cs index 94f55789..7875713f 100644 --- a/GUI.NET/Forms/Config/frmInputConfig.cs +++ b/GUI.NET/Forms/Config/frmInputConfig.cs @@ -22,6 +22,11 @@ namespace Mesen.GUI.Forms.Config AddBinding("ExpansionPortDevice", cboExpansionPort); AddBinding("ConsoleType", cboConsoleType); AddBinding("UseFourScore", chkFourScore); + + AddBinding("ControllerType1", cboPlayer1); + AddBinding("ControllerType2", cboPlayer2); + AddBinding("ControllerType3", cboPlayer3); + AddBinding("ControllerType4", cboPlayer4); } protected override void AfterUpdateUI() @@ -29,12 +34,6 @@ namespace Mesen.GUI.Forms.Config base.AfterUpdateUI(); this.UpdateInterface(); - - InputInfo inputInfo = (InputInfo)Entity; - cboPlayer1.SelectedItem = ResourceHelper.GetEnumText(inputInfo.Controllers[0].ControllerType); - cboPlayer2.SelectedItem = ResourceHelper.GetEnumText(inputInfo.Controllers[1].ControllerType); - cboPlayer3.SelectedItem = ResourceHelper.GetEnumText(inputInfo.Controllers[2].ControllerType); - cboPlayer4.SelectedItem = ResourceHelper.GetEnumText(inputInfo.Controllers[3].ControllerType); } private void UpdateAvailableControllerTypes() @@ -73,10 +72,10 @@ namespace Mesen.GUI.Forms.Config { InputInfo inputInfo = (InputInfo)Entity; - inputInfo.Controllers[0].ControllerType = (InteropEmu.ControllerType)Enum.Parse(typeof(InteropEmu.ControllerType), cboPlayer1.SelectedItem.ToString()); - inputInfo.Controllers[1].ControllerType = (InteropEmu.ControllerType)Enum.Parse(typeof(InteropEmu.ControllerType), cboPlayer2.SelectedItem.ToString()); - inputInfo.Controllers[2].ControllerType = (InteropEmu.ControllerType)Enum.Parse(typeof(InteropEmu.ControllerType), cboPlayer3.SelectedItem.ToString()); - inputInfo.Controllers[3].ControllerType = (InteropEmu.ControllerType)Enum.Parse(typeof(InteropEmu.ControllerType), cboPlayer4.SelectedItem.ToString()); + inputInfo.Controllers[0].ControllerType = inputInfo.ControllerType1; + inputInfo.Controllers[1].ControllerType = inputInfo.ControllerType2; + inputInfo.Controllers[2].ControllerType = inputInfo.ControllerType3; + inputInfo.Controllers[3].ControllerType = inputInfo.ControllerType4; InputInfo.ApplyConfig(); }