PointSystem.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Content.Client.CharacterInfo;
  2. using Content.Client.Message;
  3. using Content.Shared.Points;
  4. using Robust.Client.UserInterface;
  5. using Robust.Client.UserInterface.Controls;
  6. namespace Content.Client.Points;
  7. /// <inheritdoc/>
  8. public sealed class PointSystem : SharedPointSystem
  9. {
  10. [Dependency] private readonly CharacterInfoSystem _characterInfo = default!;
  11. /// <inheritdoc/>
  12. public override void Initialize()
  13. {
  14. base.Initialize();
  15. SubscribeLocalEvent<PointManagerComponent, AfterAutoHandleStateEvent>(OnHandleState);
  16. SubscribeLocalEvent<CharacterInfoSystem.GetCharacterInfoControlsEvent>(OnGetCharacterInfoControls);
  17. }
  18. private void OnHandleState(EntityUid uid, PointManagerComponent component, ref AfterAutoHandleStateEvent args)
  19. {
  20. _characterInfo.RequestCharacterInfo();
  21. }
  22. private void OnGetCharacterInfoControls(ref CharacterInfoSystem.GetCharacterInfoControlsEvent ev)
  23. {
  24. foreach (var point in EntityQuery<PointManagerComponent>())
  25. {
  26. var box = new BoxContainer
  27. {
  28. Margin = new Thickness(5),
  29. Orientation = BoxContainer.LayoutOrientation.Vertical
  30. };
  31. var title = new RichTextLabel
  32. {
  33. HorizontalAlignment = Control.HAlignment.Center
  34. };
  35. title.SetMarkup(Loc.GetString("point-scoreboard-header"));
  36. var text = new RichTextLabel();
  37. text.SetMessage(point.Scoreboard);
  38. box.AddChild(title);
  39. box.AddChild(text);
  40. ev.Controls.Add(box);
  41. }
  42. }
  43. }