From b784edb7581b2c9e64349c9895013ac387d7778d Mon Sep 17 00:00:00 2001 From: Repo <47093363+Titian3@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:58:31 +1200 Subject: [PATCH 01/11] Fix aHelp menu sorting (#30518) * Keep Pinned status through player status changes. * Fix filtering to be admin optimal. --- .../UI/Bwoink/BwoinkControl.xaml.cs | 41 +++++++++++++++++-- .../CustomControls/PlayerListControl.xaml.cs | 21 +++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs index ddd66623bd4..18aa02e9d67 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs +++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs @@ -88,6 +88,10 @@ public BwoinkControl() var ach = AHelpHelper.EnsurePanel(a.SessionId); var bch = AHelpHelper.EnsurePanel(b.SessionId); + // Pinned players first + if (a.IsPinned != b.IsPinned) + return a.IsPinned ? -1 : 1; + // First, sort by unread. Any chat with unread messages appears first. We just sort based on unread // status, not number of unread messages, so that more recent unread messages take priority. var aUnread = ach.Unread > 0; @@ -99,15 +103,31 @@ public BwoinkControl() if (a.Connected != b.Connected) return a.Connected ? -1 : 1; - // Next, group by whether or not the players have participated in this round. - // The ahelp window shows all players that have connected since server restart, this groups them all towards the bottom. - if (a.ActiveThisRound != b.ActiveThisRound) - return a.ActiveThisRound ? -1 : 1; + // Sort connected players by New Player status, then by Antag status + if (a.Connected && b.Connected) + { + var aNewPlayer = a.OverallPlaytime <= TimeSpan.FromMinutes(_cfg.GetCVar(CCVars.NewPlayerThreshold)); + var bNewPlayer = b.OverallPlaytime <= TimeSpan.FromMinutes(_cfg.GetCVar(CCVars.NewPlayerThreshold)); + + if (aNewPlayer != bNewPlayer) + return aNewPlayer ? -1 : 1; + + if (a.Antag != b.Antag) + return a.Antag ? -1 : 1; + } + + // Sort disconnected players by participation in the round + if (!a.Connected && !b.Connected) + { + if (a.ActiveThisRound != b.ActiveThisRound) + return a.ActiveThisRound ? -1 : 1; + } // Finally, sort by the most recent message. return bch.LastMessage.CompareTo(ach.LastMessage); }; + Bans.OnPressed += _ => { if (_currentPlayer is not null) @@ -253,7 +273,20 @@ private void SwitchToChannel(NetUserId? ch) public void PopulateList() { + // Maintain existing pin statuses + var pinnedPlayers = ChannelSelector.PlayerInfo.Where(p => p.IsPinned).ToDictionary(p => p.SessionId); + ChannelSelector.PopulateList(); + + // Restore pin statuses + foreach (var player in ChannelSelector.PlayerInfo) + { + if (pinnedPlayers.TryGetValue(player.SessionId, out var pinnedPlayer)) + { + player.IsPinned = pinnedPlayer.IsPinned; + } + } + UpdateButtons(); } } diff --git a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs index b09cd727ef8..c7fbf6c2dc0 100644 --- a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs +++ b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs @@ -21,11 +21,11 @@ public sealed partial class PlayerListControl : BoxContainer private readonly IEntityManager _entManager; private readonly IUserInterfaceManager _uiManager; - + private PlayerInfo? _selectedPlayer; private List _playerList = new(); - private readonly List _sortedPlayerList = new(); + private List _sortedPlayerList = new(); public Comparison? Comparison; public Func? OverrideText; @@ -110,19 +110,30 @@ private void FilterList() if (Comparison != null) _sortedPlayerList.Sort((a, b) => Comparison(a, b)); - // Ensure pinned players are always at the top - _sortedPlayerList.Sort((a, b) => a.IsPinned != b.IsPinned && a.IsPinned ? -1 : 1); - PlayerListContainer.PopulateList(_sortedPlayerList.Select(info => new PlayerListData(info)).ToList()); if (_selectedPlayer != null) PlayerListContainer.Select(new PlayerListData(_selectedPlayer)); } + public void PopulateList(IReadOnlyList? players = null) { + // Maintain existing pin statuses + var pinnedPlayers = _playerList.Where(p => p.IsPinned).ToDictionary(p => p.SessionId); + players ??= _adminSystem.PlayerList; _playerList = players.ToList(); + + // Restore pin statuses + foreach (var player in _playerList) + { + if (pinnedPlayers.TryGetValue(player.SessionId, out var pinnedPlayer)) + { + player.IsPinned = pinnedPlayer.IsPinned; + } + } + if (_selectedPlayer != null && !_playerList.Contains(_selectedPlayer)) _selectedPlayer = null; From f264da89c43801db72264b9255905c93219f626a Mon Sep 17 00:00:00 2001 From: PJBot Date: Wed, 31 Jul 2024 01:59:37 +0000 Subject: [PATCH 02/11] Automatic changelog update --- Resources/Changelog/Admin.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Resources/Changelog/Admin.yml b/Resources/Changelog/Admin.yml index 6625e7ae7f1..6788f631b7a 100644 --- a/Resources/Changelog/Admin.yml +++ b/Resources/Changelog/Admin.yml @@ -378,5 +378,12 @@ Entries: id: 46 time: '2024-07-30T08:28:32.0000000+00:00' url: https://github.com/space-wizards/space-station-14/pull/28639 +- author: Repo + changes: + - message: Fixed Ahelp Sorting + type: Fix + id: 47 + time: '2024-07-31T01:58:31.0000000+00:00' + url: https://github.com/space-wizards/space-station-14/pull/30518 Name: Admin Order: 1 From 778bfe3355044835e7ee993c00a26cc456673522 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:31:41 +1000 Subject: [PATCH 03/11] Add test for anchored prototypes (#30526) Nothing fails at least but at some point will let us remove some hacky engine code. --- .../Tests/Physics/AnchorPrototypeTest.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs diff --git a/Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs b/Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs new file mode 100644 index 00000000000..a65e7d1fd67 --- /dev/null +++ b/Content.IntegrationTests/Tests/Physics/AnchorPrototypeTest.cs @@ -0,0 +1,43 @@ +using Robust.Shared.GameObjects; +using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; +using Robust.Shared.Prototypes; + +namespace Content.IntegrationTests.Tests.Physics; + +[TestFixture] +public sealed class AnchorPrototypeTest +{ + /// + /// Asserts that entityprototypes marked as anchored are also static physics bodies. + /// + [Test] + public async Task TestStaticAnchorPrototypes() + { + await using var pair = await PoolManager.GetServerClient(); + + var protoManager = pair.Server.ResolveDependency(); + + await pair.Server.WaitAssertion(() => + { + foreach (var ent in protoManager.EnumeratePrototypes()) + { + if (!ent.Components.TryGetComponent("Transform", out var xformComp) || + !ent.Components.TryGetComponent("Physics", out var physicsComp)) + { + continue; + } + + var xform = (TransformComponent)xformComp; + var physics = (PhysicsComponent)physicsComp; + + if (!xform.Anchored) + continue; + + Assert.That(physics.BodyType, Is.EqualTo(BodyType.Static), $"Found entity prototype {ent} marked as anchored but not static for physics."); + } + }); + + await pair.CleanReturnAsync(); + } +} From 5bc9c04a0201bf9ce4a42145a6776a39cb2b0d83 Mon Sep 17 00:00:00 2001 From: Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:32:19 +0000 Subject: [PATCH 04/11] add(SharedDoAfterSystem): Add a IsRunning "Utility" function (#30512) --- Content.Shared/DoAfter/SharedDoAfterSystem.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.cs index 77b47415333..feda662a7a8 100644 --- a/Content.Shared/DoAfter/SharedDoAfterSystem.cs +++ b/Content.Shared/DoAfter/SharedDoAfterSystem.cs @@ -393,5 +393,18 @@ public DoAfterStatus GetStatus(EntityUid entity, ushort id, DoAfterComponent? co // networking whether a do-after has raised its events or not. return DoAfterStatus.Finished; } + + public bool IsRunning(DoAfterId? id, DoAfterComponent? comp = null) + { + if (id == null) + return false; + + return GetStatus(id.Value.Uid, id.Value.Index, comp) == DoAfterStatus.Running; + } + + public bool IsRunning(EntityUid entity, ushort id, DoAfterComponent? comp = null) + { + return GetStatus(entity, id, comp) == DoAfterStatus.Running; + } #endregion } From 0432f21110e4953f0094f348637b50e72dd7edba Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:14:19 +1000 Subject: [PATCH 05/11] Add sprite exporting (#29874) * Redo of code * Dump IDs on lobby exports --- Content.Client/Lobby/LobbyUIController.cs | 1 + .../Lobby/UI/HumanoidProfileEditor.xaml | 2 + .../Lobby/UI/HumanoidProfileEditor.xaml.cs | 49 +++- Content.Client/Sprite/ContentSpriteSystem.cs | 218 ++++++++++++++++++ .../en-US/administration/admin-verbs.ftl | 2 + .../ui/humanoid-profile-editor.ftl | 2 + 6 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 Content.Client/Sprite/ContentSpriteSystem.cs diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index 824a842d560..1cdaaccc4e8 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -272,6 +272,7 @@ private void OpenSavePanel() _logManager, _playerManager, _prototypeManager, + _resourceCache, _requirements, _markings); diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml index 03a205e94a8..2f6c2d5aa23 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml @@ -38,6 +38,8 @@