2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.Items.Components;
|
|
|
|
|
using Content.Client.Message;
|
|
|
|
|
using Content.Client.Stylesheets;
|
|
|
|
|
using Content.Shared.Stacks;
|
2020-01-09 00:27:52 +01:00
|
|
|
using Robust.Client.UserInterface;
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
2021-08-30 11:49:09 +02:00
|
|
|
using Robust.Shared.Analyzers;
|
2020-01-09 00:27:52 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
using Robust.Shared.Timing;
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Stack
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2021-08-30 11:49:09 +02:00
|
|
|
[RegisterComponent, Friend(typeof(StackSystem), typeof(StatusControl))]
|
2020-10-08 17:41:23 +02:00
|
|
|
[ComponentReference(typeof(SharedStackComponent))]
|
2020-01-09 00:27:52 +01:00
|
|
|
public class StackComponent : SharedStackComponent, IItemStatus
|
|
|
|
|
{
|
2021-08-30 11:49:09 +02:00
|
|
|
[ViewVariables]
|
|
|
|
|
public bool UiUpdateNeeded { get; set; }
|
2020-01-09 00:27:52 +01:00
|
|
|
|
2021-05-26 10:20:57 +02:00
|
|
|
public Control MakeControl()
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2021-05-26 10:20:57 +02:00
|
|
|
return new StatusControl(this);
|
2020-01-09 00:27:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private sealed class StatusControl : Control
|
|
|
|
|
{
|
|
|
|
|
private readonly StackComponent _parent;
|
|
|
|
|
private readonly RichTextLabel _label;
|
|
|
|
|
|
|
|
|
|
public StatusControl(StackComponent parent)
|
|
|
|
|
{
|
|
|
|
|
_parent = parent;
|
2020-04-04 15:10:51 +02:00
|
|
|
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
|
2020-01-09 00:27:52 +01:00
|
|
|
AddChild(_label);
|
|
|
|
|
|
2021-08-30 11:49:09 +02:00
|
|
|
parent.UiUpdateNeeded = true;
|
2020-01-09 00:27:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-26 17:10:31 -07:00
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
2021-03-26 17:10:31 -07:00
|
|
|
base.FrameUpdate(args);
|
2020-01-09 00:27:52 +01:00
|
|
|
|
2021-08-30 11:49:09 +02:00
|
|
|
if (!_parent.UiUpdateNeeded)
|
2020-01-09 00:27:52 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-30 11:49:09 +02:00
|
|
|
_parent.UiUpdateNeeded = false;
|
2020-01-09 00:27:52 +01:00
|
|
|
|
2021-02-28 20:02:03 -04:00
|
|
|
_label.SetMarkup(Loc.GetString("comp-stack-status", ("count", _parent.Count)));
|
2020-01-09 00:27:52 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-28 20:02:03 -04:00
|
|
|
}
|