2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Client.GameObjects;
|
2023-07-12 15:47:45 -04:00
|
|
|
|
using static Content.Shared.Atmos.Components.GasAnalyzerComponent;
|
2020-08-08 18:24:41 +02:00
|
|
|
|
|
2021-06-19 13:25:05 +02:00
|
|
|
|
namespace Content.Client.Atmos.UI
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class GasAnalyzerBoundUserInterface : BoundUserInterface
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
2023-07-08 09:02:17 -07:00
|
|
|
|
[ViewVariables]
|
|
|
|
|
|
private GasAnalyzerWindow? _window;
|
|
|
|
|
|
|
|
|
|
|
|
public GasAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Open()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Open();
|
|
|
|
|
|
|
2023-07-12 15:47:45 -04:00
|
|
|
|
_window = new GasAnalyzerWindow();
|
2022-09-08 14:22:14 +00:00
|
|
|
|
_window.OnClose += OnClose;
|
2024-02-01 05:49:48 -07:00
|
|
|
|
_window.OpenCenteredLeft();
|
2020-08-08 18:24:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-08 14:22:14 +00:00
|
|
|
|
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
2022-09-08 14:22:14 +00:00
|
|
|
|
if (_window == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
if (message is not GasAnalyzerUserMessage cast)
|
|
|
|
|
|
return;
|
|
|
|
|
|
_window.Populate(cast);
|
2020-08-08 18:24:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-08 14:22:14 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Closes UI and tells the server to disable the analyzer
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnClose()
|
2020-08-08 18:24:41 +02:00
|
|
|
|
{
|
2022-09-08 14:22:14 +00:00
|
|
|
|
SendMessage(new GasAnalyzerDisableMessage());
|
|
|
|
|
|
Close();
|
2020-08-08 18:24:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
|
|
2022-09-08 14:22:14 +00:00
|
|
|
|
if (disposing)
|
|
|
|
|
|
_window?.Dispose();
|
2020-08-08 18:24:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|