Add support for custom controls in the character menu (#19567)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user