mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Added set English language checkbox (#2136)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Robust.Shared;
|
||||
using System.Threading;
|
||||
using OpenToolkit.GraphicsLibraryFramework;
|
||||
using Robust.Client.Input;
|
||||
@@ -8,6 +9,8 @@ using GlfwKey = OpenToolkit.GraphicsLibraryFramework.Keys;
|
||||
using GlfwButton = OpenToolkit.GraphicsLibraryFramework.MouseButton;
|
||||
using static Robust.Client.Input.Mouse;
|
||||
using static Robust.Client.Input.Keyboard;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Robust.Client.Graphics.Clyde
|
||||
{
|
||||
@@ -22,6 +25,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
private void InitKeyMap()
|
||||
{
|
||||
_printableKeyNameMap.Clear();
|
||||
// From GLFW's source code: this is the actual list of "printable" keys
|
||||
// that GetKeyName returns something for.
|
||||
CacheKey(Keys.KeyPadEqual);
|
||||
@@ -41,8 +45,18 @@ namespace Robust.Client.Graphics.Clyde
|
||||
if (rKey == Key.Unknown)
|
||||
return;
|
||||
|
||||
var name = GLFW.GetKeyName(key, 0);
|
||||
if (name != null)
|
||||
string name;
|
||||
|
||||
if (!_clyde._cfg.GetCVar(CVars.DisplayUSQWERTYHotkeys))
|
||||
{
|
||||
name = GLFW.GetKeyName(key, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = key.ToString();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
_printableKeyNameMap.Add(rKey, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using OpenToolkit.GraphicsLibraryFramework;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -16,6 +17,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly ILocalizationManager _loc = default!;
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
|
||||
private readonly Clyde _clyde;
|
||||
|
||||
@@ -39,6 +41,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
#if DEBUG
|
||||
_cfg.OnValueChanged(CVars.DisplayWin32Experience, b => _win32Experience = b, true);
|
||||
#endif
|
||||
_cfg.OnValueChanged(CVars.DisplayUSQWERTYHotkeys, ReInitKeyMap);
|
||||
|
||||
InitChannels();
|
||||
|
||||
@@ -60,6 +63,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
if (_glfwInitialized)
|
||||
{
|
||||
_sawmill.Debug("Terminating GLFW.");
|
||||
_cfg.UnsubValueChanged(CVars.DisplayUSQWERTYHotkeys, ReInitKeyMap);
|
||||
GLFW.Terminate();
|
||||
}
|
||||
}
|
||||
@@ -69,6 +73,12 @@ namespace Robust.Client.Graphics.Clyde
|
||||
// Not currently used
|
||||
}
|
||||
|
||||
private void ReInitKeyMap(bool onValueChanged)
|
||||
{
|
||||
InitKeyMap();
|
||||
_inputManager.InputModeChanged();
|
||||
}
|
||||
|
||||
private bool InitGlfw()
|
||||
{
|
||||
StoreCallbacks();
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace Robust.Client.Input
|
||||
|
||||
event Action<IKeyBinding> OnKeyBindingAdded;
|
||||
event Action<IKeyBinding> OnKeyBindingRemoved;
|
||||
event Action OnInputModeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the keybinds bound to a specific function.
|
||||
@@ -131,5 +132,7 @@ namespace Robust.Client.Input
|
||||
bool IsKeyFunctionModified(BoundKeyFunction function);
|
||||
|
||||
bool IsKeyDown(Keyboard.Key key);
|
||||
|
||||
void InputModeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Input;
|
||||
@@ -43,6 +45,7 @@ namespace Robust.Client.Input
|
||||
[Dependency] private readonly IResourceManager _resourceMan = default!;
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
[Dependency] private readonly IUserInterfaceManagerInternal _uiMgr = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private bool _currentlyFindingViewport;
|
||||
|
||||
@@ -98,6 +101,7 @@ namespace Robust.Client.Input
|
||||
public event KeyEventAction? FirstChanceOnKeyEvent;
|
||||
public event Action<IKeyBinding>? OnKeyBindingAdded;
|
||||
public event Action<IKeyBinding>? OnKeyBindingRemoved;
|
||||
public event Action? OnInputModeChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Initialize()
|
||||
@@ -569,6 +573,8 @@ namespace Robust.Client.Input
|
||||
OnKeyBindingRemoved?.Invoke(binding);
|
||||
}
|
||||
|
||||
public void InputModeChanged() => OnInputModeChanged?.Invoke();
|
||||
|
||||
private void RegisterBinding(KeyBinding binding, bool markModified = true)
|
||||
{
|
||||
// we sort larger combos first so they take priority over smaller (single key) combos,
|
||||
|
||||
@@ -445,6 +445,12 @@ namespace Robust.Shared
|
||||
public static readonly CVarDef<string> DisplaySplashLogo =
|
||||
CVarDef.Create("display.splash_logo", "", CVar.CLIENTONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Use US QWERTY hotkeys.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> DisplayUSQWERTYHotkeys =
|
||||
CVarDef.Create("display.use_US_QWERTY_hotkeys", false, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/*
|
||||
* AUDIO
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user