mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 00:27:59 +00:00
70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using System.Linq;
|
|
using Content.Client.Humanoid;
|
|
using Content.Shared.Clothing;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Humanoid.Prototypes;
|
|
using Content.Shared.Preferences;
|
|
using Content.Shared.Preferences.Loadouts;
|
|
using Content.Shared.Roles;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Lobby.UI;
|
|
|
|
/// <summary>
|
|
/// Holds character data on the side of the setup GUI.
|
|
/// </summary>
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class CharacterPickerButton : ContainerButton
|
|
{
|
|
/// <summary>
|
|
/// Invoked if we should delete the attached character
|
|
/// </summary>
|
|
public event Action? OnDeletePressed;
|
|
|
|
public CharacterPickerButton(
|
|
IPrototypeManager prototypeManager,
|
|
ISharedPlayerManager playerMan,
|
|
ButtonGroup group,
|
|
HumanoidCharacterProfile profile,
|
|
bool isSelected)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
AddStyleClass(StyleClassButton);
|
|
ToggleMode = true;
|
|
Group = group;
|
|
var description = profile.Name;
|
|
|
|
View.LoadPreview(profile);
|
|
|
|
var highPriorityJob = profile.JobPriorities.SingleOrDefault(p => p.Value == JobPriority.High).Key;
|
|
if (highPriorityJob != default)
|
|
{
|
|
var jobName = prototypeManager.Index(highPriorityJob).LocalizedName;
|
|
description = $"{description}\n{jobName}";
|
|
}
|
|
|
|
Pressed = isSelected;
|
|
DeleteButton.Visible = !isSelected;
|
|
|
|
DescriptionLabel.Text = description;
|
|
|
|
ConfirmDeleteButton.OnPressed += _ =>
|
|
{
|
|
Parent?.RemoveChild(this);
|
|
Parent?.RemoveChild(ConfirmDeleteButton);
|
|
OnDeletePressed?.Invoke();
|
|
};
|
|
|
|
DeleteButton.OnPressed += _ =>
|
|
{
|
|
DeleteButton.Visible = false;
|
|
ConfirmDeleteButton.Visible = true;
|
|
};
|
|
}
|
|
}
|