CatStation/Content.Client/UserInterface/Systems/EscapeMenu/OptionsUIController.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

69 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 partial class OptionsUIController : UIController
{
[Dependency] private 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();
}
}
}