using System; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.GameObjects; namespace Robust.Client.UserInterface; public static class BoundUserInterfaceExt { /// /// Helper method to create a window and also handle closing the BUI when it's closed. /// public static T CreateWindow(this BoundUserInterface bui) where T : BaseWindow, new() { var window = bui.CreateDisposableControl(); window.OpenCentered(); window.OnClose += bui.Close; return window; } /// /// Creates a control for this BUI that will be disposed when it is disposed. /// /// /// /// public static T CreateDisposableControl(this BoundUserInterface bui) where T : Control, IDisposable, new() { var control = new T(); bui.Disposals ??= []; bui.Disposals.Add(control); return control; } }