Skip to content

Commit

Permalink
Use short context names in hotkey yaml, generate translation key at r…
Browse files Browse the repository at this point in the history
…untime.
  • Loading branch information
RoosterDragon committed Oct 5, 2024
1 parent a24f240 commit 27f045d
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 203 deletions.
6 changes: 5 additions & 1 deletion OpenRA.Game/HotkeyDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#endregion

using System.Collections.Generic;
using System.Linq;

namespace OpenRA
{
public sealed class HotkeyDefinition
{
public const string ContextFluentPrefix = "hotkey-context";

public readonly string Name;
public readonly Hotkey Default = Hotkey.Invalid;

Expand Down Expand Up @@ -45,7 +48,8 @@ public HotkeyDefinition(string name, MiniYaml node)
Types = FieldLoader.GetValue<HashSet<string>>("Types", typesYaml.Value);

if (nodeDict.TryGetValue("Contexts", out var contextYaml))
Contexts = FieldLoader.GetValue<HashSet<string>>("Contexts", contextYaml.Value);
Contexts = FieldLoader.GetValue<HashSet<string>>("Contexts", contextYaml.Value)
.Select(c => ContextFluentPrefix + "." + c).ToHashSet();

if (nodeDict.TryGetValue("Platform", out var platformYaml))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class HotkeysSettingsLogic : ChromeLogic
const string DuplicateNotice = "label-duplicate-notice";

[FluentReference]
const string AnyContext = "hotkey-context-any";
const string AnyContext = HotkeyDefinition.ContextFluentPrefix + "-any";

readonly ModData modData;
readonly Dictionary<string, MiniYaml> logicArgs;
Expand Down
14 changes: 7 additions & 7 deletions mods/cnc/hotkeys.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
NextProductionTab: PAGEDOWN
Description: hotkey-description-nextproductiontab
Types: Production
Contexts: hotkey-context-player
Contexts: player

PreviousProductionTab: PAGEUP
Description: hotkey-description-previousproductiontab
Types: Production
Contexts: hotkey-context-player
Contexts: player

ProductionTypeBuilding: E
Description: hotkey-description-productiontypebuilding
Types: Production
Contexts: hotkey-context-player
Contexts: player

ProductionTypeDefense: R
Description: hotkey-description-productiontypedefense
Types: Production
Contexts: hotkey-context-player
Contexts: player

ProductionTypeInfantry: T
Description: hotkey-description-productiontypeinfantry
Types: Production
Contexts: hotkey-context-player
Contexts: player

ProductionTypeVehicle: Y
Description: hotkey-description-productiontypevehicle
Types: Production
Contexts: hotkey-context-player
Contexts: player

ProductionTypeAircraft: U
Description: hotkey-description-productiontypeaircraft
Types: Production
Contexts: hotkey-context-player
Contexts: player
8 changes: 4 additions & 4 deletions mods/common/hotkeys/chat.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
OpenTeamChat: Return
Description: hotkey-description-openteamchat
Types: Chat
Contexts: hotkey-context-player, hotkey-context-spectator
Contexts: player, spectator

OpenGeneralChat: Return Shift
Description: hotkey-description-opengeneralchat
Types: Chat
Contexts: hotkey-context-player, hotkey-context-spectator
Contexts: player, spectator

ToggleChatMode: Tab Shift
Description: hotkey-description-togglechatmode
Types: Chat
Contexts: hotkey-context-chat-input, hotkey-context-menu
Contexts: chat-input, menu
Readonly: True

Autocomplete: Tab
Description: hotkey-description-autocomplete
Types: Chat
Contexts: hotkey-context-chat-input
Contexts: chat-input
Readonly: True
Loading

0 comments on commit 27f045d

Please sign in to comment.