Files
tbd-station-14/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
2023-12-26 18:24:53 -04:00

40 lines
1.1 KiB
C#

using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class LogProbeUiFragment : BoxContainer
{
public LogProbeUiFragment()
{
RobustXamlLoader.Load(this);
}
public void UpdateState(List<PulledAccessLog> logs)
{
ProbedDeviceContainer.RemoveAllChildren();
//Reverse the list so the oldest entries appear at the bottom
logs.Reverse();
var count = 1;
foreach (var log in logs)
{
AddAccessLog(log, count);
count++;
}
}
private void AddAccessLog(PulledAccessLog log, int numberLabelText)
{
var timeLabelText = TimeSpan.FromSeconds(Math.Truncate(log.Time.TotalSeconds)).ToString();
var accessorLabelText = log.Accessor;
var entry = new LogProbeUiEntry(numberLabelText, timeLabelText, accessorLabelText);
ProbedDeviceContainer.AddChild(entry);
}
}