Move hardcoded support power keys into yaml.

This commit is contained in:
Paul Chote
2017-09-01 22:50:13 +01:00
committed by reaperrr
parent 4f00d62237
commit 2a6bb0678e
7 changed files with 58 additions and 32 deletions

View File

@@ -297,15 +297,6 @@ namespace OpenRA
public Hotkey PrevMusicKey = new Hotkey(Keycode.AUDIOPREV, Modifiers.None);
public Hotkey NextMusicKey = new Hotkey(Keycode.AUDIONEXT, Modifiers.None);
static readonly Func<KeySettings, Hotkey>[] SupportPowerKeys = GetKeys(6, "SupportPower");
static Func<KeySettings, Hotkey>[] GetKeys(int count, string prefix)
{
var keySettings = Expression.Parameter(typeof(KeySettings), "keySettings");
return Exts.MakeArray(count, i => Expression.Lambda<Func<KeySettings, Hotkey>>(
Expression.Field(keySettings, "{0}{1:D2}Key".F(prefix, i + 1)), keySettings).Compile());
}
internal Func<Hotkey> GetHotkeyReference(string name)
{
var field = typeof(KeySettings).GetField(name + "Key");
@@ -314,19 +305,6 @@ namespace OpenRA
return () => (Hotkey)field.GetValue(this);
}
public Hotkey GetSupportPowerHotkey(int index)
{
return GetKey(SupportPowerKeys, index);
}
Hotkey GetKey(Func<KeySettings, Hotkey>[] keys, int index)
{
if (index < 0 || index >= keys.Length)
return Hotkey.Invalid;
return keys[index](this);
}
}
public class ChatSettings