mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* icon group prototype * prototype v2 * agent id uses groups * working UI using groups * UI work, new header * formatting and misc work * fix some texture scaling * aesthetics * tabs, scrollbar, MinSize * commit * commit * commit * commit * Revert "commit" This reverts commit 8f29ae30c69670c6dc8d5fba3dd6bd98f574830d. * we're back * well enough * Final visuals for the Id (for now) * code cleaning * minor cleanup * self review * id card system changes * try index -> resolve * DisposeAllChildren -> RemoveAllChildren * fix the id cards * all pretty * unneeded * merge * Review by Fildrance * Review by Pok * fix * cleanup * refactor: revert icon setsize changes back to good old '32', made container button be resizable for localization reasons * jobIconGroup --------- Co-authored-by: iaada <iaada@users.noreply.github.com> Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com> Co-authored-by: Fildrance <fildrance@gmail.com>
64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using Content.Shared.Access.Components;
|
|
using Content.Shared.Access.Systems;
|
|
using Content.Shared.StatusIcon;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Access.UI;
|
|
|
|
/// <summary>
|
|
/// Initializes a <see cref="AgentIDCardWindow"/> and updates it when new server messages are received.
|
|
/// </summary>
|
|
public sealed class AgentIDCardBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
|
|
{
|
|
private AgentIDCardWindow? _window;
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
if (!EntMan.TryGetComponent(Owner, out AgentIDCardComponent? agent))
|
|
return;
|
|
|
|
_window = this.CreateWindow<AgentIDCardWindow>();
|
|
|
|
_window.OnNameChanged += OnNameChanged;
|
|
_window.OnJobChanged += OnJobChanged;
|
|
_window.OnJobIconChanged += OnJobIconChanged;
|
|
|
|
ProtoId<JobIconPrototype> currentIcon = default;
|
|
if (EntMan.TryGetComponent<IdCardComponent>(Owner, out var card))
|
|
currentIcon = card.JobIcon;
|
|
|
|
_window.SetAllowedIcons(agent.IconGroups, currentIcon);
|
|
Update();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
if (_window == null)
|
|
return;
|
|
|
|
if (!EntMan.TryGetComponent<IdCardComponent>(Owner, out var card))
|
|
return;
|
|
|
|
_window.Update(card);
|
|
}
|
|
|
|
private void OnNameChanged(string newName)
|
|
{
|
|
SendPredictedMessage(new AgentIDCardNameChangedMessage(newName));
|
|
}
|
|
|
|
private void OnJobChanged(string newJob)
|
|
{
|
|
SendPredictedMessage(new AgentIDCardJobChangedMessage(newJob));
|
|
}
|
|
|
|
private void OnJobIconChanged(ProtoId<JobIconPrototype> newJobIconId)
|
|
{
|
|
SendPredictedMessage(new AgentIDCardJobIconChangedMessage(newJobIconId));
|
|
}
|
|
}
|