CargoBountyMenu.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Content.Client.UserInterface.Controls;
  2. using Content.Shared.Cargo;
  3. using Robust.Client.AutoGenerated;
  4. using Robust.Client.UserInterface;
  5. using Robust.Client.UserInterface.XAML;
  6. namespace Content.Client.Cargo.UI;
  7. [GenerateTypedNameReferences]
  8. public sealed partial class CargoBountyMenu : FancyWindow
  9. {
  10. public Action<string>? OnLabelButtonPressed;
  11. public Action<string>? OnSkipButtonPressed;
  12. public CargoBountyMenu()
  13. {
  14. RobustXamlLoader.Load(this);
  15. MasterTabContainer.SetTabTitle(0, Loc.GetString("bounty-console-tab-available-label"));
  16. MasterTabContainer.SetTabTitle(1, Loc.GetString("bounty-console-tab-history-label"));
  17. }
  18. public void UpdateEntries(List<CargoBountyData> bounties, List<CargoBountyHistoryData> history, TimeSpan untilNextSkip)
  19. {
  20. BountyEntriesContainer.Children.Clear();
  21. foreach (var b in bounties)
  22. {
  23. var entry = new BountyEntry(b, untilNextSkip);
  24. entry.OnLabelButtonPressed += () => OnLabelButtonPressed?.Invoke(b.Id);
  25. entry.OnSkipButtonPressed += () => OnSkipButtonPressed?.Invoke(b.Id);
  26. BountyEntriesContainer.AddChild(entry);
  27. }
  28. BountyEntriesContainer.AddChild(new Control
  29. {
  30. MinHeight = 10
  31. });
  32. BountyHistoryContainer.Children.Clear();
  33. if (history.Count == 0)
  34. {
  35. NoHistoryLabel.Visible = true;
  36. }
  37. else
  38. {
  39. NoHistoryLabel.Visible = false;
  40. // Show the history in reverse, so last entry is first in the list
  41. for (var i = history.Count - 1; i >= 0; i--)
  42. {
  43. BountyHistoryContainer.AddChild(new BountyHistoryEntry(history[i]));
  44. }
  45. }
  46. }
  47. }