Added set English language checkbox (#4898)
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Client.Stylesheets;
|
using Content.Client.Stylesheets;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
@@ -7,12 +8,16 @@ using Robust.Client.Input;
|
|||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||||
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
|
||||||
namespace Content.Client.EscapeMenu.UI.Tabs
|
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 IInputManager _inputManager = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
|
||||||
private BindButton? _currentlyRebinding;
|
private BindButton? _currentlyRebinding;
|
||||||
|
|
||||||
@@ -35,6 +41,12 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
|||||||
|
|
||||||
private readonly List<Action> _deferCommands = new();
|
private readonly List<Action> _deferCommands = new();
|
||||||
|
|
||||||
|
private void HandleToggleUSQWERTYCheckbox(BaseButton.ButtonToggledEventArgs args)
|
||||||
|
{
|
||||||
|
_cfg.SetCVar(CVars.DisplayUSQWERTYHotkeys, args.Pressed);
|
||||||
|
_cfg.SaveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
public KeyRebindTab()
|
public KeyRebindTab()
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
@@ -74,6 +86,18 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
|||||||
_keyControls.Add(function, control);
|
_keyControls.Add(function, control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.ButtonToggledEventArgs>? 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");
|
AddHeader("ui-options-header-movement");
|
||||||
AddButton(EngineKeyFunctions.MoveUp);
|
AddButton(EngineKeyFunctions.MoveUp);
|
||||||
AddButton(EngineKeyFunctions.MoveLeft);
|
AddButton(EngineKeyFunctions.MoveLeft);
|
||||||
@@ -428,6 +452,18 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
|||||||
MinSize = (200, 0);
|
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)
|
private void ButtonOnOnKeyBindDown(GUIBoundKeyEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Function == EngineKeyFunctions.UIRightClick)
|
if (args.Function == EngineKeyFunctions.UIRightClick)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Robust.Client.Graphics;
|
|||||||
using Robust.Client.Input;
|
using Robust.Client.Input;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
@@ -620,12 +621,14 @@ namespace Content.Client.HUD
|
|||||||
{
|
{
|
||||||
_inputManager.OnKeyBindingAdded += OnKeyBindingChanged;
|
_inputManager.OnKeyBindingAdded += OnKeyBindingChanged;
|
||||||
_inputManager.OnKeyBindingRemoved += OnKeyBindingChanged;
|
_inputManager.OnKeyBindingRemoved += OnKeyBindingChanged;
|
||||||
|
_inputManager.OnInputModeChanged += OnKeyBindingChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ExitedTree()
|
protected override void ExitedTree()
|
||||||
{
|
{
|
||||||
_inputManager.OnKeyBindingAdded -= OnKeyBindingChanged;
|
_inputManager.OnKeyBindingAdded -= OnKeyBindingChanged;
|
||||||
_inputManager.OnKeyBindingRemoved -= OnKeyBindingChanged;
|
_inputManager.OnKeyBindingRemoved -= OnKeyBindingChanged;
|
||||||
|
_inputManager.OnInputModeChanged -= OnKeyBindingChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -634,6 +637,11 @@ namespace Content.Client.HUD
|
|||||||
_label.Text = ShortKeyName(_function);
|
_label.Text = ShortKeyName(_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnKeyBindingChanged()
|
||||||
|
{
|
||||||
|
_label.Text = ShortKeyName(_function);
|
||||||
|
}
|
||||||
|
|
||||||
private string ShortKeyName(BoundKeyFunction keyFunction)
|
private string ShortKeyName(BoundKeyFunction keyFunction)
|
||||||
{
|
{
|
||||||
// need to use shortened key names so they fit in the buttons.
|
// need to use shortened key names so they fit in the buttons.
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ ui-options-header-misc = Miscellaneous
|
|||||||
ui-options-header-hotbar = Hotbar
|
ui-options-header-hotbar = Hotbar
|
||||||
ui-options-header-map-editor = Map Editor
|
ui-options-header-map-editor = Map Editor
|
||||||
ui-options-header-dev = Development
|
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-up = Move Up
|
||||||
ui-options-function-move-left = Move Left
|
ui-options-function-move-left = Move Left
|
||||||
|
|||||||
Reference in New Issue
Block a user