From 70a90ad31f08cdb5b6444b524545144ec927b14b Mon Sep 17 00:00:00 2001 From: Dvir <39403717+dvir001@users.noreply.github.com> Date: Sun, 8 Sep 2024 10:41:25 +0300 Subject: [PATCH] Plant Analyzer (#1904) --- .../UI/PlantAnalyzerBoundUserInterface.cs | 53 ++++ .../PlantAnalyzer/UI/PlantAnalyzerWindow.xaml | 49 ++++ .../UI/PlantAnalyzerWindow.xaml.cs | 217 +++++++++++++++ .../Components/PlantAnalyzerComponent.cs | 33 +++ .../_NF/Botany/Systems/PlantAnalyzerSystem.cs | 257 ++++++++++++++++++ .../PlantAnalyzerDoAfterEvent.cs | 9 + ...lantAnalyzerScannedSeedPlantInformation.cs | 94 +++++++ .../_NF/PlantAnalyzer/PlantAnalyzerUiKey.cs | 9 + .../_NF/botany/components/plantanalyzer.ftl | 52 ++++ Resources/Locale/en-US/_NF/seeds/seeds.ftl | 9 +- .../Objects/Devices/plant_analyzer.yml | 66 +++++ .../Prototypes/_NF/Recipes/Lathes/botany.yml | 9 + .../Devices/plant_analyzer.rsi/icon.png | Bin 0 -> 2189 bytes .../Devices/plant_analyzer.rsi/meta.json | 40 +++ .../plant_analyzer.rsi/plantanalyzer.png | Bin 0 -> 364 bytes .../Devices/plant_analyzer.rsi/unlit.png | Bin 0 -> 1181 bytes 16 files changed, 894 insertions(+), 3 deletions(-) create mode 100644 Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerBoundUserInterface.cs create mode 100644 Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerWindow.xaml create mode 100644 Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerWindow.xaml.cs create mode 100644 Content.Server/_NF/Botany/Components/PlantAnalyzerComponent.cs create mode 100644 Content.Server/_NF/Botany/Systems/PlantAnalyzerSystem.cs create mode 100644 Content.Shared/_NF/PlantAnalyzer/PlantAnalyzerDoAfterEvent.cs create mode 100644 Content.Shared/_NF/PlantAnalyzer/PlantAnalyzerScannedSeedPlantInformation.cs create mode 100644 Content.Shared/_NF/PlantAnalyzer/PlantAnalyzerUiKey.cs create mode 100644 Resources/Locale/en-US/_NF/botany/components/plantanalyzer.ftl create mode 100644 Resources/Prototypes/_NF/Entities/Objects/Devices/plant_analyzer.yml create mode 100644 Resources/Prototypes/_NF/Recipes/Lathes/botany.yml create mode 100644 Resources/Textures/_NF/Objects/Devices/plant_analyzer.rsi/icon.png create mode 100644 Resources/Textures/_NF/Objects/Devices/plant_analyzer.rsi/meta.json create mode 100644 Resources/Textures/_NF/Objects/Devices/plant_analyzer.rsi/plantanalyzer.png create mode 100644 Resources/Textures/_NF/Objects/Devices/plant_analyzer.rsi/unlit.png diff --git a/Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerBoundUserInterface.cs b/Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerBoundUserInterface.cs new file mode 100644 index 00000000000..70a02af09eb --- /dev/null +++ b/Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerBoundUserInterface.cs @@ -0,0 +1,53 @@ +using Content.Shared._NF.PlantAnalyzer; +using JetBrains.Annotations; + +namespace Content.Client._NF.PlantAnalyzer.UI; + +[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 = new PlantAnalyzerWindow(this) + { + Title = Loc.GetString("plant-analyzer-interface-title"), + }; + _window.OnClose += Close; + _window.OpenCenteredLeft(); + } + + protected override void ReceiveMessage(BoundUserInterfaceMessage message) + { + if (_window == null) + return; + + if (message is not PlantAnalyzerScannedSeedPlantInformation cast) + return; + _window.Populate(cast); + } + + public void AdvPressed(bool scanMode) + { + SendMessage(new PlantAnalyzerSetMode(scanMode)); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) + return; + + if (_window != null) + _window.OnClose -= Close; + + _window?.Dispose(); + } +} diff --git a/Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerWindow.xaml b/Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerWindow.xaml new file mode 100644 index 00000000000..684517a3030 --- /dev/null +++ b/Content.Client/_NF/PlantAnalyzer/UI/PlantAnalyzerWindow.xaml @@ -0,0 +1,49 @@ + + + + +