CatStation/Content.Client/UserInterface/Systems/CloseWindow/CloseAllWindowsUIController.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

34 lines
1.1 KiB
C#

using Content.Client.Gameplay;
using Content.Client.Info;
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
namespace Content.Client.UserInterface.Systems.Info;
public sealed partial class CloseAllWindowsUIController : UIController
{
[Dependency] private IInputManager _inputManager = default!;
[Dependency] private IUserInterfaceManager _uiManager = default!;
public override void Initialize()
{
_inputManager.SetInputCommand(EngineKeyFunctions.WindowCloseAll,
InputCmdHandler.FromDelegate(session => CloseAllWindows()));
}
private void CloseAllWindows()
{
foreach (var childControl in new List<Control>(_uiManager.WindowRoot.Children)) // Copy children list as it will be modified on Close()
{
if (childControl is BaseWindow)
{
((BaseWindow) childControl).Close();
}
}
}
}