From cb88230d982ec8b239586851388d94b37f95d793 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 7 Nov 2012 14:31:12 +0000 Subject: [PATCH] New Controller Config - more robust saving logic, some UI cleanup, delete now unused gamepad config objects --- .../BizHawk.MultiClient.csproj | 10 +- .../config/ControllerConfig.Designer.cs | 161 +++++++++++------- .../config/ControllerConfig.cs | 48 +++--- .../ControllerConfig/GamepadConfigPanel.cs | 60 ------- .../ControllerConfig/NESConsoleButtons.cs | 34 ++-- .../config/ControllerConfig/NESGamePad.cs | 40 ----- 6 files changed, 138 insertions(+), 215 deletions(-) delete mode 100644 BizHawk.MultiClient/config/ControllerConfig/GamepadConfigPanel.cs delete mode 100644 BizHawk.MultiClient/config/ControllerConfig/NESGamePad.cs diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 046f708f9d..32d0bd4572 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -175,15 +175,7 @@ ControllerConfigPanel.cs - - Component - - - Component - - - Component - + Form diff --git a/BizHawk.MultiClient/config/ControllerConfig.Designer.cs b/BizHawk.MultiClient/config/ControllerConfig.Designer.cs index 997c944cba..6ac671541c 100644 --- a/BizHawk.MultiClient/config/ControllerConfig.Designer.cs +++ b/BizHawk.MultiClient/config/ControllerConfig.Designer.cs @@ -32,22 +32,14 @@ this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabControl2 = new System.Windows.Forms.TabControl(); this.tabPage13 = new System.Windows.Forms.TabPage(); - this.NESController1Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage14 = new System.Windows.Forms.TabPage(); - this.NESController2Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage15 = new System.Windows.Forms.TabPage(); - this.NESController3Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage16 = new System.Windows.Forms.TabPage(); - this.NESController4Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage17 = new System.Windows.Forms.TabPage(); this.tabPage18 = new System.Windows.Forms.TabPage(); - this.NESAutofire1Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage19 = new System.Windows.Forms.TabPage(); - this.NESAutofire2Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage20 = new System.Windows.Forms.TabPage(); - this.NESAutofire3Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage21 = new System.Windows.Forms.TabPage(); - this.NESAutofire4Panel = new BizHawk.MultiClient.ControllerConfigPanel(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabControl3 = new System.Windows.Forms.TabControl(); this.tabPage22 = new System.Windows.Forms.TabPage(); @@ -103,6 +95,16 @@ this.tabPage8 = new System.Windows.Forms.TabPage(); this.Cancel = new System.Windows.Forms.Button(); this.OK = new System.Windows.Forms.Button(); + this.ControllerImage = new System.Windows.Forms.PictureBox(); + this.NESController1Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESController2Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESController3Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESController4Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESAutofire1Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESAutofire2Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESAutofire3Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.NESAutofire4Panel = new BizHawk.MultiClient.ControllerConfigPanel(); + this.label38 = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabControl2.SuspendLayout(); @@ -128,6 +130,7 @@ this.tabControl7.SuspendLayout(); this.tabPage7.SuspendLayout(); this.tabControl8.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ControllerImage)).BeginInit(); this.SuspendLayout(); // // tabControl1 @@ -152,6 +155,7 @@ // // tabPage1 // + this.tabPage1.Controls.Add(this.ControllerImage); this.tabPage1.Controls.Add(this.tabControl2); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; @@ -191,13 +195,6 @@ this.tabPage13.Text = "Pad 1"; this.tabPage13.UseVisualStyleBackColor = true; // - // NESController1Panel - // - this.NESController1Panel.Location = new System.Drawing.Point(10, 10); - this.NESController1Panel.Name = "NESController1Panel"; - this.NESController1Panel.Size = new System.Drawing.Size(392, 332); - this.NESController1Panel.TabIndex = 0; - // // tabPage14 // this.tabPage14.Controls.Add(this.NESController2Panel); @@ -209,13 +206,6 @@ this.tabPage14.Text = "Pad 2"; this.tabPage14.UseVisualStyleBackColor = true; // - // NESController2Panel - // - this.NESController2Panel.Location = new System.Drawing.Point(10, 10); - this.NESController2Panel.Name = "NESController2Panel"; - this.NESController2Panel.Size = new System.Drawing.Size(392, 332); - this.NESController2Panel.TabIndex = 0; - // // tabPage15 // this.tabPage15.Controls.Add(this.NESController3Panel); @@ -226,13 +216,6 @@ this.tabPage15.Text = "Pad 3"; this.tabPage15.UseVisualStyleBackColor = true; // - // NESController3Panel - // - this.NESController3Panel.Location = new System.Drawing.Point(10, 10); - this.NESController3Panel.Name = "NESController3Panel"; - this.NESController3Panel.Size = new System.Drawing.Size(392, 332); - this.NESController3Panel.TabIndex = 0; - // // tabPage16 // this.tabPage16.Controls.Add(this.NESController4Panel); @@ -243,13 +226,6 @@ this.tabPage16.Text = "Pad 4"; this.tabPage16.UseVisualStyleBackColor = true; // - // NESController4Panel - // - this.NESController4Panel.Location = new System.Drawing.Point(10, 10); - this.NESController4Panel.Name = "NESController4Panel"; - this.NESController4Panel.Size = new System.Drawing.Size(392, 332); - this.NESController4Panel.TabIndex = 0; - // // tabPage17 // this.tabPage17.Location = new System.Drawing.Point(4, 22); @@ -269,13 +245,6 @@ this.tabPage18.Text = "Autofire 1"; this.tabPage18.UseVisualStyleBackColor = true; // - // NESAutofire1Panel - // - this.NESAutofire1Panel.Location = new System.Drawing.Point(10, 10); - this.NESAutofire1Panel.Name = "NESAutofire1Panel"; - this.NESAutofire1Panel.Size = new System.Drawing.Size(392, 332); - this.NESAutofire1Panel.TabIndex = 0; - // // tabPage19 // this.tabPage19.Controls.Add(this.NESAutofire2Panel); @@ -286,13 +255,6 @@ this.tabPage19.Text = "Autofire 2"; this.tabPage19.UseVisualStyleBackColor = true; // - // NESAutofire2Panel - // - this.NESAutofire2Panel.Location = new System.Drawing.Point(10, 10); - this.NESAutofire2Panel.Name = "NESAutofire2Panel"; - this.NESAutofire2Panel.Size = new System.Drawing.Size(392, 332); - this.NESAutofire2Panel.TabIndex = 0; - // // tabPage20 // this.tabPage20.Controls.Add(this.NESAutofire3Panel); @@ -303,13 +265,6 @@ this.tabPage20.Text = "Autofire 3"; this.tabPage20.UseVisualStyleBackColor = true; // - // NESAutofire3Panel - // - this.NESAutofire3Panel.Location = new System.Drawing.Point(10, 10); - this.NESAutofire3Panel.Name = "NESAutofire3Panel"; - this.NESAutofire3Panel.Size = new System.Drawing.Size(392, 332); - this.NESAutofire3Panel.TabIndex = 0; - // // tabPage21 // this.tabPage21.Controls.Add(this.NESAutofire4Panel); @@ -320,13 +275,6 @@ this.tabPage21.Text = "Autofire 4"; this.tabPage21.UseVisualStyleBackColor = true; // - // NESAutofire4Panel - // - this.NESAutofire4Panel.Location = new System.Drawing.Point(10, 10); - this.NESAutofire4Panel.Name = "NESAutofire4Panel"; - this.NESAutofire4Panel.Size = new System.Drawing.Size(392, 332); - this.NESAutofire4Panel.TabIndex = 0; - // // tabPage2 // this.tabPage2.Controls.Add(this.tabControl3); @@ -891,6 +839,86 @@ this.OK.UseVisualStyleBackColor = true; this.OK.Click += new System.EventHandler(this.OK_Click); // + // ControllerImage + // + this.ControllerImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ControllerImage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.ControllerImage.Image = global::BizHawk.MultiClient.Properties.Resources.NES_Controller; + this.ControllerImage.Location = new System.Drawing.Point(485, 37); + this.ControllerImage.Name = "ControllerImage"; + this.ControllerImage.Size = new System.Drawing.Size(284, 125); + this.ControllerImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.ControllerImage.TabIndex = 4; + this.ControllerImage.TabStop = false; + // + // NESController1Panel + // + this.NESController1Panel.Location = new System.Drawing.Point(10, 10); + this.NESController1Panel.Name = "NESController1Panel"; + this.NESController1Panel.Size = new System.Drawing.Size(392, 332); + this.NESController1Panel.TabIndex = 0; + // + // NESController2Panel + // + this.NESController2Panel.Location = new System.Drawing.Point(10, 10); + this.NESController2Panel.Name = "NESController2Panel"; + this.NESController2Panel.Size = new System.Drawing.Size(392, 332); + this.NESController2Panel.TabIndex = 0; + // + // NESController3Panel + // + this.NESController3Panel.Location = new System.Drawing.Point(10, 10); + this.NESController3Panel.Name = "NESController3Panel"; + this.NESController3Panel.Size = new System.Drawing.Size(392, 332); + this.NESController3Panel.TabIndex = 0; + // + // NESController4Panel + // + this.NESController4Panel.Location = new System.Drawing.Point(10, 10); + this.NESController4Panel.Name = "NESController4Panel"; + this.NESController4Panel.Size = new System.Drawing.Size(392, 332); + this.NESController4Panel.TabIndex = 0; + // + // NESAutofire1Panel + // + this.NESAutofire1Panel.Location = new System.Drawing.Point(10, 10); + this.NESAutofire1Panel.Name = "NESAutofire1Panel"; + this.NESAutofire1Panel.Size = new System.Drawing.Size(392, 332); + this.NESAutofire1Panel.TabIndex = 0; + // + // NESAutofire2Panel + // + this.NESAutofire2Panel.Location = new System.Drawing.Point(10, 10); + this.NESAutofire2Panel.Name = "NESAutofire2Panel"; + this.NESAutofire2Panel.Size = new System.Drawing.Size(392, 332); + this.NESAutofire2Panel.TabIndex = 0; + // + // NESAutofire3Panel + // + this.NESAutofire3Panel.Location = new System.Drawing.Point(10, 10); + this.NESAutofire3Panel.Name = "NESAutofire3Panel"; + this.NESAutofire3Panel.Size = new System.Drawing.Size(392, 332); + this.NESAutofire3Panel.TabIndex = 0; + // + // NESAutofire4Panel + // + this.NESAutofire4Panel.Location = new System.Drawing.Point(10, 10); + this.NESAutofire4Panel.Name = "NESAutofire4Panel"; + this.NESAutofire4Panel.Size = new System.Drawing.Size(392, 332); + this.NESAutofire4Panel.TabIndex = 0; + // + // label38 + // + this.label38.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label38.AutoSize = true; + this.label38.Location = new System.Drawing.Point(13, 483); + this.label38.Name = "label38"; + this.label38.Size = new System.Drawing.Size(153, 13); + this.label38.TabIndex = 10; + this.label38.Text = "* Escape clears a key mapping"; + // // ControllerConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -898,6 +926,7 @@ this.CancelButton = this.Cancel; this.ClientSize = new System.Drawing.Size(823, 513); this.ControlBox = false; + this.Controls.Add(this.label38); this.Controls.Add(this.OK); this.Controls.Add(this.Cancel); this.Controls.Add(this.tabControl1); @@ -929,7 +958,9 @@ this.tabControl7.ResumeLayout(false); this.tabPage7.ResumeLayout(false); this.tabControl8.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ControllerImage)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -1010,5 +1041,7 @@ private ControllerConfigPanel NESAutofire2Panel; private ControllerConfigPanel NESAutofire3Panel; private ControllerConfigPanel NESAutofire4Panel; + private System.Windows.Forms.PictureBox ControllerImage; + private System.Windows.Forms.Label label38; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/config/ControllerConfig.cs b/BizHawk.MultiClient/config/ControllerConfig.cs index de122092c9..6816a14d54 100644 --- a/BizHawk.MultiClient/config/ControllerConfig.cs +++ b/BizHawk.MultiClient/config/ControllerConfig.cs @@ -11,6 +11,9 @@ namespace BizHawk.MultiClient { public partial class ControllerConfig : Form { + //TODO: autoab + //enable L+R + public ControllerConfig() { InitializeComponent(); @@ -23,27 +26,6 @@ namespace BizHawk.MultiClient NESController3Panel.LoadSettings(Global.Config.NESController[2]); NESController4Panel.LoadSettings(Global.Config.NESController[3]); - //NESController1Panel.ControllerNumber = 1; - //NESController1Panel.Autofire = false; - //NESController1Panel.Load(); - //NESController2Panel.ControllerNumber = 2; - //NESController2Panel.Autofire = false; - //NESController2Panel.Load(); - - //NESController3Panel.ControllerNumber = 3; - //NESController3Panel.Autofire = false; - //NESController4Panel.ControllerNumber = 4; - //NESController4Panel.Autofire = false; - //NESAutofire1Panel.ControllerNumber = 1; - //NESAutofire1Panel.Autofire = false; - //NESAutofire2Panel.ControllerNumber = 2; - //NESAutofire2Panel.Autofire = false; - //NESAutofire3Panel.ControllerNumber = 3; - //NESAutofire3Panel.Autofire = false; - //NESAutofire4Panel.ControllerNumber = 4; - //NESAutofire4Panel.Autofire = false; - - SetAutoTab(true); } @@ -85,10 +67,26 @@ namespace BizHawk.MultiClient private void OK_Click(object sender, EventArgs e) { - NESController1Panel.Save(); - NESController2Panel.Save(); - NESController3Panel.Save(); - NESController4Panel.Save(); + foreach (Control control1 in tabControl1.TabPages) + { + if (control1 is TabControl) + { + foreach (Control control2 in (control1 as TabControl).TabPages) + { + if (control2 is ControllerConfigPanel) + { + (control2 as ControllerConfigPanel).Save(); + } + } + } + else + { + if (control1 is ControllerConfigPanel) + { + (control1 as ControllerConfigPanel).Save(); + } + } + } Global.OSD.AddMessage("Controller settings saved"); Close(); diff --git a/BizHawk.MultiClient/config/ControllerConfig/GamepadConfigPanel.cs b/BizHawk.MultiClient/config/ControllerConfig/GamepadConfigPanel.cs deleted file mode 100644 index 5281649369..0000000000 --- a/BizHawk.MultiClient/config/ControllerConfig/GamepadConfigPanel.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using System.Drawing; - -namespace BizHawk.MultiClient -{ - class GamepadConfigPanel : Panel - { - public static List buttons = new List(); - public int ControllerNumber = 1; - public bool Autofire = false; - - public int InputMarginLeft = 0; - public int LabelPadding = 10; - - public int MarginTop = 0; - public int Spacing = 30; - public int InputSize = 200; - - protected List Inputs = new List(); - protected List