Add support for custom controls in the character menu (#19567)

This commit is contained in:
Nemanja
2023-08-27 04:24:24 -04:00
committed by GitHub
parent 70e0520a2c
commit 3e93e963b5
4 changed files with 35 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
using Content.Shared.Objectives;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
namespace Content.Client.CharacterInfo;
@@ -43,10 +44,16 @@ public sealed class CharacterInfoSystem : EntitySystem
private void OnCharacterInfoEvent(CharacterInfoEvent msg, EntitySessionEventArgs args)
{
var data = new CharacterData(msg.EntityUid, msg.JobTitle, msg.Objectives, msg.Briefing, Name(msg.EntityUid));
OnCharacterUpdate?.Invoke(data);
}
public List<Control> GetCharacterInfoControls(EntityUid uid)
{
var ev = new GetCharacterInfoControlsEvent(uid);
RaiseLocalEvent(uid, ref ev, true);
return ev.Controls;
}
public readonly record struct CharacterData(
EntityUid Entity,
string Job,
@@ -54,4 +61,15 @@ public sealed class CharacterInfoSystem : EntitySystem
string Briefing,
string EntityName
);
/// <summary>
/// Event raised to get additional controls to display in the character info menu.
/// </summary>
[ByRefEvent]
public readonly record struct GetCharacterInfoControlsEvent(EntityUid Entity)
{
public readonly List<Control> Controls = new();
public readonly EntityUid Entity = Entity;
}
}