Expose hotkeys to localisation.
Allows the Settings > Hotkeys screen to be localised, including hotkey decriptions, groups and contexts. The hotkey names are exposed to localisation via KeycodeExts. Hotkey modifiers are similarly exposed via ModifersExts. The Settings > Input screen has a Zoom Modifier dropdown, which shows the localised modifier name. The --check-yaml utility command is taught to recognise all hotkey translation, so it can validate their usage.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -61,6 +62,33 @@ namespace OpenRA
|
||||
Meta = 8,
|
||||
}
|
||||
|
||||
public static class ModifiersExts
|
||||
{
|
||||
[FluentReference]
|
||||
public const string Cmd = "keycode-modifier.cmd";
|
||||
|
||||
[FluentReference(Traits.LintDictionaryReference.Values)]
|
||||
public static readonly IReadOnlyDictionary<Modifiers, string> ModifierFluentKeys = new Dictionary<Modifiers, string>()
|
||||
{
|
||||
{ Modifiers.None, "keycode-modifier.none" },
|
||||
{ Modifiers.Shift, "keycode-modifier.shift" },
|
||||
{ Modifiers.Alt, "keycode-modifier.alt" },
|
||||
{ Modifiers.Ctrl, "keycode-modifier.ctrl" },
|
||||
{ Modifiers.Meta, "keycode-modifier.meta" },
|
||||
};
|
||||
|
||||
public static string DisplayString(Modifiers m)
|
||||
{
|
||||
if (m == Modifiers.Meta && Platform.CurrentPlatform == PlatformType.OSX)
|
||||
return FluentProvider.GetString(Cmd);
|
||||
|
||||
if (!ModifierFluentKeys.TryGetValue(m, out var fluentKey))
|
||||
return m.ToString();
|
||||
|
||||
return FluentProvider.GetString(fluentKey);
|
||||
}
|
||||
}
|
||||
|
||||
public enum KeyInputEvent { Down, Up }
|
||||
public struct KeyInput
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user