Rename NamedHotkey to HotkeyReference.

This commit is contained in:
Paul Chote
2017-11-05 19:38:06 +00:00
committed by abcdefg30
parent 6dd42f7ab1
commit c4237d6a1a
16 changed files with 51 additions and 51 deletions

View File

@@ -273,9 +273,9 @@ namespace OpenRA
return InvalidValueAction(value, fieldType, fieldName);
}
else if (fieldType == typeof(NamedHotkey))
else if (fieldType == typeof(HotkeyReference))
{
return new NamedHotkey(value, Game.Settings.Keys);
return new HotkeyReference(value, Game.Settings.Keys);
}
else if (fieldType == typeof(WDist))
{

View File

@@ -16,18 +16,18 @@ namespace OpenRA
/// <summary>
/// A reference to either a named hotkey (defined in the game settings) or a statically assigned hotkey
/// </summary>
public class NamedHotkey
public class HotkeyReference
{
static readonly Func<Hotkey> Invalid = () => Hotkey.Invalid;
readonly Func<Hotkey> getValue;
public NamedHotkey()
public HotkeyReference()
{
getValue = Invalid;
}
public NamedHotkey(string name, KeySettings settings)
public HotkeyReference(string name, KeySettings settings)
{
// Try parsing the value as a reference to a named hotkey
getValue = settings.GetHotkeyReference(name);

View File

@@ -225,7 +225,7 @@
<Compile Include="Input\InputHandler.cs" />
<Compile Include="Input\Keycode.cs" />
<Compile Include="Input\Hotkey.cs" />
<Compile Include="Input\NamedHotkey.cs" />
<Compile Include="Input\HotkeyReference.cs" />
<Compile Include="Graphics\PlatformInterfaces.cs" />
<Compile Include="Sound\Sound.cs" />
<Compile Include="Sound\SoundDevice.cs" />

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Lint
// Build the list of widget keys to validate
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
.SelectMany(w => w.GetFields()
.Where(f => f.FieldType == typeof(NamedHotkey))
.Where(f => f.FieldType == typeof(HotkeyReference))
.Select(f => Pair.New(w.Name.Substring(0, w.Name.Length - 6), f.Name)))
.ToArray();

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets
public readonly string TooltipContainer;
public readonly string TooltipTemplate = "BUTTON_TOOLTIP";
public NamedHotkey Key = new NamedHotkey();
public HotkeyReference Key = new HotkeyReference();
public bool DisableKeyRepeat = false;
public bool DisableKeySound = false;

View File

@@ -26,9 +26,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
{
MiniYaml yaml;
var changeZoomKey = new NamedHotkey();
var changeZoomKey = new HotkeyReference();
if (logicArgs.TryGetValue("ChangeZoomKey", out yaml))
changeZoomKey = new NamedHotkey(yaml.Value, Game.Settings.Keys);
changeZoomKey = new HotkeyReference(yaml.Value, Game.Settings.Keys);
var editorViewport = widget.Get<EditorViewportControllerWidget>("MAP_EDITOR");

View File

@@ -38,9 +38,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
MiniYaml yaml;
var ks = Game.Settings.Keys;
string[] keyNames = Enum.GetNames(typeof(ObserverStatsPanel));
var statsHotkeys = new NamedHotkey[keyNames.Length];
var statsHotkeys = new HotkeyReference[keyNames.Length];
for (var i = 0; i < keyNames.Length; i++)
statsHotkeys[i] = logicArgs.TryGetValue("Statistics" + keyNames[i] + "Key", out yaml) ? new NamedHotkey(yaml.Value, ks) : new NamedHotkey();
statsHotkeys[i] = logicArgs.TryGetValue("Statistics" + keyNames[i] + "Key", out yaml) ? new HotkeyReference(yaml.Value, ks) : new HotkeyReference();
// System buttons
var options = widget.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");

View File

@@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
readonly bool limitViews;
readonly NamedHotkey combinedViewKey = new NamedHotkey();
readonly NamedHotkey worldViewKey = new NamedHotkey();
readonly HotkeyReference combinedViewKey = new HotkeyReference();
readonly HotkeyReference worldViewKey = new HotkeyReference();
CameraOption selected;
@@ -67,10 +67,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
MiniYaml yaml;
var ks = Game.Settings.Keys;
if (logicArgs.TryGetValue("CombinedViewKey", out yaml))
combinedViewKey = new NamedHotkey(yaml.Value, ks);
combinedViewKey = new HotkeyReference(yaml.Value, ks);
if (logicArgs.TryGetValue("WorldViewKey", out yaml))
worldViewKey = new NamedHotkey(yaml.Value, ks);
worldViewKey = new HotkeyReference(yaml.Value, ks);
limitViews = world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);

View File

@@ -52,9 +52,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
MiniYaml yaml;
var ks = Game.Settings.Keys;
string[] keyNames = Enum.GetNames(typeof(ObserverStatsPanel));
var statsHotkeys = new NamedHotkey[keyNames.Length];
var statsHotkeys = new HotkeyReference[keyNames.Length];
for (var i = 0; i < keyNames.Length; i++)
statsHotkeys[i] = logicArgs.TryGetValue("Statistics" + keyNames[i] + "Key", out yaml) ? new NamedHotkey(yaml.Value, ks) : new NamedHotkey();
statsHotkeys[i] = logicArgs.TryGetValue("Statistics" + keyNames[i] + "Key", out yaml) ? new HotkeyReference(yaml.Value, ks) : new HotkeyReference();
players = world.Players.Where(p => !p.NonCombatant);

View File

@@ -29,21 +29,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var ks = Game.Settings.Keys;
MiniYaml yaml;
var stopKey = new NamedHotkey();
var stopKey = new HotkeyReference();
if (logicArgs.TryGetValue("StopMusicKey", out yaml))
stopKey = new NamedHotkey(yaml.Value, ks);
stopKey = new HotkeyReference(yaml.Value, ks);
var pauseKey = new NamedHotkey();
var pauseKey = new HotkeyReference();
if (logicArgs.TryGetValue("PauseMusicKey", out yaml))
pauseKey = new NamedHotkey(yaml.Value, ks);
pauseKey = new HotkeyReference(yaml.Value, ks);
var prevKey = new NamedHotkey();
var prevKey = new HotkeyReference();
if (logicArgs.TryGetValue("PrevMusicKey", out yaml))
prevKey = new NamedHotkey(yaml.Value, ks);
prevKey = new HotkeyReference(yaml.Value, ks);
var nextKey = new NamedHotkey();
var nextKey = new HotkeyReference();
if (logicArgs.TryGetValue("NextMusicKey", out yaml))
nextKey = new NamedHotkey(yaml.Value, ks);
nextKey = new HotkeyReference(yaml.Value, ks);
var keyhandler = widget.Get<LogicKeyListenerWidget>("GLOBAL_KEYHANDLER");
keyhandler.AddHandler(e =>

View File

@@ -22,9 +22,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var ks = Game.Settings.Keys;
MiniYaml yaml;
var namedKey = new NamedHotkey();
var namedKey = new HotkeyReference();
if (logicArgs.TryGetValue(argName, out yaml))
namedKey = new NamedHotkey(yaml.Value, ks);
namedKey = new HotkeyReference(yaml.Value, ks);
var keyhandler = widget.Get<LogicKeyListenerWidget>(parentName);
keyhandler.AddHandler(e =>

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets
{
public ActorInfo Actor;
public string Name;
public NamedHotkey Hotkey;
public HotkeyReference Hotkey;
public Sprite Sprite;
public PaletteReference Palette;
public PaletteReference IconClockPalette;
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets
Lazy<TooltipContainerWidget> tooltipContainer;
ProductionQueue currentQueue;
NamedHotkey[] hotkeys;
HotkeyReference[] hotkeys;
public ProductionQueue CurrentQueue
{
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets
base.Initialize(args);
hotkeys = Exts.MakeArray(HotkeyCount,
i => new NamedHotkey(HotkeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
i => new HotkeyReference(HotkeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
}
public void ScrollDown()

View File

@@ -69,8 +69,8 @@ namespace OpenRA.Mods.Common.Widgets
public readonly int TabWidth = 30;
public readonly int ArrowWidth = 20;
public readonly NamedHotkey PreviousProductionTabKey = new NamedHotkey();
public readonly NamedHotkey NextProductionTabKey = new NamedHotkey();
public readonly HotkeyReference PreviousProductionTabKey = new HotkeyReference();
public readonly HotkeyReference NextProductionTabKey = new HotkeyReference();
public readonly Dictionary<string, ProductionTabGroup> Groups;

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets
public SupportPowerIcon TooltipIcon { get; private set; }
Lazy<TooltipContainerWidget> tooltipContainer;
NamedHotkey[] hotkeys;
HotkeyReference[] hotkeys;
Rectangle eventBounds;
public override Rectangle EventBounds { get { return eventBounds; } }
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets
base.Initialize(args);
hotkeys = Exts.MakeArray(HotkeyCount,
i => new NamedHotkey(HotkeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
i => new HotkeyReference(HotkeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
}
public class SupportPowerIcon
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Widgets
public Sprite Sprite;
public PaletteReference Palette;
public PaletteReference IconClockPalette;
public NamedHotkey Hotkey;
public HotkeyReference Hotkey;
}
public void RefreshIcons()

View File

@@ -26,15 +26,15 @@ namespace OpenRA.Mods.Common.Widgets
{
readonly ResourceLayer resourceLayer;
public readonly NamedHotkey ScrollUpKey = new NamedHotkey();
public readonly NamedHotkey ScrollDownKey = new NamedHotkey();
public readonly NamedHotkey ScrollLeftKey = new NamedHotkey();
public readonly NamedHotkey ScrollRightKey = new NamedHotkey();
public readonly HotkeyReference ScrollUpKey = new HotkeyReference();
public readonly HotkeyReference ScrollDownKey = new HotkeyReference();
public readonly HotkeyReference ScrollLeftKey = new HotkeyReference();
public readonly HotkeyReference ScrollRightKey = new HotkeyReference();
public readonly NamedHotkey JumpToTopEdgeKey = new NamedHotkey();
public readonly NamedHotkey JumpToBottomEdgeKey = new NamedHotkey();
public readonly NamedHotkey JumpToLeftEdgeKey = new NamedHotkey();
public readonly NamedHotkey JumpToRightEdgeKey = new NamedHotkey();
public readonly HotkeyReference JumpToTopEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToBottomEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToLeftEdgeKey = new HotkeyReference();
public readonly HotkeyReference JumpToRightEdgeKey = new HotkeyReference();
// Note: LinterHotkeyNames assumes that these are disabled by default
public readonly string BookmarkSaveKeyPrefix = null;
@@ -92,8 +92,8 @@ namespace OpenRA.Mods.Common.Widgets
World world;
WorldRenderer worldRenderer;
NamedHotkey[] saveBookmarkHotkeys;
NamedHotkey[] restoreBookmarkHotkeys;
HotkeyReference[] saveBookmarkHotkeys;
HotkeyReference[] restoreBookmarkHotkeys;
WPos?[] bookmarkPositions;
[CustomLintableHotkeyNames]
@@ -147,10 +147,10 @@ namespace OpenRA.Mods.Common.Widgets
base.Initialize(args);
saveBookmarkHotkeys = Exts.MakeArray(BookmarkKeyCount,
i => new NamedHotkey(BookmarkSaveKeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
i => new HotkeyReference(BookmarkSaveKeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
restoreBookmarkHotkeys = Exts.MakeArray(BookmarkKeyCount,
i => new NamedHotkey(BookmarkRestoreKeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
i => new HotkeyReference(BookmarkRestoreKeyPrefix + (i + 1).ToString("D2"), Game.Settings.Keys));
bookmarkPositions = new WPos?[BookmarkKeyCount];
}
@@ -427,7 +427,7 @@ namespace OpenRA.Mods.Common.Widgets
{
var key = Hotkey.FromKeyInput(e);
Func<NamedHotkey, ScrollDirection, bool> handleMapScrollKey = (hotkey, scrollDirection) =>
Func<HotkeyReference, ScrollDirection, bool> handleMapScrollKey = (hotkey, scrollDirection) =>
{
var isHotkey = false;
var keyValue = hotkey.GetValue();

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.Widgets
{
public class WorldInteractionControllerWidget : Widget
{
public readonly NamedHotkey SelectAllKey = new NamedHotkey();
public readonly NamedHotkey SelectSameTypeKey = new NamedHotkey();
public readonly HotkeyReference SelectAllKey = new HotkeyReference();
public readonly HotkeyReference SelectSameTypeKey = new HotkeyReference();
protected readonly World World;
readonly WorldRenderer worldRenderer;