diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.Designer.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.Designer.cs index f52aefb6fc..c78a658baa 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.Designer.cs @@ -28,52 +28,63 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PCEControllerConfig)); - this.CancelBtn = new System.Windows.Forms.Button(); - this.OkBtn = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // CancelBtn - // - this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CancelBtn.Location = new System.Drawing.Point(235, 145); - this.CancelBtn.Name = "CancelBtn"; - this.CancelBtn.Size = new System.Drawing.Size(60, 23); - this.CancelBtn.TabIndex = 3; - this.CancelBtn.Text = "&Cancel"; - this.CancelBtn.UseVisualStyleBackColor = true; - this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click); - // - // OkBtn - // - this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OkBtn.Location = new System.Drawing.Point(169, 145); - this.OkBtn.Name = "OkBtn"; - this.OkBtn.Size = new System.Drawing.Size(60, 23); - this.OkBtn.TabIndex = 2; - this.OkBtn.Text = "&OK"; - this.OkBtn.UseVisualStyleBackColor = true; - this.OkBtn.Click += new System.EventHandler(this.OkBtn_Click); - // - // PCEControllerConfig - // - this.AcceptButton = this.OkBtn; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.CancelBtn; - this.ClientSize = new System.Drawing.Size(307, 180); - this.Controls.Add(this.CancelBtn); - this.Controls.Add(this.OkBtn); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "PCEControllerConfig"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Controller Settings"; - this.Load += new System.EventHandler(this.PCEControllerConfig_Load); - this.ResumeLayout(false); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PCEControllerConfig)); + this.CancelBtn = new System.Windows.Forms.Button(); + this.OkBtn = new System.Windows.Forms.Button(); + this.ControllerPropertyGrid = new System.Windows.Forms.PropertyGrid(); + this.SuspendLayout(); + // + // CancelBtn + // + this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.CancelBtn.Location = new System.Drawing.Point(235, 203); + this.CancelBtn.Name = "CancelBtn"; + this.CancelBtn.Size = new System.Drawing.Size(60, 23); + this.CancelBtn.TabIndex = 3; + this.CancelBtn.Text = "&Cancel"; + this.CancelBtn.UseVisualStyleBackColor = true; + this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click); + // + // OkBtn + // + this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.OkBtn.Location = new System.Drawing.Point(169, 203); + this.OkBtn.Name = "OkBtn"; + this.OkBtn.Size = new System.Drawing.Size(60, 23); + this.OkBtn.TabIndex = 2; + this.OkBtn.Text = "&OK"; + this.OkBtn.UseVisualStyleBackColor = true; + this.OkBtn.Click += new System.EventHandler(this.OkBtn_Click); + // + // ControllerPropertyGrid + // + this.ControllerPropertyGrid.Location = new System.Drawing.Point(12, 12); + this.ControllerPropertyGrid.Name = "ControllerPropertyGrid"; + this.ControllerPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.Alphabetical; + this.ControllerPropertyGrid.Size = new System.Drawing.Size(283, 181); + this.ControllerPropertyGrid.TabIndex = 4; + this.ControllerPropertyGrid.ToolbarVisible = false; + // + // PCEControllerConfig + // + this.AcceptButton = this.OkBtn; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.CancelBtn; + this.ClientSize = new System.Drawing.Size(307, 238); + this.Controls.Add(this.ControllerPropertyGrid); + this.Controls.Add(this.CancelBtn); + this.Controls.Add(this.OkBtn); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "PCEControllerConfig"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Controller Settings"; + this.Load += new System.EventHandler(this.PCEControllerConfig_Load); + this.ResumeLayout(false); } @@ -81,5 +92,6 @@ private System.Windows.Forms.Button CancelBtn; private System.Windows.Forms.Button OkBtn; + private System.Windows.Forms.PropertyGrid ControllerPropertyGrid; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs index 0eec5d71e9..ba5af970fa 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs @@ -1,6 +1,4 @@ using System; -using System.Drawing; -using System.Linq; using System.Windows.Forms; using BizHawk.Emulation.Cores.PCEngine; @@ -10,6 +8,8 @@ namespace BizHawk.Client.EmuHawk { public partial class PCEControllerConfig : Form { + private PCEngine.PCESyncSettings _controllerSettings; + public PCEControllerConfig() { InitializeComponent(); @@ -18,36 +18,15 @@ namespace BizHawk.Client.EmuHawk private void PCEControllerConfig_Load(object sender, EventArgs e) { var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings(); - for (int i = 0; i < 5; i++) - { - Controls.Add(new Label - { - Text = "Controller " + (i + 1), - Location = new Point(15, 15 + (i * 25)) - }); - Controls.Add(new CheckBox - { - Text = "Connected", - Name = "Controller" + i, - Location = new Point(135, 15 + (i * 25)), - Checked = pceSettings.Controllers[i].IsConnected - }); - } + _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) { var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings(); - Controls - .OfType() - .OrderBy(c => c.Name) - .ToList() - .ForEach(c => - { - var index = int.Parse(c.Name.Replace("Controller", "")); - pceSettings.Controllers[index].IsConnected = c.Checked; - }); + pceSettings = _controllerSettings; GlobalWin.MainForm.PutCoreSyncSettings(pceSettings); DialogResult = DialogResult.OK; Close(); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs index 39e6d2dcaf..5a58dedea1 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISettable.cs @@ -69,8 +69,8 @@ namespace BizHawk.Emulation.Cores.PCEngine [DisplayName("Port 1 Device")] [Description("The type of controller plugged into the first controller port")] [TypeConverter(typeof(DescribableEnumConverter))] - public PceControllerType Port1 { get; set; } = PceControllerType.GamePad; - + public PceControllerType Port1 { get; set; } = PceControllerType.GamePad; + [DefaultValue(PceControllerType.Unplugged)] [DisplayName("Port 2 Device")] [Description("The type of controller plugged into the second controller port")] @@ -106,13 +106,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public PCESyncSettings Clone() { - var ret = new PCESyncSettings(); - for (int i = 0; i < Controllers.Length; i++) - { - ret.Controllers[i].IsConnected = Controllers[i].IsConnected; - } - - return ret; + return (PCESyncSettings)MemberwiseClone(); } public class ControllerSetting @@ -122,15 +116,11 @@ namespace BizHawk.Emulation.Cores.PCEngine public static bool NeedsReboot(PCESyncSettings x, PCESyncSettings y) { - for (int i = 0; i < x.Controllers.Length; i++) - { - if (x.Controllers[i].IsConnected != y.Controllers[i].IsConnected) - { - return true; - } - } - - return false; + return x.Port1 != y.Port1 + || x.Port2 != y.Port2 + || x.Port3 != y.Port3 + || x.Port4 != y.Port4 + || x.Port5 != y.Port5; } } }