Controller Config - add a Clear button

This commit is contained in:
adelikat 2014-06-04 15:00:53 +00:00
parent 019ab3efe0
commit 500bbaf3c1
6 changed files with 257 additions and 202 deletions

View File

@ -45,6 +45,7 @@
this.buttonSaveDefaults = new System.Windows.Forms.Button();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.ClearBtn = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
@ -178,9 +179,9 @@
// buttonLoadDefaults
//
this.buttonLoadDefaults.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonLoadDefaults.Location = new System.Drawing.Point(465, 514);
this.buttonLoadDefaults.Location = new System.Drawing.Point(504, 514);
this.buttonLoadDefaults.Name = "buttonLoadDefaults";
this.buttonLoadDefaults.Size = new System.Drawing.Size(75, 23);
this.buttonLoadDefaults.Size = new System.Drawing.Size(70, 23);
this.buttonLoadDefaults.TabIndex = 8;
this.buttonLoadDefaults.Text = "Defaults";
this.toolTip1.SetToolTip(this.buttonLoadDefaults, "Set the default controller configuration to the current. Note: this affects all " +
@ -191,9 +192,9 @@
// buttonSaveDefaults
//
this.buttonSaveDefaults.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonSaveDefaults.Location = new System.Drawing.Point(384, 514);
this.buttonSaveDefaults.Location = new System.Drawing.Point(374, 514);
this.buttonSaveDefaults.Name = "buttonSaveDefaults";
this.buttonSaveDefaults.Size = new System.Drawing.Size(75, 23);
this.buttonSaveDefaults.Size = new System.Drawing.Size(70, 23);
this.buttonSaveDefaults.TabIndex = 9;
this.buttonSaveDefaults.Text = "Save Defs";
this.toolTip1.SetToolTip(this.buttonSaveDefaults, "Save the current configuration as your default controls. Note: this saves ALL con" +
@ -206,6 +207,17 @@
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// ClearBtn
//
this.ClearBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ClearBtn.Location = new System.Drawing.Point(580, 514);
this.ClearBtn.Name = "ClearBtn";
this.ClearBtn.Size = new System.Drawing.Size(75, 23);
this.ClearBtn.TabIndex = 10;
this.ClearBtn.Text = "&Clear";
this.ClearBtn.UseVisualStyleBackColor = true;
this.ClearBtn.Click += new System.EventHandler(this.ClearBtn_Click);
//
// ControllerConfig
//
this.AcceptButton = this.buttonOK;
@ -213,6 +225,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(932, 544);
this.Controls.Add(this.ClearBtn);
this.Controls.Add(this.buttonSaveDefaults);
this.Controls.Add(this.buttonLoadDefaults);
this.Controls.Add(this.checkBoxUDLR);
@ -251,5 +264,6 @@
private System.Windows.Forms.Button buttonSaveDefaults;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Button ClearBtn;
}
}

View File

@ -379,5 +379,40 @@ namespace BizHawk.Client.EmuHawk
ConfigService.Save(Config.ControlDefaultPath, cd);
}
}
private void ClearWidgetAndChildren(Control c)
{
if (c is InputCompositeWidget)
{
(c as InputCompositeWidget).Clear();
}
if (c is InputWidget)
{
(c as InputWidget).ClearAll();
}
if (c is AnalogBindControl)
{
(c as AnalogBindControl).Unbind_Click(null, null);
}
if (c.Controls.Count > 0)
{
foreach (Control child in c.Controls.OfType<Control>())
{
ClearWidgetAndChildren(child);
}
}
}
private void ClearBtn_Click(object sender, EventArgs e)
{
// TODO: make this recursive to not depend on the current structure
foreach (var c in Controls.OfType<Control>())
{
ClearWidgetAndChildren(c);
}
}
}
}

View File

@ -132,7 +132,7 @@
this.buttonUnbind.TabIndex = 8;
this.buttonUnbind.Text = "Unbind!";
this.buttonUnbind.UseVisualStyleBackColor = true;
this.buttonUnbind.Click += new System.EventHandler(this.buttonUnbind_Click);
this.buttonUnbind.Click += new System.EventHandler(this.Unbind_Click);
//
// AnalogBindControl
//

View File

@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
trackBarSensitivity.Value *= -1;
}
private void buttonUnbind_Click(object sender, EventArgs e)
public void Unbind_Click(object sender, EventArgs e)
{
Bind.Value = "";
textBox1.Text = "";

View File

@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
public void Clear()
{
widget.Clear();
widget.ClearAll();
}
private void btnSpecial_Click(object sender, EventArgs e)

View File

@ -83,6 +83,12 @@ namespace BizHawk.Client.EmuHawk
base.OnMouseClick(e);
}
public void ClearAll()
{
ClearBindings();
Clear();
}
private void ClearBindings()
{
for (var i = 0; i < _maxBind; i++)