fish-station/Content.Client/Botany/PlantAnalyzer/PlantAnalyzerBoundUserInterface.cs
Vigers Ray 2c1db3ffdf
Анализатор растений (#1755)
Co-authored-by: Ignaz Kraft <ignaz.k@live.de>
2025-04-12 04:05:07 +03:00

42 lines
1.1 KiB
C#

using Content.Shared.Botany.PlantAnalyzer;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
namespace Content.Client.Botany.PlantAnalyzer;
[UsedImplicitly]
public sealed class PlantAnalyzerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PlantAnalyzerWindow? _window;
public PlantAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<PlantAnalyzerWindow>();
_window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
_window.Print.OnPressed += _ => Print();
}
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
if (_window == null)
return;
if (message is not PlantAnalyzerScannedUserMessage cast)
return;
_window.Populate(cast);
}
private void Print()
{
SendMessage(new PlantAnalyzerPrintMessage());
if (_window != null)
_window.Print.Disabled = true;
}
}