Files
tbd-station-14/Content.Client/Chemistry/UI/HyposprayStatusControl.cs
Plykiya f192d7901f Hyposprays Draw from Jugs (#25544)
* Hyposprays Draw from Jugs

* Fix last onlyMobs usage in yml

* Some Suggested Changes

* Remove unnecessary datafield name declarations

* Remove unnecessary dirtying of component

* Same line parentheses

* Added client-side HypospraySystem

* Cache UI values and only updates if values change

* empty line

* Update label

* Label change

* Reimplement ReactionMixerSystem

* Remove DataField from Hypospray Toggle Mode

* Change ToggleMode from enum to Bool OnlyAffectsMobs

* Add DataField required back since it's required for replays...?

* update EligibleEntity and uses of it

* Add user argument back

* Adds newline

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Guard for dirty entity

* Adds summary tag

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2024-03-30 14:59:16 +11:00

59 lines
2.0 KiB
C#

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;
namespace Content.Client.Chemistry.UI;
public sealed class HyposprayStatusControl : Control
{
private readonly Entity<HyposprayComponent> _parent;
private readonly RichTextLabel _label;
private readonly SharedSolutionContainerSystem _solutionContainers;
private FixedPoint2 PrevVolume;
private FixedPoint2 PrevMaxVolume;
private bool PrevOnlyAffectsMobs;
public HyposprayStatusControl(Entity<HyposprayComponent> parent, SharedSolutionContainerSystem solutionContainers)
{
_parent = parent;
_solutionContainers = solutionContainers;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.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
&& PrevOnlyAffectsMobs == _parent.Comp.OnlyAffectsMobs)
return;
PrevVolume = solution.Volume;
PrevMaxVolume = solution.MaxVolume;
PrevOnlyAffectsMobs = _parent.Comp.OnlyAffectsMobs;
var modeStringLocalized = Loc.GetString(_parent.Comp.OnlyAffectsMobs switch
{
false => "hypospray-all-mode-text",
true => "hypospray-mobs-only-mode-text",
});
_label.SetMarkup(Loc.GetString("hypospray-volume-label",
("currentVolume", solution.Volume),
("totalVolume", solution.MaxVolume),
("modeString", modeStringLocalized)));
}
}