1
0

PlaytimeStatsEntry.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. using Content.Shared.Localizations;
  2. using Robust.Client.AutoGenerated;
  3. using Robust.Client.Graphics;
  4. using Robust.Client.UserInterface.Controls;
  5. using Robust.Client.UserInterface.XAML;
  6. namespace Content.Client.Info.PlaytimeStats;
  7. [GenerateTypedNameReferences]
  8. public sealed partial class PlaytimeStatsEntry : ContainerButton
  9. {
  10. public TimeSpan Playtime { get; private set; } // new TimeSpan property
  11. public PlaytimeStatsEntry(string role, TimeSpan playtime, StyleBox styleBox)
  12. {
  13. RobustXamlLoader.Load(this);
  14. RoleLabel.Text = role;
  15. Playtime = playtime; // store the TimeSpan value directly
  16. PlaytimeLabel.Text = ContentLocalizationManager.FormatPlaytime(playtime); // convert to string for display
  17. BackgroundColorPanel.PanelOverride = styleBox;
  18. }
  19. public void UpdateShading(StyleBoxFlat styleBox)
  20. {
  21. BackgroundColorPanel.PanelOverride = styleBox;
  22. }
  23. public string? PlaytimeText => PlaytimeLabel.Text;
  24. public string? RoleText => RoleLabel.Text;
  25. }