* Fixes and adds many localization keys from #34343 Open * Fix comment, that is not how that works. * Update Resources/Locale/en-US/components/screen-component.ftl Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Fixes cmd-parse-failure-int -> cmd-parse-failure-integer in OptionsUIController.cs, removes cmd-parse-failure-int from options-menu.ftl --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
70 lines
1.6 KiB
C#
70 lines
1.6 KiB
C#
using Content.Client.Options.UI;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Client.UserInterface.Systems.EscapeMenu;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class OptionsUIController : UIController
|
|
{
|
|
[Dependency] private readonly IConsoleHost _con = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
_con.RegisterCommand("options", Loc.GetString("cmd-options-desc"), Loc.GetString("cmd-options-help"), OptionsCommand);
|
|
}
|
|
|
|
private void OptionsCommand(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length == 0)
|
|
{
|
|
ToggleWindow();
|
|
return;
|
|
}
|
|
OpenWindow();
|
|
|
|
if (!int.TryParse(args[0], out var tab))
|
|
{
|
|
shell.WriteError(Loc.GetString("cmd-parse-failure-integer", ("arg", args[0])));
|
|
return;
|
|
}
|
|
|
|
_optionsWindow.Tabs.CurrentTab = tab;
|
|
}
|
|
|
|
private OptionsMenu _optionsWindow = default!;
|
|
|
|
private void EnsureWindow()
|
|
{
|
|
if (_optionsWindow is { Disposed: false })
|
|
return;
|
|
|
|
_optionsWindow = UIManager.CreateWindow<OptionsMenu>();
|
|
}
|
|
|
|
public void OpenWindow()
|
|
{
|
|
EnsureWindow();
|
|
|
|
_optionsWindow.UpdateTabs();
|
|
|
|
_optionsWindow.OpenCentered();
|
|
_optionsWindow.MoveToFront();
|
|
}
|
|
|
|
public void ToggleWindow()
|
|
{
|
|
EnsureWindow();
|
|
|
|
if (_optionsWindow.IsOpen)
|
|
{
|
|
_optionsWindow.Close();
|
|
}
|
|
else
|
|
{
|
|
OpenWindow();
|
|
}
|
|
}
|
|
}
|