diff --git a/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs b/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs index e3c6a79482..49badb606f 100644 --- a/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs +++ b/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs @@ -42,43 +42,9 @@ namespace BizHawk.MultiClient } - private void DoConflicts() - { - var BindingList = new List>(); - var uniqueBindings = new HashSet(); - - for (int i = 0; i < Inputs.Count; i++) - { - if (!String.IsNullOrWhiteSpace(Inputs[i].Text)) - { - string[] bindings = Inputs[i].Text.Split(','); - foreach (string binding in bindings) - { - BindingList.Add(new KeyValuePair(i, binding)); - uniqueBindings.Add(binding); - } - } - } - - foreach (string binding in uniqueBindings) - { - List> kvps = BindingList.Where(x => x.Value == binding).ToList(); - if (kvps.Count > 1) - { - foreach(KeyValuePair kvp in kvps) - { - Inputs[kvp.Key].Conflicted = true; - } - } - } - } - public void ClearAll() { - foreach (InputWidget i in Inputs) - { - i.Clear(); - } + Inputs.ForEach(x => x.Clear()); } /// @@ -143,34 +109,31 @@ namespace BizHawk.MultiClient y = MarginTop; x += ColumnWidth; } - InputWidget iw = new InputWidget {Location = new Point(x, y), Size = new Size(InputSize, 23), TabIndex = i}; - iw.AutoTab = Autotab; + + InputWidget iw = new InputWidget + { + Location = new Point(x, y), + Size = new Size(InputSize, 23), + TabIndex = i, + AutoTab = this.Autotab + }; + iw.BringToFront(); - iw.Leave += InputWidget_Leave; Controls.Add(iw); Inputs.Add(iw); - Label l = new Label + Label label = new Label { Location = new Point(x + InputSize + LabelPadding, y + 3), Text = buttons[i].Replace('_', ' ').Trim(), - //Width = LabelWidth }; - Controls.Add(l); - Labels.Add(l); + Controls.Add(label); + Labels.Add(label); } } - private void InputWidget_Leave(object sender, EventArgs e) - { - DoConflicts(); - } - public void SetAutoTab(bool value) { - foreach (InputWidget i in Inputs) - { - i.AutoTab = value; - } + Inputs.ForEach(x => x.AutoTab = value); } private void clearToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/config/InputWidget.cs b/BizHawk.MultiClient/config/InputWidget.cs index f709e745d8..5b54089d8a 100644 --- a/BizHawk.MultiClient/config/InputWidget.cs +++ b/BizHawk.MultiClient/config/InputWidget.cs @@ -18,54 +18,10 @@ namespace BizHawk.MultiClient private string[] _bindings = new string[4]; private string wasPressed = String.Empty; private ToolTip tooltip1 = new ToolTip(); - private Color _highlight_color = Color.LightCyan; - private Color _no_highlight_color = SystemColors.Window; - private bool conflicted = false; public bool AutoTab = true; public string WidgetName; - public bool Conflicted - { - get - { - return conflicted; - } - set - { - conflicted = value; - if (conflicted) - { - _no_highlight_color = Color.LightCoral; - _highlight_color = Color.Violet; - } - else - { - _highlight_color = Color.LightCyan; - _no_highlight_color = SystemColors.Window; - } - - if (Focused) - { - Highlight(); - } - else - { - UnHighlight(); - } - } - } - - private void Highlight() - { - BackColor = _highlight_color; - } - - private void UnHighlight() - { - BackColor = _no_highlight_color; - } - [DllImport("user32")] private static extern bool HideCaret(IntPtr hWnd); @@ -96,7 +52,7 @@ namespace BizHawk.MultiClient private void ClearBindings() { - for(int i = 0; i < MaxBind; i++) + for (int i = 0; i < MaxBind; i++) { _bindings[i] = String.Empty; } @@ -106,9 +62,7 @@ namespace BizHawk.MultiClient { pos = 0; timer.Start(); - //Input.Update(); - //zero: ??? what is this all about ??? wasPressed = Input.Instance.GetNextBindEvent(); } @@ -127,7 +81,6 @@ namespace BizHawk.MultiClient public void EraseMappings() { ClearBindings(); - Conflicted = false; Text = String.Empty; } @@ -144,7 +97,6 @@ namespace BizHawk.MultiClient if (TempBindingStr == "Escape") { ClearBindings(); - Conflicted = false; Increment(); return; } @@ -164,7 +116,6 @@ namespace BizHawk.MultiClient } } - //Checks if the key is already mapped to this widget private bool IsDuplicate(string binding) { return _bindings.FirstOrDefault(x => x == binding) != null; @@ -243,7 +194,7 @@ namespace BizHawk.MultiClient } set { - Text = ""; + Text = String.Empty; ClearBindings(); string str = value.Trim(); int x; @@ -254,7 +205,7 @@ namespace BizHawk.MultiClient if (x < 0) { _bindings[i] = str; - str = ""; + str = String.Empty; } else { @@ -277,30 +228,30 @@ namespace BizHawk.MultiClient switch (m.Msg) { case 0x0201: //WM_LBUTTONDOWN - { - this.Focus(); - return; - } + { + this.Focus(); + return; + } //case 0x0202://WM_LBUTTONUP //{ // return; //} case 0x0203://WM_LBUTTONDBLCLK - { - return; - } + { + return; + } case 0x0204://WM_RBUTTONDOWN - { - return; - } + { + return; + } case 0x0205://WM_RBUTTONUP - { - return; - } + { + return; + } case 0x0206://WM_RBUTTONDBLCLK - { - return; - } + { + return; + } } base.WndProc(ref m); @@ -321,14 +272,11 @@ namespace BizHawk.MultiClient protected override void OnGotFocus(EventArgs e) { - //base.OnGotFocus(e); HideCaret(this.Handle); - Highlight(); } protected override void OnLostFocus(EventArgs e) { - UnHighlight(); base.OnLostFocus(e); }