Migrate ButtonWidget to NamedHotkey.

This commit is contained in:
Paul Chote
2017-07-23 14:25:27 +00:00
committed by reaperrr
parent 42bf232b37
commit 1e0148e092
20 changed files with 120 additions and 100 deletions

View File

@@ -19,14 +19,8 @@ namespace OpenRA.Mods.Common.Widgets
{
public readonly string TooltipContainer;
public readonly string TooltipTemplate = "BUTTON_TOOLTIP";
public Func<ButtonWidget, Hotkey> GetKey = _ => Hotkey.Invalid;
public Hotkey Key
{
get { return GetKey(this); }
set { GetKey = _ => value; }
}
public NamedHotkey Key = new NamedHotkey();
public bool DisableKeyRepeat = false;
public bool DisableKeySound = false;
@@ -136,7 +130,7 @@ namespace OpenRA.Mods.Common.Widgets
public override bool HandleKeyPress(KeyInput e)
{
if (Hotkey.FromKeyInput(e) != Key || e.Event != KeyInputEvent.Down || (DisableKeyRepeat && e.IsRepeat))
if (Hotkey.FromKeyInput(e) != Key.GetValue() || e.Event != KeyInputEvent.Down || (DisableKeyRepeat && e.IsRepeat))
return false;
if (!IsDisabled())