2023-09-20 08:54:53 +01:00
|
|
|
using System.Numerics;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Ghost.Roles;
|
2021-02-12 04:35:56 +01:00
|
|
|
using Robust.Client.AutoGenerated;
|
2023-09-20 08:54:53 +01:00
|
|
|
using Robust.Client.GameObjects;
|
2021-02-12 04:35:56 +01:00
|
|
|
using Robust.Client.UserInterface.Controls;
|
2023-09-20 08:54:53 +01:00
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2021-02-12 04:35:56 +01:00
|
|
|
using Robust.Client.UserInterface.XAML;
|
2023-09-20 08:54:53 +01:00
|
|
|
using Robust.Shared.Utility;
|
2021-02-12 04:35:56 +01:00
|
|
|
|
2022-09-11 20:42:12 -07:00
|
|
|
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
2021-02-12 04:35:56 +01:00
|
|
|
{
|
|
|
|
|
[GenerateTypedNameReferences]
|
2024-11-04 03:49:42 +03:00
|
|
|
public sealed partial class GhostRoleButtonsBox : BoxContainer
|
2021-02-12 04:35:56 +01:00
|
|
|
{
|
2023-09-20 08:54:53 +01:00
|
|
|
private SpriteSystem _spriteSystem;
|
2022-04-03 01:06:29 +03:00
|
|
|
public event Action<GhostRoleInfo>? OnRoleSelected;
|
|
|
|
|
public event Action<GhostRoleInfo>? OnRoleFollow;
|
|
|
|
|
|
2024-11-04 03:49:42 +03:00
|
|
|
public GhostRoleButtonsBox(bool hasAccess, FormattedMessage? reason, IEnumerable<GhostRoleInfo> roles, SpriteSystem spriteSystem)
|
2021-02-12 04:35:56 +01:00
|
|
|
{
|
|
|
|
|
RobustXamlLoader.Load(this);
|
2023-09-20 08:54:53 +01:00
|
|
|
_spriteSystem = spriteSystem;
|
2021-02-12 04:35:56 +01:00
|
|
|
|
2022-04-03 01:06:29 +03:00
|
|
|
foreach (var role in roles)
|
|
|
|
|
{
|
2024-05-07 03:48:16 +02:00
|
|
|
var button = new GhostRoleEntryButtons(role);
|
2022-04-03 01:06:29 +03:00
|
|
|
button.RequestButton.OnPressed += _ => OnRoleSelected?.Invoke(role);
|
|
|
|
|
button.FollowButton.OnPressed += _ => OnRoleFollow?.Invoke(role);
|
|
|
|
|
|
2023-09-20 08:54:53 +01:00
|
|
|
if (!hasAccess)
|
|
|
|
|
{
|
|
|
|
|
button.RequestButton.Disabled = true;
|
|
|
|
|
|
|
|
|
|
if (reason != null && !reason.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
var tooltip = new Tooltip();
|
|
|
|
|
tooltip.SetMessage(reason);
|
|
|
|
|
button.RequestButton.TooltipSupplier = _ => tooltip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button.RequestButton.AddChild(new TextureRect
|
|
|
|
|
{
|
|
|
|
|
TextureScale = new Vector2(0.4f, 0.4f),
|
|
|
|
|
Stretch = TextureRect.StretchMode.KeepCentered,
|
|
|
|
|
Texture = _spriteSystem.Frame0(new SpriteSpecifier.Texture(new ("/Textures/Interface/Nano/lock.svg.192dpi.png"))),
|
|
|
|
|
HorizontalExpand = true,
|
|
|
|
|
HorizontalAlignment = HAlignment.Right,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-03 01:06:29 +03:00
|
|
|
Buttons.AddChild(button);
|
|
|
|
|
}
|
2021-02-12 04:35:56 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|