Improves the Admin PlayerList (#1989)
* -Makes PlayerList scrollable -Player names clip when they are too long -Shows Player count * Add padding to make columns more noticeable * -Added Separators between the columns -Pushed List a bit down * Add alternating row colors
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Content.Client.GameObjects.EntitySystems;
|
using Content.Client.GameObjects.EntitySystems;
|
||||||
using Content.Client.StationEvents;
|
using Content.Client.StationEvents;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
|
using Robust.Client.Graphics.Drawing;
|
||||||
using Robust.Client.Interfaces.Placement;
|
using Robust.Client.Interfaces.Placement;
|
||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
@@ -17,8 +15,12 @@ using Robust.Shared.Interfaces.Map;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||||
|
|
||||||
namespace Content.Client.UserInterface.AdminMenu
|
namespace Content.Client.UserInterface.AdminMenu
|
||||||
@@ -27,6 +29,9 @@ namespace Content.Client.UserInterface.AdminMenu
|
|||||||
{
|
{
|
||||||
public TabContainer MasterTabContainer;
|
public TabContainer MasterTabContainer;
|
||||||
public VBoxContainer PlayerList;
|
public VBoxContainer PlayerList;
|
||||||
|
public Label PlayerCount;
|
||||||
|
|
||||||
|
protected override Vector2? CustomSize => (500, 250);
|
||||||
|
|
||||||
private List<CommandButton> _adminButtons = new List<CommandButton>
|
private List<CommandButton> _adminButtons = new List<CommandButton>
|
||||||
{
|
{
|
||||||
@@ -57,51 +62,107 @@ namespace Content.Client.UserInterface.AdminMenu
|
|||||||
new DirectCommandButton("Shutdown", "shutdown"),
|
new DirectCommandButton("Shutdown", "shutdown"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static readonly Color SeparatorColor = Color.FromHex("#3D4059");
|
||||||
|
private class HSeperator : Control
|
||||||
|
{
|
||||||
|
public HSeperator()
|
||||||
|
{
|
||||||
|
AddChild(new PanelContainer {
|
||||||
|
PanelOverride = new StyleBoxFlat
|
||||||
|
{
|
||||||
|
BackgroundColor = SeparatorColor,
|
||||||
|
ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class VSeperator : PanelContainer
|
||||||
|
{
|
||||||
|
public VSeperator()
|
||||||
|
{
|
||||||
|
CustomMinimumSize = (2, 5);
|
||||||
|
AddChild(new PanelContainer {
|
||||||
|
PanelOverride = new StyleBoxFlat {
|
||||||
|
BackgroundColor = SeparatorColor
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RefreshPlayerList(ButtonEventArgs args)
|
private void RefreshPlayerList(ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
PlayerList.RemoveAllChildren();
|
PlayerList.RemoveAllChildren();
|
||||||
var sessions = IoCManager.Resolve<IPlayerManager>().Sessions;
|
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||||
|
var sessions = playerManager.Sessions;
|
||||||
|
PlayerCount.Text = $"Players: {playerManager.PlayerCount}";
|
||||||
|
|
||||||
|
Color altColor = Color.FromHex("#292B38");
|
||||||
|
Color defaultColor = Color.FromHex("#2F2F3B");
|
||||||
|
|
||||||
var header = new HBoxContainer
|
var header = new HBoxContainer
|
||||||
{
|
{
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SeparationOverride = 4,
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
new Label { Text = "Name",
|
new Label { Text = "Name",
|
||||||
SizeFlagsStretchRatio = 2f,
|
SizeFlagsStretchRatio = 2f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
||||||
|
new VSeperator(),
|
||||||
new Label { Text = "Player",
|
new Label { Text = "Player",
|
||||||
SizeFlagsStretchRatio = 2f,
|
SizeFlagsStretchRatio = 2f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
||||||
|
new VSeperator(),
|
||||||
new Label { Text = "Status",
|
new Label { Text = "Status",
|
||||||
SizeFlagsStretchRatio = 1f,
|
SizeFlagsStretchRatio = 1f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
||||||
|
new VSeperator(),
|
||||||
new Label { Text = "Ping",
|
new Label { Text = "Ping",
|
||||||
SizeFlagsStretchRatio = 1f,
|
SizeFlagsStretchRatio = 1f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
Align = Label.AlignMode.Right },
|
Align = Label.AlignMode.Right },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
PlayerList.AddChild(header);
|
PlayerList.AddChild(new PanelContainer
|
||||||
PlayerList.AddChild(new Controls.HighDivider());
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat
|
||||||
|
{
|
||||||
|
BackgroundColor = altColor,
|
||||||
|
},
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
header
|
||||||
|
}
|
||||||
|
});
|
||||||
|
PlayerList.AddChild(new HSeperator());
|
||||||
|
|
||||||
|
var useAltColor = false;
|
||||||
foreach (var player in sessions)
|
foreach (var player in sessions)
|
||||||
{
|
{
|
||||||
var hbox = new HBoxContainer
|
var hbox = new HBoxContainer
|
||||||
{
|
{
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SeparationOverride = 4,
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
new Label {
|
new Label {
|
||||||
Text = player.Name,
|
Text = player.Name,
|
||||||
SizeFlagsStretchRatio = 2f,
|
SizeFlagsStretchRatio = 2f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
ClipText = true },
|
||||||
|
new VSeperator(),
|
||||||
new Label {
|
new Label {
|
||||||
Text = player.AttachedEntity?.Name,
|
Text = player.AttachedEntity?.Name,
|
||||||
SizeFlagsStretchRatio = 2f,
|
SizeFlagsStretchRatio = 2f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
ClipText = true },
|
||||||
|
new VSeperator(),
|
||||||
new Label {
|
new Label {
|
||||||
Text = player.Status.ToString(),
|
Text = player.Status.ToString(),
|
||||||
SizeFlagsStretchRatio = 1f,
|
SizeFlagsStretchRatio = 1f,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
SizeFlagsHorizontal = SizeFlags.FillExpand },
|
||||||
|
new VSeperator(),
|
||||||
new Label {
|
new Label {
|
||||||
Text = player.Ping.ToString(),
|
Text = player.Ping.ToString(),
|
||||||
SizeFlagsStretchRatio = 1f,
|
SizeFlagsStretchRatio = 1f,
|
||||||
@@ -109,7 +170,18 @@ namespace Content.Client.UserInterface.AdminMenu
|
|||||||
Align = Label.AlignMode.Right },
|
Align = Label.AlignMode.Right },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
PlayerList.AddChild(hbox);
|
PlayerList.AddChild(new PanelContainer
|
||||||
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat
|
||||||
|
{
|
||||||
|
BackgroundColor = useAltColor ? altColor : defaultColor,
|
||||||
|
},
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
hbox
|
||||||
|
}
|
||||||
|
});
|
||||||
|
useAltColor ^= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +205,6 @@ namespace Content.Client.UserInterface.AdminMenu
|
|||||||
|
|
||||||
public AdminMenuWindow() //TODO: search for buttons?
|
public AdminMenuWindow() //TODO: search for buttons?
|
||||||
{
|
{
|
||||||
CustomMinimumSize = (415,0);
|
|
||||||
Title = Loc.GetString("Admin Menu");
|
Title = Loc.GetString("Admin Menu");
|
||||||
|
|
||||||
#region PlayerList
|
#region PlayerList
|
||||||
@@ -146,22 +217,50 @@ namespace Content.Client.UserInterface.AdminMenu
|
|||||||
MarginBottomOverride = 4,
|
MarginBottomOverride = 4,
|
||||||
CustomMinimumSize = (50, 50),
|
CustomMinimumSize = (50, 50),
|
||||||
};
|
};
|
||||||
PlayerList = new VBoxContainer();
|
|
||||||
|
PlayerCount = new Label
|
||||||
|
{
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsStretchRatio = 0.7f,
|
||||||
|
};
|
||||||
var refreshButton = new Button
|
var refreshButton = new Button
|
||||||
{
|
{
|
||||||
Text = "Refresh"
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsStretchRatio = 0.3f,
|
||||||
|
Text = "Refresh",
|
||||||
};
|
};
|
||||||
refreshButton.OnPressed += RefreshPlayerList;
|
refreshButton.OnPressed += RefreshPlayerList;
|
||||||
RefreshPlayerList(null!);
|
|
||||||
|
PlayerList = new VBoxContainer();
|
||||||
|
|
||||||
var playerVBox = new VBoxContainer
|
var playerVBox = new VBoxContainer
|
||||||
{
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
refreshButton,
|
new HBoxContainer
|
||||||
PlayerList
|
{
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
PlayerCount,
|
||||||
|
refreshButton,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Control { CustomMinimumSize = (0, 5) },
|
||||||
|
new ScrollContainer
|
||||||
|
{
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
PlayerList
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
playerTabContainer.AddChild(playerVBox);
|
playerTabContainer.AddChild(playerVBox);
|
||||||
|
RefreshPlayerList(null!);
|
||||||
#endregion PlayerList
|
#endregion PlayerList
|
||||||
|
|
||||||
#region Admin Tab
|
#region Admin Tab
|
||||||
|
|||||||
Reference in New Issue
Block a user