Ghost UI to XAML and minor cleanup (#4637)
* Remove unused class, clean up XAML * Move GhostGui.cs into UI folder and namespace * GhostTargetWindow to seperate file * GhostTargetWindow to XAML * Center request button * Improve UI, localisation
This commit is contained in:
85
Content.Client/Ghost/UI/GhostTargetWindow.xaml.cs
Normal file
85
Content.Client/Ghost/UI/GhostTargetWindow.xaml.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Ghost;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Client.Ghost.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class GhostTargetWindow : SS14Window
|
||||
{
|
||||
private readonly IEntityNetworkManager _netManager;
|
||||
|
||||
public List<string> Locations { get; set; } = new();
|
||||
|
||||
public Dictionary<EntityUid, string> Players { get; set; } = new();
|
||||
|
||||
public GhostTargetWindow(IEntityNetworkManager netManager)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
_netManager = netManager;
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
{
|
||||
ButtonContainer.DisposeAllChildren();
|
||||
AddButtonPlayers();
|
||||
AddButtonLocations();
|
||||
}
|
||||
|
||||
private void AddButtonPlayers()
|
||||
{
|
||||
foreach (var (key, value) in Players)
|
||||
{
|
||||
var currentButtonRef = new Button
|
||||
{
|
||||
Text = value,
|
||||
TextAlign = Label.AlignMode.Right,
|
||||
HorizontalAlignment = HAlignment.Center,
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
MinSize = (230, 20),
|
||||
ClipText = true,
|
||||
};
|
||||
|
||||
currentButtonRef.OnPressed += (_) =>
|
||||
{
|
||||
var msg = new GhostWarpToTargetRequestEvent(key);
|
||||
_netManager.SendSystemNetworkMessage(msg);
|
||||
};
|
||||
|
||||
ButtonContainer.AddChild(currentButtonRef);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButtonLocations()
|
||||
{
|
||||
foreach (var name in Locations)
|
||||
{
|
||||
var currentButtonRef = new Button
|
||||
{
|
||||
Text = Loc.GetString("ghost-target-window-current-button", ("name", name)),
|
||||
TextAlign = Label.AlignMode.Right,
|
||||
HorizontalAlignment = HAlignment.Center,
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
MinSize = (230, 20),
|
||||
ClipText = true,
|
||||
};
|
||||
|
||||
currentButtonRef.OnPressed += _ =>
|
||||
{
|
||||
var msg = new GhostWarpToLocationRequestEvent(name);
|
||||
_netManager.SendSystemNetworkMessage(msg);
|
||||
};
|
||||
|
||||
ButtonContainer.AddChild(currentButtonRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user