1
0

StackStatusControl.cs 981 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Content.Client.Message;
  2. using Content.Client.Stylesheets;
  3. using Content.Shared.Stacks;
  4. using Robust.Client.UserInterface;
  5. using Robust.Client.UserInterface.Controls;
  6. using Robust.Shared.Timing;
  7. namespace Content.Client.Stack;
  8. public sealed class StackStatusControl : Control
  9. {
  10. private readonly StackComponent _parent;
  11. private readonly RichTextLabel _label;
  12. public StackStatusControl(StackComponent parent)
  13. {
  14. _parent = parent;
  15. _label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
  16. _label.SetMarkup(Loc.GetString("comp-stack-status", ("count", _parent.Count)));
  17. AddChild(_label);
  18. }
  19. protected override void FrameUpdate(FrameEventArgs args)
  20. {
  21. base.FrameUpdate(args);
  22. if (!_parent.UiUpdateNeeded)
  23. {
  24. return;
  25. }
  26. _parent.UiUpdateNeeded = false;
  27. _label.SetMarkup(Loc.GetString("comp-stack-status", ("count", _parent.Count)));
  28. }
  29. }