CrewManifestSection.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Content.Shared.CrewManifest;
  2. using Content.Shared.StatusIcon;
  3. using Robust.Client.GameObjects;
  4. using Robust.Client.UserInterface.Controls;
  5. using Robust.Shared.Prototypes;
  6. using System.Numerics;
  7. using Content.Shared.Roles;
  8. namespace Content.Client.CrewManifest.UI;
  9. public sealed class CrewManifestSection : BoxContainer
  10. {
  11. public CrewManifestSection(
  12. IPrototypeManager prototypeManager,
  13. SpriteSystem spriteSystem,
  14. DepartmentPrototype section,
  15. List<CrewManifestEntry> entries)
  16. {
  17. Orientation = LayoutOrientation.Vertical;
  18. HorizontalExpand = true;
  19. AddChild(new Label()
  20. {
  21. StyleClasses = { "LabelBig" },
  22. Text = Loc.GetString(section.Name)
  23. });
  24. var gridContainer = new GridContainer()
  25. {
  26. HorizontalExpand = true,
  27. Columns = 2
  28. };
  29. AddChild(gridContainer);
  30. foreach (var entry in entries)
  31. {
  32. var name = new RichTextLabel()
  33. {
  34. HorizontalExpand = true,
  35. };
  36. name.SetMessage(entry.Name);
  37. var titleContainer = new BoxContainer()
  38. {
  39. Orientation = LayoutOrientation.Horizontal,
  40. HorizontalExpand = true
  41. };
  42. var title = new RichTextLabel();
  43. title.SetMessage(entry.JobTitle);
  44. if (prototypeManager.TryIndex<JobIconPrototype>(entry.JobIcon, out var jobIcon))
  45. {
  46. var icon = new TextureRect()
  47. {
  48. TextureScale = new Vector2(2, 2),
  49. VerticalAlignment = VAlignment.Center,
  50. Texture = spriteSystem.Frame0(jobIcon.Icon),
  51. Margin = new Thickness(0, 0, 4, 0)
  52. };
  53. titleContainer.AddChild(icon);
  54. titleContainer.AddChild(title);
  55. }
  56. else
  57. {
  58. titleContainer.AddChild(title);
  59. }
  60. gridContainer.AddChild(name);
  61. gridContainer.AddChild(titleContainer);
  62. }
  63. }
  64. }