From 46524609775baed6f2348938f52e03f657887f9c Mon Sep 17 00:00:00 2001 From: desuwatch Date: Tue, 7 May 2024 16:40:14 +0300 Subject: [PATCH] Added sorting and NO BALANCE label --- Content.Client/Administration/AdminNameOverlay.cs | 3 ++- .../Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs | 5 +++-- .../Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs | 2 +- Content.Server/Administration/Systems/AdminSystem.cs | 6 +++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Content.Client/Administration/AdminNameOverlay.cs b/Content.Client/Administration/AdminNameOverlay.cs index e10b800cc3c..836682175a0 100644 --- a/Content.Client/Administration/AdminNameOverlay.cs +++ b/Content.Client/Administration/AdminNameOverlay.cs @@ -61,13 +61,14 @@ protected override void Draw(in OverlayDrawArgs args) var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center + new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec( aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f); + var balance_str = playerInfo.Balance == int.MinValue ? "NO BALANCE" : playerInfo.Balance.ToString(); if (playerInfo.Antag) { args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", Color.OrangeRed); } args.ScreenHandle.DrawString(_font, screenCoordinates + lineoffset, playerInfo.Username, playerInfo.Connected ? Color.Yellow : Color.White); args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, playerInfo.Connected ? Color.Aquamarine : Color.White); - args.ScreenHandle.DrawString(_font, screenCoordinates + 3 * lineoffset, $"balance: {playerInfo.Balance}", playerInfo.Connected ? Color.Aquamarine : Color.White); + args.ScreenHandle.DrawString(_font, screenCoordinates + 3 * lineoffset, $"balance: {balance_str}", playerInfo.Connected ? Color.Aquamarine : Color.White); } } } diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs index acad192c225..392ef04c6f4 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs @@ -122,7 +122,7 @@ private void RefreshPlayerList(IReadOnlyList players) new StyleBoxFlat(useAltColor ? _altColor : _defaultColor), player.Connected, player.PlaytimeString, - player.Balance); + player.Balance == int.MinValue ? "NO BALANCE" : player.Balance.ToString()); entry.PlayerEntity = player.NetEntity; entry.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(entry, args); entry.ToolTip = Loc.GetString("player-tab-entry-tooltip"); @@ -152,8 +152,9 @@ private int Compare(PlayerInfo x, PlayerInfo y) Header.Job => Compare(x.StartingJob, y.StartingJob), Header.Antagonist => x.Antag.CompareTo(y.Antag), Header.Playtime => TimeSpan.Compare(x.OverallPlaytime ?? default, y.OverallPlaytime ?? default), + Header.Balance => x.Balance.CompareTo(y.Balance), _ => 1 - }; + }; ; } private int Compare(string x, string y) diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs index 3f8d6453575..aac7e3559d5 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs @@ -10,7 +10,7 @@ public sealed partial class PlayerTabEntry : ContainerButton { public NetEntity? PlayerEntity; - public PlayerTabEntry(string username, string character, string identity, string job, string antagonist, StyleBox styleBox, bool connected, string overallPlaytime, int balance) + public PlayerTabEntry(string username, string character, string identity, string job, string antagonist, StyleBox styleBox, bool connected, string overallPlaytime, string balance) { RobustXamlLoader.Load(this); diff --git a/Content.Server/Administration/Systems/AdminSystem.cs b/Content.Server/Administration/Systems/AdminSystem.cs index 9291e3136ae..546b0b0decf 100644 --- a/Content.Server/Administration/Systems/AdminSystem.cs +++ b/Content.Server/Administration/Systems/AdminSystem.cs @@ -221,7 +221,7 @@ private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session) var name = data.UserName; var entityName = string.Empty; var identityName = string.Empty; - var balance = 0; + int balance = 0; if (session?.AttachedEntity != null) { @@ -231,6 +231,10 @@ private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session) { balance = comp.Balance; } + else + { + balance = int.MinValue; // Эквивалент отсутствующего баланса + } } var antag = false;