Files
tbd-station-14/Content.Client/Fluids/UI/AbsorbentItemStatus.xaml.cs
Pieter-Jan Briers 25b620de23 Lower minimum size of absorbent item status (#35804)
80f2dc6dd3 fixed BoxContainer so that the actual specified MinimumSize gets used. This is a problem because for the absorbent item status it's way too high so it looks silly.
2025-04-10 20:48:13 +10:00

55 lines
1.5 KiB
C#

using System.Linq;
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Fluids;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Client.Fluids.UI
{
[GenerateTypedNameReferences]
public sealed partial class AbsorbentItemStatus : SplitBar
{
private readonly IEntityManager _entManager;
private readonly EntityUid _uid;
private Dictionary<Color, float> _progress = new();
public AbsorbentItemStatus(EntityUid uid, IEntityManager entManager)
{
RobustXamlLoader.Load(this);
_uid = uid;
_entManager = entManager;
MinBarSize = new Vector2(10, 0);
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_entManager.TryGetComponent<AbsorbentComponent>(_uid, out var absorbent))
return;
var oldProgress = _progress.ShallowClone();
_progress.Clear();
foreach (var item in absorbent.Progress)
{
_progress[item.Key] = item.Value;
}
if (oldProgress.OrderBy(x => x.Key.ToArgb()).SequenceEqual(_progress))
return;
Bar.Clear();
foreach (var (key, value) in absorbent.Progress)
{
Bar.AddEntry(value, key);
}
}
}
}