]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Syringe UI cached updates (#25581)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Mon, 26 Feb 2024 06:17:56 +0000 (22:17 -0800)
committerGitHub <noreply@github.com>
Mon, 26 Feb 2024 06:17:56 +0000 (17:17 +1100)
Injector status UI cached values

Co-authored-by: Plykiya <plykiya@protonmail.com>
Content.Client/Chemistry/UI/InjectorStatusControl.cs

index 979e9ea64555435caeda8fdd53b1fe14ae544911..9cb699330c233155248de7bbe9f539f078c9263f 100644 (file)
@@ -2,6 +2,7 @@ using Content.Client.Message;
 using Content.Client.Stylesheets;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.EntitySystems;
+using Content.Shared.FixedPoint;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Shared.Timing;
@@ -14,6 +15,10 @@ public sealed class InjectorStatusControl : Control
     private readonly SharedSolutionContainerSystem _solutionContainers;
     private readonly RichTextLabel _label;
 
+    private FixedPoint2 PrevVolume;
+    private FixedPoint2 PrevMaxVolume;
+    private InjectorToggleMode PrevToggleState;
+
     public InjectorStatusControl(Entity<InjectorComponent> parent, SharedSolutionContainerSystem solutionContainers)
     {
         _parent = parent;
@@ -29,6 +34,16 @@ public sealed class InjectorStatusControl : Control
         if (!_solutionContainers.TryGetSolution(_parent.Owner, InjectorComponent.SolutionName, out _, out var solution))
             return;
 
+        // only updates the UI if any of the details are different than they previously were
+        if (PrevVolume == solution.Volume
+            && PrevMaxVolume == solution.MaxVolume
+            && PrevToggleState == _parent.Comp.ToggleState)
+            return;
+
+        PrevVolume = solution.Volume;
+        PrevMaxVolume = solution.MaxVolume;
+        PrevToggleState = _parent.Comp.ToggleState;
+
         // Update current volume and injector state
         var modeStringLocalized = Loc.GetString(_parent.Comp.ToggleState switch
         {