Files
wwdpublic/Content.Client/Atmos/UI/GasAnalyzerBoundUserInterface.cs
Kara 27895cd4d9 Open some windows non-centered to avoid covering the player (#24767)
(cherry picked from commit e212b10ca205b5a76c20a3daca4a13af435611c5)
2024-02-08 12:21:00 +01:00

51 lines
1.3 KiB
C#

using Robust.Client.GameObjects;
using static Content.Shared.Atmos.Components.GasAnalyzerComponent;
namespace Content.Client.Atmos.UI
{
public sealed class GasAnalyzerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GasAnalyzerWindow? _window;
public GasAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new GasAnalyzerWindow();
_window.OnClose += OnClose;
_window.OpenCenteredLeft();
}
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
if (_window == null)
return;
if (message is not GasAnalyzerUserMessage cast)
return;
_window.Populate(cast);
}
/// <summary>
/// Closes UI and tells the server to disable the analyzer
/// </summary>
private void OnClose()
{
SendMessage(new GasAnalyzerDisableMessage());
Close();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
_window?.Dispose();
}
}
}