1
0

BountyHistoryEntry.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Content.Client.Message;
  2. using Content.Shared.Cargo;
  3. using Content.Shared.Cargo.Prototypes;
  4. using Robust.Client.AutoGenerated;
  5. using Robust.Client.UserInterface.Controls;
  6. using Robust.Client.UserInterface.XAML;
  7. using Robust.Shared.Prototypes;
  8. using Robust.Shared.Timing;
  9. namespace Content.Client.Cargo.UI;
  10. [GenerateTypedNameReferences]
  11. public sealed partial class BountyHistoryEntry : BoxContainer
  12. {
  13. [Dependency] private readonly IPrototypeManager _prototype = default!;
  14. public BountyHistoryEntry(CargoBountyHistoryData bounty)
  15. {
  16. RobustXamlLoader.Load(this);
  17. IoCManager.InjectDependencies(this);
  18. if (!_prototype.TryIndex(bounty.Bounty, out var bountyPrototype))
  19. return;
  20. var items = new List<string>();
  21. foreach (var entry in bountyPrototype.Entries)
  22. {
  23. items.Add(Loc.GetString("bounty-console-manifest-entry",
  24. ("amount", entry.Amount),
  25. ("item", Loc.GetString(entry.Name))));
  26. }
  27. ManifestLabel.SetMarkup(Loc.GetString("bounty-console-manifest-label", ("item", string.Join(", ", items))));
  28. RewardLabel.SetMarkup(Loc.GetString("bounty-console-reward-label", ("reward", bountyPrototype.Reward)));
  29. IdLabel.SetMarkup(Loc.GetString("bounty-console-id-label", ("id", bounty.Id)));
  30. TimestampLabel.SetMarkup(bounty.Timestamp.ToString(@"hh\:mm\:ss"));
  31. if (bounty.Result == CargoBountyHistoryData.BountyResult.Completed)
  32. {
  33. NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-completed-label"));
  34. }
  35. else
  36. {
  37. NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-skipped-label",
  38. ("id", bounty.ActorName ?? "")));
  39. }
  40. }
  41. }