Ghost Roles (#3106)
* Add files for Ghost Roles. * Work on Ghost Roles * Improvements * GHOST ROLES IS DONE * mmm yes * auto-update when setting rolename/roledescription * well * command graceful error * Makes UI have a scrollbar when it has too many entries * fix command fuckup * Apply suggestions from code review Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3923733113
commit
4c419f85ce
@@ -0,0 +1,9 @@
|
||||
<uic:VBoxContainer
|
||||
xmlns:uic="clr-namespace:Robust.Client.UserInterface.Controls;assembly=Robust.Client">
|
||||
|
||||
<uic:RichTextLabel Name="Title" />
|
||||
<uic:HBoxContainer SeparationOverride="10">
|
||||
<uic:RichTextLabel Name="Description" SizeFlagsHorizontal="FillExpand" />
|
||||
<uic:Button Name="RequestButton" Text="Request" TextAlign="Center" SizeFlagsHorizontal="ShrinkEnd" />
|
||||
</uic:HBoxContainer>
|
||||
</uic:VBoxContainer>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostRolesEntry : VBoxContainer
|
||||
{
|
||||
public GhostRolesEntry(GhostRoleInfo info, Action<BaseButton.ButtonEventArgs> requestAction)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
Title.SetMessage(info.Name);
|
||||
Description.SetMessage(info.Description);
|
||||
RequestButton.OnPressed += requestAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Content.Client.Eui;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class GhostRolesEui : BaseEui
|
||||
{
|
||||
private readonly GhostRolesWindow _window;
|
||||
|
||||
public GhostRolesEui()
|
||||
{
|
||||
_window = new GhostRolesWindow();
|
||||
|
||||
_window.RoleRequested += id =>
|
||||
{
|
||||
SendMessage(new GhostRoleTakeoverRequestMessage(id));
|
||||
};
|
||||
|
||||
_window.OnClose += () =>
|
||||
{
|
||||
SendMessage(new GhostRoleWindowCloseMessage());
|
||||
};
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
base.Opened();
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
public override void Closed()
|
||||
{
|
||||
base.Closed();
|
||||
_window.Close();
|
||||
}
|
||||
|
||||
public override void HandleState(EuiStateBase state)
|
||||
{
|
||||
base.HandleState(state);
|
||||
|
||||
if (state is not GhostRolesEuiState ghostState) return;
|
||||
|
||||
_window.ClearEntries();
|
||||
|
||||
foreach (var info in ghostState.GhostRoles)
|
||||
{
|
||||
_window.AddEntry(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<cc:SS14Window Title="Ghost Roles"
|
||||
xmlns:cc="clr-namespace:Robust.Client.UserInterface.CustomControls;assembly=Robust.Client"
|
||||
xmlns:uic="clr-namespace:Robust.Client.UserInterface.Controls;assembly=Robust.Client">
|
||||
|
||||
<uic:CenterContainer Name="NoRolesMessage" SizeFlagsVertical="FillExpand" SizeFlagsHorizontal="FillExpand">
|
||||
<uic:Label Text="There are currently no available ghost roles."/>
|
||||
</uic:CenterContainer>
|
||||
<uic:ScrollContainer SizeFlagsHorizontal="FillExpand" SizeFlagsVertical="FillExpand">
|
||||
<uic:VBoxContainer Name="EntryContainer" SizeFlagsHorizontal="FillExpand" SizeFlagsVertical="FillExpand" />
|
||||
</uic:ScrollContainer>
|
||||
|
||||
</cc:SS14Window>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Observer
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostRolesWindow : SS14Window
|
||||
{
|
||||
public event Action<uint> RoleRequested;
|
||||
|
||||
protected override Vector2 CalculateMinimumSize() => (350, 275);
|
||||
|
||||
public void ClearEntries()
|
||||
{
|
||||
EntryContainer.DisposeAllChildren();
|
||||
NoRolesMessage.Visible = true;
|
||||
}
|
||||
|
||||
public void AddEntry(GhostRoleInfo info)
|
||||
{
|
||||
NoRolesMessage.Visible = false;
|
||||
EntryContainer.AddChild(new GhostRolesEntry(info, _ => RoleRequested?.Invoke(info.Identifier)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user