Rename NamedHotkey to HotkeyReference.
This commit is contained in:
@@ -273,9 +273,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
return InvalidValueAction(value, fieldType, fieldName);
|
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))
|
else if (fieldType == typeof(WDist))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ namespace OpenRA
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A reference to either a named hotkey (defined in the game settings) or a statically assigned hotkey
|
/// A reference to either a named hotkey (defined in the game settings) or a statically assigned hotkey
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class NamedHotkey
|
public class HotkeyReference
|
||||||
{
|
{
|
||||||
static readonly Func<Hotkey> Invalid = () => Hotkey.Invalid;
|
static readonly Func<Hotkey> Invalid = () => Hotkey.Invalid;
|
||||||
|
|
||||||
readonly Func<Hotkey> getValue;
|
readonly Func<Hotkey> getValue;
|
||||||
|
|
||||||
public NamedHotkey()
|
public HotkeyReference()
|
||||||
{
|
{
|
||||||
getValue = Invalid;
|
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
|
// Try parsing the value as a reference to a named hotkey
|
||||||
getValue = settings.GetHotkeyReference(name);
|
getValue = settings.GetHotkeyReference(name);
|
||||||
@@ -225,7 +225,7 @@
|
|||||||
<Compile Include="Input\InputHandler.cs" />
|
<Compile Include="Input\InputHandler.cs" />
|
||||||
<Compile Include="Input\Keycode.cs" />
|
<Compile Include="Input\Keycode.cs" />
|
||||||
<Compile Include="Input\Hotkey.cs" />
|
<Compile Include="Input\Hotkey.cs" />
|
||||||
<Compile Include="Input\NamedHotkey.cs" />
|
<Compile Include="Input\HotkeyReference.cs" />
|
||||||
<Compile Include="Graphics\PlatformInterfaces.cs" />
|
<Compile Include="Graphics\PlatformInterfaces.cs" />
|
||||||
<Compile Include="Sound\Sound.cs" />
|
<Compile Include="Sound\Sound.cs" />
|
||||||
<Compile Include="Sound\SoundDevice.cs" />
|
<Compile Include="Sound\SoundDevice.cs" />
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
// Build the list of widget keys to validate
|
// Build the list of widget keys to validate
|
||||||
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
||||||
.SelectMany(w => w.GetFields()
|
.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)))
|
.Select(f => Pair.New(w.Name.Substring(0, w.Name.Length - 6), f.Name)))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public readonly string TooltipContainer;
|
public readonly string TooltipContainer;
|
||||||
public readonly string TooltipTemplate = "BUTTON_TOOLTIP";
|
public readonly string TooltipTemplate = "BUTTON_TOOLTIP";
|
||||||
|
|
||||||
public NamedHotkey Key = new NamedHotkey();
|
public HotkeyReference Key = new HotkeyReference();
|
||||||
public bool DisableKeyRepeat = false;
|
public bool DisableKeyRepeat = false;
|
||||||
public bool DisableKeySound = false;
|
public bool DisableKeySound = false;
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
|
public MapEditorLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary<string, MiniYaml> logicArgs)
|
||||||
{
|
{
|
||||||
MiniYaml yaml;
|
MiniYaml yaml;
|
||||||
var changeZoomKey = new NamedHotkey();
|
var changeZoomKey = new HotkeyReference();
|
||||||
if (logicArgs.TryGetValue("ChangeZoomKey", out yaml))
|
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");
|
var editorViewport = widget.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
MiniYaml yaml;
|
MiniYaml yaml;
|
||||||
var ks = Game.Settings.Keys;
|
var ks = Game.Settings.Keys;
|
||||||
string[] keyNames = Enum.GetNames(typeof(ObserverStatsPanel));
|
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++)
|
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
|
// System buttons
|
||||||
var options = widget.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");
|
var options = widget.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
readonly IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
|
readonly IOrderedEnumerable<IGrouping<int, CameraOption>> teams;
|
||||||
readonly bool limitViews;
|
readonly bool limitViews;
|
||||||
|
|
||||||
readonly NamedHotkey combinedViewKey = new NamedHotkey();
|
readonly HotkeyReference combinedViewKey = new HotkeyReference();
|
||||||
readonly NamedHotkey worldViewKey = new NamedHotkey();
|
readonly HotkeyReference worldViewKey = new HotkeyReference();
|
||||||
|
|
||||||
CameraOption selected;
|
CameraOption selected;
|
||||||
|
|
||||||
@@ -67,10 +67,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
MiniYaml yaml;
|
MiniYaml yaml;
|
||||||
var ks = Game.Settings.Keys;
|
var ks = Game.Settings.Keys;
|
||||||
if (logicArgs.TryGetValue("CombinedViewKey", out yaml))
|
if (logicArgs.TryGetValue("CombinedViewKey", out yaml))
|
||||||
combinedViewKey = new NamedHotkey(yaml.Value, ks);
|
combinedViewKey = new HotkeyReference(yaml.Value, ks);
|
||||||
|
|
||||||
if (logicArgs.TryGetValue("WorldViewKey", out yaml))
|
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);
|
limitViews = world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
MiniYaml yaml;
|
MiniYaml yaml;
|
||||||
var ks = Game.Settings.Keys;
|
var ks = Game.Settings.Keys;
|
||||||
string[] keyNames = Enum.GetNames(typeof(ObserverStatsPanel));
|
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++)
|
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);
|
players = world.Players.Where(p => !p.NonCombatant);
|
||||||
|
|
||||||
|
|||||||
@@ -29,21 +29,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var ks = Game.Settings.Keys;
|
var ks = Game.Settings.Keys;
|
||||||
MiniYaml yaml;
|
MiniYaml yaml;
|
||||||
|
|
||||||
var stopKey = new NamedHotkey();
|
var stopKey = new HotkeyReference();
|
||||||
if (logicArgs.TryGetValue("StopMusicKey", out yaml))
|
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))
|
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))
|
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))
|
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");
|
var keyhandler = widget.Get<LogicKeyListenerWidget>("GLOBAL_KEYHANDLER");
|
||||||
keyhandler.AddHandler(e =>
|
keyhandler.AddHandler(e =>
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var ks = Game.Settings.Keys;
|
var ks = Game.Settings.Keys;
|
||||||
MiniYaml yaml;
|
MiniYaml yaml;
|
||||||
|
|
||||||
var namedKey = new NamedHotkey();
|
var namedKey = new HotkeyReference();
|
||||||
if (logicArgs.TryGetValue(argName, out yaml))
|
if (logicArgs.TryGetValue(argName, out yaml))
|
||||||
namedKey = new NamedHotkey(yaml.Value, ks);
|
namedKey = new HotkeyReference(yaml.Value, ks);
|
||||||
|
|
||||||
var keyhandler = widget.Get<LogicKeyListenerWidget>(parentName);
|
var keyhandler = widget.Get<LogicKeyListenerWidget>(parentName);
|
||||||
keyhandler.AddHandler(e =>
|
keyhandler.AddHandler(e =>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
public ActorInfo Actor;
|
public ActorInfo Actor;
|
||||||
public string Name;
|
public string Name;
|
||||||
public NamedHotkey Hotkey;
|
public HotkeyReference Hotkey;
|
||||||
public Sprite Sprite;
|
public Sprite Sprite;
|
||||||
public PaletteReference Palette;
|
public PaletteReference Palette;
|
||||||
public PaletteReference IconClockPalette;
|
public PaletteReference IconClockPalette;
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||||
ProductionQueue currentQueue;
|
ProductionQueue currentQueue;
|
||||||
NamedHotkey[] hotkeys;
|
HotkeyReference[] hotkeys;
|
||||||
|
|
||||||
public ProductionQueue CurrentQueue
|
public ProductionQueue CurrentQueue
|
||||||
{
|
{
|
||||||
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
base.Initialize(args);
|
base.Initialize(args);
|
||||||
|
|
||||||
hotkeys = Exts.MakeArray(HotkeyCount,
|
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()
|
public void ScrollDown()
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public readonly int TabWidth = 30;
|
public readonly int TabWidth = 30;
|
||||||
public readonly int ArrowWidth = 20;
|
public readonly int ArrowWidth = 20;
|
||||||
|
|
||||||
public readonly NamedHotkey PreviousProductionTabKey = new NamedHotkey();
|
public readonly HotkeyReference PreviousProductionTabKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey NextProductionTabKey = new NamedHotkey();
|
public readonly HotkeyReference NextProductionTabKey = new HotkeyReference();
|
||||||
|
|
||||||
public readonly Dictionary<string, ProductionTabGroup> Groups;
|
public readonly Dictionary<string, ProductionTabGroup> Groups;
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
public SupportPowerIcon TooltipIcon { get; private set; }
|
public SupportPowerIcon TooltipIcon { get; private set; }
|
||||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||||
NamedHotkey[] hotkeys;
|
HotkeyReference[] hotkeys;
|
||||||
|
|
||||||
Rectangle eventBounds;
|
Rectangle eventBounds;
|
||||||
public override Rectangle EventBounds { get { return eventBounds; } }
|
public override Rectangle EventBounds { get { return eventBounds; } }
|
||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
base.Initialize(args);
|
base.Initialize(args);
|
||||||
|
|
||||||
hotkeys = Exts.MakeArray(HotkeyCount,
|
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
|
public class SupportPowerIcon
|
||||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public Sprite Sprite;
|
public Sprite Sprite;
|
||||||
public PaletteReference Palette;
|
public PaletteReference Palette;
|
||||||
public PaletteReference IconClockPalette;
|
public PaletteReference IconClockPalette;
|
||||||
public NamedHotkey Hotkey;
|
public HotkeyReference Hotkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshIcons()
|
public void RefreshIcons()
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
readonly ResourceLayer resourceLayer;
|
readonly ResourceLayer resourceLayer;
|
||||||
|
|
||||||
public readonly NamedHotkey ScrollUpKey = new NamedHotkey();
|
public readonly HotkeyReference ScrollUpKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey ScrollDownKey = new NamedHotkey();
|
public readonly HotkeyReference ScrollDownKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey ScrollLeftKey = new NamedHotkey();
|
public readonly HotkeyReference ScrollLeftKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey ScrollRightKey = new NamedHotkey();
|
public readonly HotkeyReference ScrollRightKey = new HotkeyReference();
|
||||||
|
|
||||||
public readonly NamedHotkey JumpToTopEdgeKey = new NamedHotkey();
|
public readonly HotkeyReference JumpToTopEdgeKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey JumpToBottomEdgeKey = new NamedHotkey();
|
public readonly HotkeyReference JumpToBottomEdgeKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey JumpToLeftEdgeKey = new NamedHotkey();
|
public readonly HotkeyReference JumpToLeftEdgeKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey JumpToRightEdgeKey = new NamedHotkey();
|
public readonly HotkeyReference JumpToRightEdgeKey = new HotkeyReference();
|
||||||
|
|
||||||
// Note: LinterHotkeyNames assumes that these are disabled by default
|
// Note: LinterHotkeyNames assumes that these are disabled by default
|
||||||
public readonly string BookmarkSaveKeyPrefix = null;
|
public readonly string BookmarkSaveKeyPrefix = null;
|
||||||
@@ -92,8 +92,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
World world;
|
World world;
|
||||||
WorldRenderer worldRenderer;
|
WorldRenderer worldRenderer;
|
||||||
|
|
||||||
NamedHotkey[] saveBookmarkHotkeys;
|
HotkeyReference[] saveBookmarkHotkeys;
|
||||||
NamedHotkey[] restoreBookmarkHotkeys;
|
HotkeyReference[] restoreBookmarkHotkeys;
|
||||||
WPos?[] bookmarkPositions;
|
WPos?[] bookmarkPositions;
|
||||||
|
|
||||||
[CustomLintableHotkeyNames]
|
[CustomLintableHotkeyNames]
|
||||||
@@ -147,10 +147,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
base.Initialize(args);
|
base.Initialize(args);
|
||||||
|
|
||||||
saveBookmarkHotkeys = Exts.MakeArray(BookmarkKeyCount,
|
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,
|
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];
|
bookmarkPositions = new WPos?[BookmarkKeyCount];
|
||||||
}
|
}
|
||||||
@@ -427,7 +427,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
var key = Hotkey.FromKeyInput(e);
|
var key = Hotkey.FromKeyInput(e);
|
||||||
|
|
||||||
Func<NamedHotkey, ScrollDirection, bool> handleMapScrollKey = (hotkey, scrollDirection) =>
|
Func<HotkeyReference, ScrollDirection, bool> handleMapScrollKey = (hotkey, scrollDirection) =>
|
||||||
{
|
{
|
||||||
var isHotkey = false;
|
var isHotkey = false;
|
||||||
var keyValue = hotkey.GetValue();
|
var keyValue = hotkey.GetValue();
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
public class WorldInteractionControllerWidget : Widget
|
public class WorldInteractionControllerWidget : Widget
|
||||||
{
|
{
|
||||||
public readonly NamedHotkey SelectAllKey = new NamedHotkey();
|
public readonly HotkeyReference SelectAllKey = new HotkeyReference();
|
||||||
public readonly NamedHotkey SelectSameTypeKey = new NamedHotkey();
|
public readonly HotkeyReference SelectSameTypeKey = new HotkeyReference();
|
||||||
|
|
||||||
protected readonly World World;
|
protected readonly World World;
|
||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
|
|||||||
Reference in New Issue
Block a user