Input widget - Check for duplicates in binding array before committing a mapping

This commit is contained in:
andres.delikat 2011-07-09 18:24:53 +00:00
parent 7c9d170248
commit 0407bb2e86
1 changed files with 18 additions and 4 deletions

View File

@ -78,13 +78,27 @@ namespace BizHawk.MultiClient
if (TempBindingStr == "Alt+F4") if (TempBindingStr == "Alt+F4")
return; return;
Bindings[pos] = TempBindingStr; if (!IsDuplicate(TempBindingStr))
wasPressed = TempBindingStr; {
UpdateLabel(); Bindings[pos] = TempBindingStr;
Increment(); wasPressed = TempBindingStr;
UpdateLabel();
Increment();
}
} }
} }
public bool IsDuplicate(string binding)
{
for (int x = 0; x < MaxBind; x++)
{
if (Bindings[x] == binding)
return true;
}
return false;
}
protected override void OnKeyUp(KeyEventArgs e) protected override void OnKeyUp(KeyEventArgs e)
{ {
if (e.KeyCode == Keys.F4 && e.Modifiers == Keys.Alt) if (e.KeyCode == Keys.F4 && e.Modifiers == Keys.Alt)