diff --git a/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs b/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs index d8a018d1ea..0b44cdfb32 100644 --- a/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs +++ b/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using Content.Client.Stylesheets; using Content.Shared.Input; @@ -7,12 +8,16 @@ using Robust.Client.Input; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; +using Robust.Shared; +using Robust.Shared.Configuration; using Robust.Shared.Input; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Robust.Shared.Log; using static Robust.Client.UserInterface.Controls.BoxContainer; +using Robust.Client.UserInterface.CustomControls; namespace Content.Client.EscapeMenu.UI.Tabs { @@ -27,6 +32,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs }; [Dependency] private readonly IInputManager _inputManager = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; private BindButton? _currentlyRebinding; @@ -35,6 +41,12 @@ namespace Content.Client.EscapeMenu.UI.Tabs private readonly List _deferCommands = new(); + private void HandleToggleUSQWERTYCheckbox(BaseButton.ButtonToggledEventArgs args) + { + _cfg.SetCVar(CVars.DisplayUSQWERTYHotkeys, args.Pressed); + _cfg.SaveToFile(); + } + public KeyRebindTab() { IoCManager.InjectDependencies(this); @@ -74,6 +86,18 @@ namespace Content.Client.EscapeMenu.UI.Tabs _keyControls.Add(function, control); } + void AddCheckBox(string checkBoxName, bool currentState, Action? callBackOnClick) + { + CheckBox newCheckBox = new CheckBox() { Text = Loc.GetString(checkBoxName)}; + newCheckBox.Pressed = currentState; + newCheckBox.OnToggled += callBackOnClick; + + KeybindsContainer.AddChild(newCheckBox); + } + + AddHeader("ui-options-header-general"); + AddCheckBox("ui-options-hotkey-keymap", _cfg.GetCVar(CVars.DisplayUSQWERTYHotkeys), HandleToggleUSQWERTYCheckbox); + AddHeader("ui-options-header-movement"); AddButton(EngineKeyFunctions.MoveUp); AddButton(EngineKeyFunctions.MoveLeft); @@ -428,6 +452,18 @@ namespace Content.Client.EscapeMenu.UI.Tabs MinSize = (200, 0); } + protected override void EnteredTree() + { + base.EnteredTree(); + _tab._inputManager.OnInputModeChanged += UpdateText; + } + + protected override void ExitedTree() + { + base.ExitedTree(); + _tab._inputManager.OnInputModeChanged -= UpdateText; + } + private void ButtonOnOnKeyBindDown(GUIBoundKeyEventArgs args) { if (args.Function == EngineKeyFunctions.UIRightClick) diff --git a/Content.Client/HUD/GameHud.cs b/Content.Client/HUD/GameHud.cs index 6da65b2f20..e3a02e0170 100644 --- a/Content.Client/HUD/GameHud.cs +++ b/Content.Client/HUD/GameHud.cs @@ -15,6 +15,7 @@ using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.ResourceManagement; using Robust.Client.UserInterface.Controls; +using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.Input; using Robust.Shared.Input.Binding; @@ -620,12 +621,14 @@ namespace Content.Client.HUD { _inputManager.OnKeyBindingAdded += OnKeyBindingChanged; _inputManager.OnKeyBindingRemoved += OnKeyBindingChanged; + _inputManager.OnInputModeChanged += OnKeyBindingChanged; } protected override void ExitedTree() { _inputManager.OnKeyBindingAdded -= OnKeyBindingChanged; _inputManager.OnKeyBindingRemoved -= OnKeyBindingChanged; + _inputManager.OnInputModeChanged -= OnKeyBindingChanged; } @@ -634,6 +637,11 @@ namespace Content.Client.HUD _label.Text = ShortKeyName(_function); } + private void OnKeyBindingChanged() + { + _label.Text = ShortKeyName(_function); + } + private string ShortKeyName(BoundKeyFunction keyFunction) { // need to use shortened key names so they fit in the buttons. diff --git a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl index 72852287a9..455f593214 100644 --- a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl +++ b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl @@ -65,6 +65,9 @@ ui-options-header-misc = Miscellaneous ui-options-header-hotbar = Hotbar ui-options-header-map-editor = Map Editor ui-options-header-dev = Development +ui-options-header-general = General + +ui-options-hotkey-keymap = Use US QWERTY Keys ui-options-function-move-up = Move Up ui-options-function-move-left = Move Left