mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-20 23:17:43 +03:00
# Description Ports over collapsible ghost role user interface, alongside making the ghost roles button red only when count increases from last view. Video under media. --- <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/c23ca06d-a4ef-413d-be3a-6980b456e5f3 </p> </details> --- # Changelog 🆑 - tweak: Ported over ghost role UI QoL --------- Co-authored-by: MilenVolf <63782763+MilenVolf@users.noreply.github.com> Co-authored-by: Intoxicating-Innocence <188202277+Intoxicating-Innocence@users.noreply.github.com> Co-authored-by: Dakota <72140289+1337Dakota@users.noreply.github.com> Co-authored-by: Timfa <timfalken@hotmail.com>
56 lines
2.1 KiB
C#
56 lines
2.1 KiB
C#
using System.Numerics;
|
|
using Content.Shared.Ghost.Roles;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class GhostRoleButtonsBox : BoxContainer
|
|
{
|
|
private SpriteSystem _spriteSystem;
|
|
public event Action<GhostRoleInfo>? OnRoleSelected;
|
|
public event Action<GhostRoleInfo>? OnRoleFollow;
|
|
|
|
public GhostRoleButtonsBox(bool hasAccess, FormattedMessage? reason, IEnumerable<GhostRoleInfo> roles, SpriteSystem spriteSystem)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
_spriteSystem = spriteSystem;
|
|
|
|
foreach (var role in roles)
|
|
{
|
|
var button = new GhostRoleEntryButtons(role);
|
|
button.RequestButton.OnPressed += _ => OnRoleSelected?.Invoke(role);
|
|
button.FollowButton.OnPressed += _ => OnRoleFollow?.Invoke(role);
|
|
|
|
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,
|
|
});
|
|
}
|
|
|
|
Buttons.AddChild(button);
|
|
}
|
|
}
|
|
}
|
|
}
|