diff --git a/.github/workflows/publish-publish.yml b/.github/workflows/publish-publish.yml index bcdeb4d9577..f1bc3f847c0 100644 --- a/.github/workflows/publish-publish.yml +++ b/.github/workflows/publish-publish.yml @@ -54,9 +54,10 @@ jobs: run: Tools/publish_github_artifact.py env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN_PUBLIC }} ARTIFACT_ID: ${{ steps.artifact-upload-step.outputs.artifact-id }} GITHUB_REPOSITORY: ${{ vars.GITHUB_REPOSITORY }} + FORK_ID: ${{ vars.FORK_ID_PUBLIC }} # - name: Publish changelog (Discord) # run: Tools/actions_changelogs_since_last_run.py diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2865cc0fbfa..1e95fb41b06 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -10,7 +10,7 @@ "args": [ "build", "/property:GenerateFullPaths=true", // Ask dotnet build to generate full paths for file names. - "/consoleloggerparameters:NoSummary" // Do not generate summary otherwise it leads to duplicate errors in Problems panel + "/consoleloggerparameters:'ForceNoAlign;NoSummary'" // Do not generate summary otherwise it leads to duplicate errors in Problems panel ], "group": { "kind": "build", @@ -29,9 +29,9 @@ "build", "${workspaceFolder}/Content.YAMLLinter/Content.YAMLLinter.csproj", "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" + "/consoleloggerparameters:'ForceNoAlign;NoSummary'" ], "problemMatcher": "$msCompile" } ] -} \ No newline at end of file +} diff --git a/Content.Benchmarks/MapLoadBenchmark.cs b/Content.Benchmarks/MapLoadBenchmark.cs index a3319e3067f..8c04d9a40dc 100644 --- a/Content.Benchmarks/MapLoadBenchmark.cs +++ b/Content.Benchmarks/MapLoadBenchmark.cs @@ -46,7 +46,7 @@ public async Task Cleanup() PoolManager.Shutdown(); } - public static readonly string[] MapsSource = { "Empty", "Box", "Bagel", "Dev", "CentComm", "Atlas", "Core", "TestTeg", "Saltern", "Packed", "Omega", "Cluster", "Reach", "Origin", "Meta", "Marathon", "Europa", "MeteorArena", "Fland", "Barratry", "Oasis" }; + public static readonly string[] MapsSource = { "Empty", "Satlern", "Box", "Bagel", "Dev", "CentComm", "Core", "TestTeg", "Packed", "Omega", "Reach", "Meta", "Marathon", "MeteorArena", "Fland", "Oasis", "Cog" }; [ParamsSource(nameof(MapsSource))] public string Map; diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index f05e4455880..26a22fa8b8d 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -259,12 +259,6 @@ public void TriggerAction(EntityUid actionId, BaseActionComponent action) if (action.ClientExclusive) { - if (instantAction.Event != null) - { - instantAction.Event.Performer = user; - instantAction.Event.Action = actionId; - } - PerformAction(user, actions, actionId, instantAction, instantAction.Event, GameTiming.CurTime); } else diff --git a/Content.Client/Administration/AdminNameOverlay.cs b/Content.Client/Administration/AdminNameOverlay.cs index 2e4cbe1cec8..e2db7a8d6b4 100644 --- a/Content.Client/Administration/AdminNameOverlay.cs +++ b/Content.Client/Administration/AdminNameOverlay.cs @@ -2,86 +2,75 @@ using Content.Client.Administration.Systems; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; +using Robust.Client.UserInterface; +using Robust.Shared; using Robust.Shared.Enums; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Maths; +using Robust.Shared.Configuration; -namespace Content.Client.Administration +namespace Content.Client.Administration; + +internal sealed class AdminNameOverlay : Overlay { - internal sealed class AdminNameOverlay : Overlay + private readonly AdminSystem _system; + private readonly IEntityManager _entityManager; + private readonly IEyeManager _eyeManager; + private readonly EntityLookupSystem _entityLookup; + private readonly IUserInterfaceManager _userInterfaceManager; + private readonly Font _font; + + public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup, IUserInterfaceManager userInterfaceManager) { - private readonly AdminSystem _system; - private readonly IEntityManager _entityManager; - private readonly IEyeManager _eyeManager; - private readonly EntityLookupSystem _entityLookup; - private readonly Font _font; + _system = system; + _entityManager = entityManager; + _eyeManager = eyeManager; + _entityLookup = entityLookup; + _userInterfaceManager = userInterfaceManager; + ZIndex = 200; + _font = new VectorFont(resourceCache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); + } - public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup) - { - _system = system; - _entityManager = entityManager; - _eyeManager = eyeManager; - _entityLookup = entityLookup; - ZIndex = 200; - _font = new VectorFont(resourceCache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); - } + public override OverlaySpace Space => OverlaySpace.ScreenSpace; - public override OverlaySpace Space => OverlaySpace.ScreenSpace; + protected override void Draw(in OverlayDrawArgs args) + { + var viewport = args.WorldAABB; - protected override void Draw(in OverlayDrawArgs args) + foreach (var playerInfo in _system.PlayerList) { - var viewport = args.WorldAABB; + var entity = _entityManager.GetEntity(playerInfo.NetEntity); - foreach (var playerInfo in _system.PlayerList) + // Otherwise the entity can not exist yet + if (entity == null || !_entityManager.EntityExists(entity)) { - var entity = _entityManager.GetEntity(playerInfo.NetEntity); - - // Otherwise the entity can not exist yet - if (entity == null || !_entityManager.EntityExists(entity)) - { - continue; - } - - // if not on the same map, continue - if (_entityManager.GetComponent(entity.Value).MapID != args.MapId) - { - continue; - } - - var aabb = _entityLookup.GetWorldAABB(entity.Value); - - // if not on screen, continue - if (!aabb.Intersects(in viewport)) - { - continue; - } + continue; + } - var lineoffset = new Vector2(0f, 11f); - var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center + - new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec( - aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f); - if (playerInfo.Antag) - { - args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", Color.OrangeRed); - } + // if not on the same map, continue + if (_entityManager.GetComponent(entity.Value).MapID != args.MapId) + { + continue; + } - //ADT-SPONSORS - if (playerInfo.Sponsor != null) - { - var sponsorOffset = playerInfo.Antag ? lineoffset * 3 : lineoffset * 2; - var sponsorString = $"Sponsor ({playerInfo.Sponsor.Tier})"; - if (playerInfo.Sponsor.AllowJob) - sponsorString += " (allJobs)"; + var aabb = _entityLookup.GetWorldAABB(entity.Value); - sponsorString += $" до {playerInfo.Sponsor.ExpireDate.ToString("dd.MM.yyyy")}"; + // if not on screen, continue + if (!aabb.Intersects(in viewport)) + { + continue; + } - args.ScreenHandle.DrawString(_font, screenCoordinates + sponsorOffset, sponsorString, Color.GreenYellow); - } - //ADT-SPONSORS - 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); + var uiScale = _userInterfaceManager.RootControl.UIScale; + var lineoffset = new Vector2(0f, 11f) * uiScale; + var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center + + new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec( + aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f); + if (playerInfo.Antag) + { + args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", uiScale, Color.OrangeRed); +; } + args.ScreenHandle.DrawString(_font, screenCoordinates+lineoffset, playerInfo.Username, uiScale, playerInfo.Connected ? Color.Yellow : Color.White); + args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, uiScale, playerInfo.Connected ? Color.Aquamarine : Color.White); } } } diff --git a/Content.Client/Administration/Systems/AdminSystem.Overlay.cs b/Content.Client/Administration/Systems/AdminSystem.Overlay.cs index 3502faf9e8e..ba6ce40ca0b 100644 --- a/Content.Client/Administration/Systems/AdminSystem.Overlay.cs +++ b/Content.Client/Administration/Systems/AdminSystem.Overlay.cs @@ -1,6 +1,8 @@ using Content.Client.Administration.Managers; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; +using Robust.Client.UserInterface; +using Robust.Shared.Configuration; namespace Content.Client.Administration.Systems { @@ -11,6 +13,7 @@ public sealed partial class AdminSystem [Dependency] private readonly IClientAdminManager _adminManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly EntityLookupSystem _entityLookup = default!; + [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; private AdminNameOverlay _adminNameOverlay = default!; @@ -19,7 +22,7 @@ public sealed partial class AdminSystem private void InitializeOverlay() { - _adminNameOverlay = new AdminNameOverlay(this, EntityManager, _eyeManager, _resourceCache, _entityLookup); + _adminNameOverlay = new AdminNameOverlay(this, EntityManager, _eyeManager, _resourceCache, _entityLookup, _userInterfaceManager); _adminManager.AdminStatusUpdated += OnAdminStatusUpdated; } diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs index 7bb425f618e..c8d7e915a1e 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs @@ -1,4 +1,4 @@ -using Content.Shared.Administration.Notes; +using Content.Shared.Administration.Notes; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; @@ -13,7 +13,7 @@ public AdminMessagePopupMessage(AdminMessageEuiState.Message message) { RobustXamlLoader.Load(this); - Admin.SetMessage(FormattedMessage.FromMarkup(Loc.GetString( + Admin.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString( "admin-notes-message-admin", ("admin", message.AdminName), ("date", message.AddedOn.ToLocalTime())))); diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs index bf2ca9bec41..148cbf4e18e 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs @@ -49,7 +49,7 @@ public void SetState(AdminMessageEuiState state) MessageContainer.AddChild(new AdminMessagePopupMessage(message)); } - Description.SetMessage(FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length)))); + Description.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length)))); } private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj) diff --git a/Content.Client/Administration/UI/BanList/BanListWindow.xaml.cs b/Content.Client/Administration/UI/BanList/BanListWindow.xaml.cs index c95f8f204dd..fad55f96273 100644 --- a/Content.Client/Administration/UI/BanList/BanListWindow.xaml.cs +++ b/Content.Client/Administration/UI/BanList/BanListWindow.xaml.cs @@ -1,4 +1,5 @@ using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs index dd8e3e22121..b4e9a07ef88 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs +++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs @@ -11,9 +11,8 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Network; -using Robust.Shared.Utility; -using Robust.Shared.Timing; using Robust.Shared.Configuration; +using Robust.Shared.Utility; namespace Content.Client.Administration.UI.Bwoink { diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs index 7a032d0bbd7..833514e4aa2 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs +++ b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs @@ -59,7 +59,7 @@ public void ReceiveLine(SharedBwoinkSystem.BwoinkTextMessage message) Unread++; var formatted = new FormattedMessage(1); - formatted.AddMarkup($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}"); + formatted.AddMarkupOrThrow($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}"); TextOutput.AddMessage(formatted); LastMessage = message.SentAt; } diff --git a/Content.Client/Administration/UI/PlayerPanel/PlayerPanel.xaml.cs b/Content.Client/Administration/UI/PlayerPanel/PlayerPanel.xaml.cs index 824d9eb6c77..53cc8faa10c 100644 --- a/Content.Client/Administration/UI/PlayerPanel/PlayerPanel.xaml.cs +++ b/Content.Client/Administration/UI/PlayerPanel/PlayerPanel.xaml.cs @@ -70,7 +70,7 @@ public void SetWhitelisted(bool? whitelisted) else { Whitelisted.Text = Loc.GetString("player-panel-whitelisted"); - WhitelistToggle.Text = whitelisted.Value.ToString(); + WhitelistToggle.Text = whitelisted.Value ? Loc.GetString("player-panel-true") : Loc.GetString("player-panel-false"); WhitelistToggle.Visible = true; _isWhitelisted = whitelisted.Value; } @@ -124,7 +124,7 @@ public void SetButtons() NotesButton.Disabled = !_adminManager.CanCommand("adminnotes"); ShowBansButton.Disabled = !_adminManager.CanCommand("banlist"); WhitelistToggle.Disabled = - !(_adminManager.CanCommand("addwhitelist") && _adminManager.CanCommand("removewhitelist")); + !(_adminManager.CanCommand("whitelistadd") && _adminManager.CanCommand("whitelistremove")); LogsButton.Disabled = !_adminManager.CanCommand("adminlogs"); RejuvenateButton.Disabled = !_adminManager.HasFlag(AdminFlags.Debug); DeleteButton.Disabled = !_adminManager.HasFlag(AdminFlags.Debug); diff --git a/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs b/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs index a2faf208d92..7cb32b43df5 100644 --- a/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs +++ b/Content.Client/Administration/UI/SetOutfit/SetOutfitMenu.xaml.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Content.Client.UserInterface.Controls; using Content.Shared.Roles; using Robust.Client.AutoGenerated; using Robust.Client.Console; diff --git a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs index 29774bb587e..ee5d3701f58 100644 --- a/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTabEntry.xaml.cs @@ -1,4 +1,4 @@ -using Content.Client.Administration.Managers; +using Content.Client.Administration.Managers; using Robust.Client.AutoGenerated; using Robust.Client.Graphics; using Robust.Client.UserInterface.Controls; @@ -13,6 +13,7 @@ public sealed partial class ObjectsTabEntry : PanelContainer public Action? OnTeleport; public Action? OnDelete; + private readonly Dictionary _confirmations = new(); public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, StyleBox styleBox) { @@ -27,6 +28,13 @@ public ObjectsTabEntry(IClientAdminManager manager, string name, NetEntity nent, DeleteButton.Disabled = !manager.CanCommand("delete"); TeleportButton.OnPressed += _ => OnTeleport?.Invoke(nent); - DeleteButton.OnPressed += _ => OnDelete?.Invoke(nent); + DeleteButton.OnPressed += _ => + { + if (!AdminUIHelpers.TryConfirm(DeleteButton, _confirmations)) + { + return; + } + OnDelete?.Invoke(nent); + }; } } diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs index e8d1f001963..043bf343ecf 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs @@ -10,238 +10,219 @@ using static Content.Client.Administration.UI.Tabs.PlayerTab.PlayerTabHeader; using static Robust.Client.UserInterface.Controls.BaseButton; -namespace Content.Client.Administration.UI.Tabs.PlayerTab +namespace Content.Client.Administration.UI.Tabs.PlayerTab; + +[GenerateTypedNameReferences] +public sealed partial class PlayerTab : Control { - [GenerateTypedNameReferences] - public sealed partial class PlayerTab : Control - { - [Dependency] private readonly IEntityManager _entManager = default!; - [Dependency] private readonly IPlayerManager _playerMan = default!; + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPlayerManager _playerMan = default!; - private const string ArrowUp = "↑"; - private const string ArrowDown = "↓"; - private readonly Color _altColor = Color.FromHex("#292B38"); - private readonly Color _defaultColor = Color.FromHex("#2F2F3B"); - private readonly AdminSystem _adminSystem; - private IReadOnlyList _players = new List(); + private const string ArrowUp = "↑"; + private const string ArrowDown = "↓"; + private readonly Color _altColor = Color.FromHex("#292B38"); + private readonly Color _defaultColor = Color.FromHex("#2F2F3B"); + private readonly AdminSystem _adminSystem; + private IReadOnlyList _players = new List(); - private Header _headerClicked = Header.Username; - private bool _ascending = true; - private bool _showDisconnected; + private Header _headerClicked = Header.Username; + private bool _ascending = true; + private bool _showDisconnected; - public event Action? OnEntryKeyBindDown; + public event Action? OnEntryKeyBindDown; - public PlayerTab() - { - IoCManager.InjectDependencies(this); - RobustXamlLoader.Load(this); + public PlayerTab() + { + IoCManager.InjectDependencies(this); + RobustXamlLoader.Load(this); - _adminSystem = _entManager.System(); - _adminSystem.PlayerListChanged += RefreshPlayerList; - _adminSystem.OverlayEnabled += OverlayEnabled; - _adminSystem.OverlayDisabled += OverlayDisabled; + _adminSystem = _entManager.System(); + _adminSystem.PlayerListChanged += RefreshPlayerList; + _adminSystem.OverlayEnabled += OverlayEnabled; + _adminSystem.OverlayDisabled += OverlayDisabled; - OverlayButton.OnPressed += OverlayButtonPressed; - ShowDisconnectedButton.OnPressed += ShowDisconnectedPressed; + OverlayButton.OnPressed += OverlayButtonPressed; + ShowDisconnectedButton.OnPressed += ShowDisconnectedPressed; - ListHeader.BackgroundColorPanel.PanelOverride = new StyleBoxFlat(_altColor); - ListHeader.OnHeaderClicked += HeaderClicked; + ListHeader.BackgroundColorPanel.PanelOverride = new StyleBoxFlat(_altColor); + ListHeader.OnHeaderClicked += HeaderClicked; - SearchList.SearchBar = SearchLineEdit; - SearchList.GenerateItem += GenerateButton; - SearchList.DataFilterCondition += DataFilterCondition; - SearchList.ItemKeyBindDown += (args, data) => OnEntryKeyBindDown?.Invoke(args, data); + SearchList.SearchBar = SearchLineEdit; + SearchList.GenerateItem += GenerateButton; + SearchList.DataFilterCondition += DataFilterCondition; + SearchList.ItemKeyBindDown += (args, data) => OnEntryKeyBindDown?.Invoke(args, data); - RefreshPlayerList(_adminSystem.PlayerList); + RefreshPlayerList(_adminSystem.PlayerList); - } + } - #region Antag Overlay + #region Antag Overlay - private void OverlayEnabled() - { - OverlayButton.Pressed = true; - } + private void OverlayEnabled() + { + OverlayButton.Pressed = true; + } - private void OverlayDisabled() + private void OverlayDisabled() + { + OverlayButton.Pressed = false; + } + + private void OverlayButtonPressed(ButtonEventArgs args) + { + if (args.Button.Pressed) { - OverlayButton.Pressed = false; + _adminSystem.AdminOverlayOn(); } - - private void OverlayButtonPressed(ButtonEventArgs args) + else { - if (args.Button.Pressed) - { - _adminSystem.AdminOverlayOn(); - } - else - { - _adminSystem.AdminOverlayOff(); - } + _adminSystem.AdminOverlayOff(); } + } + + #endregion - #endregion + private void ShowDisconnectedPressed(ButtonEventArgs args) + { + _showDisconnected = args.Button.Pressed; + RefreshPlayerList(_players); + } - private void ShowDisconnectedPressed(ButtonEventArgs args) + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) { - _showDisconnected = args.Button.Pressed; - RefreshPlayerList(_players); + _adminSystem.PlayerListChanged -= RefreshPlayerList; + _adminSystem.OverlayEnabled -= OverlayEnabled; + _adminSystem.OverlayDisabled -= OverlayDisabled; + + OverlayButton.OnPressed -= OverlayButtonPressed; + + ListHeader.OnHeaderClicked -= HeaderClicked; } + } - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); + #region ListContainer - if (disposing) - { - _adminSystem.PlayerListChanged -= RefreshPlayerList; - _adminSystem.OverlayEnabled -= OverlayEnabled; - _adminSystem.OverlayDisabled -= OverlayDisabled; + private void RefreshPlayerList(IReadOnlyList players) + { + _players = players; + PlayerCount.Text = Loc.GetString("player-tab-player-count", ("count", _playerMan.PlayerCount)); - OverlayButton.OnPressed -= OverlayButtonPressed; + var filteredPlayers = players.Where(info => _showDisconnected || info.Connected).ToList(); - ListHeader.OnHeaderClicked -= HeaderClicked; - } - } + var sortedPlayers = new List(filteredPlayers); + sortedPlayers.Sort(Compare); - #region ListContainer + UpdateHeaderSymbols(); - private void RefreshPlayerList(IReadOnlyList players) - { - _players = players; - PlayerCount.Text = Loc.GetString("player-tab-player-count", ("count", _playerMan.PlayerCount)); + SearchList.PopulateList(sortedPlayers.Select(info => new PlayerListData(info, + $"{info.Username} {info.CharacterName} {info.IdentityName} {info.StartingJob}")) + .ToList()); + } - var filteredPlayers = players.Where(info => _showDisconnected || info.Connected).ToList(); + private void GenerateButton(ListData data, ListContainerButton button) + { + if (data is not PlayerListData { Info: var player}) + return; - var sortedPlayers = new List(filteredPlayers); - sortedPlayers.Sort(Compare); + var entry = new PlayerTabEntry(player, new StyleBoxFlat(button.Index % 2 == 0 ? _altColor : _defaultColor)); + button.AddChild(entry); + button.ToolTip = $"{player.Username}, {player.CharacterName}, {player.IdentityName}, {player.StartingJob}"; + } - UpdateHeaderSymbols(); + /// + /// Determines whether is contained in .FilteringString. + /// If all characters are lowercase, the comparison ignores case. + /// If there is an uppercase character, the comparison is case sensitive. + /// + /// + /// + /// Whether is contained in .FilteringString. + private bool DataFilterCondition(string filter, ListData listData) + { + if (listData is not PlayerListData {Info: var info, FilteringString: var playerString}) + return false; - SearchList.PopulateList(sortedPlayers.Select(info => new PlayerListData(info, - $"{info.Username} {info.CharacterName} {info.IdentityName} {info.StartingJob}")) - .ToList()); - } + if (!_showDisconnected && !info.Connected) + return false; - private void GenerateButton(ListData data, ListContainerButton button) + if (IsAllLower(filter)) { - if (data is not PlayerListData { Info: var player}) - return; - - var entry = new PlayerTabEntry(player, new StyleBoxFlat(button.Index % 2 == 0 ? _altColor : _defaultColor)); - button.AddChild(entry); - button.ToolTip = $"{player.Username}, {player.CharacterName}, {player.IdentityName}, {player.StartingJob}"; + if (!playerString.Contains(filter, StringComparison.CurrentCultureIgnoreCase)) + return false; } - - /// - /// Determines whether is contained in .FilteringString. - /// If all characters are lowercase, the comparison ignores case. - /// If there is an uppercase character, the comparison is case sensitive. - /// - /// - /// - /// Whether is contained in .FilteringString. - private bool DataFilterCondition(string filter, ListData listData) + else { - if (listData is not PlayerListData {Info: var info, FilteringString: var playerString}) + if (!playerString.Contains(filter)) return false; + } - if (!_showDisconnected && !info.Connected) - return false; + return true; + } - if (IsAllLower(filter)) - { - if (!playerString.Contains(filter, StringComparison.CurrentCultureIgnoreCase)) - return false; - } - else - { - if (!playerString.Contains(filter)) - return false; - } - - return true; + private bool IsAllLower(string input) + { + foreach (var c in input) + { + if (char.IsLetter(c) && !char.IsLower(c)) + return false; } - private bool IsAllLower(string input) - { - foreach (var c in input) - { - if (char.IsLetter(c) && !char.IsLower(c)) - return false; - } + return true; + } - return true; - } + #endregion - #endregion + #region Header - #region Header + private void UpdateHeaderSymbols() + { + ListHeader.ResetHeaderText(); + ListHeader.GetHeader(_headerClicked).Text += $" {(_ascending ? ArrowUp : ArrowDown)}"; + } - private void UpdateHeaderSymbols() + private int Compare(PlayerInfo x, PlayerInfo y) + { + if (!_ascending) { - ListHeader.ResetHeaderText(); - ListHeader.GetHeader(_headerClicked).Text += $" {(_ascending ? ArrowUp : ArrowDown)}"; + (x, y) = (y, x); } - private int Compare(PlayerInfo x, PlayerInfo y) + return _headerClicked switch { - if (!_ascending) - { - (x, y) = (y, x); - } - - return _headerClicked switch - { - Header.Username => Compare(x.Username, y.Username), - Header.Character => Compare(x.CharacterName, y.CharacterName), - Header.Job => Compare(x.StartingJob, y.StartingJob), - Header.Antagonist => x.Antag.CompareTo(y.Antag), - Header.Sponsor => Compare(x.Sponsor?.Tier, y.Sponsor?.Tier), //ADT-SPONSORS - Header.Playtime => TimeSpan.Compare(x.OverallPlaytime ?? default, y.OverallPlaytime ?? default), - _ => 1 - }; - } + Header.Username => Compare(x.Username, y.Username), + Header.Character => Compare(x.CharacterName, y.CharacterName), + Header.Job => Compare(x.StartingJob, y.StartingJob), + Header.Antagonist => x.Antag.CompareTo(y.Antag), + Header.Playtime => TimeSpan.Compare(x.OverallPlaytime ?? default, y.OverallPlaytime ?? default), + _ => 1 + }; + } - //ADT-SPONSORS - private int Compare(int? x, int? y) - { - if (!x.HasValue) - return -1; - if (!y.HasValue) - return 1; - - if (x == y) - return 0; - else if (x > y) - return 1; - else - return -1; - } - //ADT-SPONSORS + private int Compare(string x, string y) + { + return string.Compare(x, y, StringComparison.OrdinalIgnoreCase); + } - private int Compare(string x, string y) + private void HeaderClicked(Header header) + { + if (_headerClicked == header) { - return string.Compare(x, y, StringComparison.OrdinalIgnoreCase); + _ascending = !_ascending; } - - private void HeaderClicked(Header header) + else { - if (_headerClicked == header) - { - _ascending = !_ascending; - } - else - { - _headerClicked = header; - _ascending = true; - } - - RefreshPlayerList(_adminSystem.PlayerList); + _headerClicked = header; + _ascending = true; } - #endregion + RefreshPlayerList(_adminSystem.PlayerList); } - public record PlayerListData(PlayerInfo Info, string FilteringString) : ListData; + #endregion } + +public record PlayerListData(PlayerInfo Info, string FilteringString) : ListData; diff --git a/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs b/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs index 5d1985485c4..f088ac1976b 100644 --- a/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs +++ b/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs @@ -1,7 +1,5 @@ using Content.Shared.Anomaly; -using Content.Shared.Gravity; using JetBrains.Annotations; -using Robust.Client.GameObjects; using Robust.Client.UserInterface; namespace Content.Client.Anomaly.Ui; diff --git a/Content.Client/Atmos/Monitor/UI/AirAlarmBoundUserInterface.cs b/Content.Client/Atmos/Monitor/UI/AirAlarmBoundUserInterface.cs index 2ae15188355..d9e94e373b4 100644 --- a/Content.Client/Atmos/Monitor/UI/AirAlarmBoundUserInterface.cs +++ b/Content.Client/Atmos/Monitor/UI/AirAlarmBoundUserInterface.cs @@ -30,7 +30,6 @@ protected override void Open() _window.AirAlarmModeChanged += OnAirAlarmModeChanged; _window.AutoModeChanged += OnAutoModeChanged; _window.ResyncAllRequested += ResyncAllDevices; - _window.AirAlarmTabChange += OnTabChanged; } private void ResyncAllDevices() @@ -63,11 +62,6 @@ private void OnThresholdChanged(string address, AtmosMonitorThresholdType type, SendMessage(new AirAlarmUpdateAlarmThresholdMessage(address, type, threshold, gas)); } - private void OnTabChanged(AirAlarmTab tab) - { - SendMessage(new AirAlarmTabSetMessage(tab)); - } - protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); diff --git a/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs b/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs index eeec11c7660..e1425ac491b 100644 --- a/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs +++ b/Content.Client/Atmos/Monitor/UI/AirAlarmWindow.xaml.cs @@ -23,7 +23,6 @@ public sealed partial class AirAlarmWindow : FancyWindow public event Action? AirAlarmModeChanged; public event Action? AutoModeChanged; public event Action? ResyncAllRequested; - public event Action? AirAlarmTabChange; private RichTextLabel _address => CDeviceAddress; private RichTextLabel _deviceTotal => CDeviceTotal; @@ -80,11 +79,6 @@ public AirAlarmWindow() _tabContainer.SetTabTitle(1, Loc.GetString("air-alarm-ui-window-tab-scrubbers")); _tabContainer.SetTabTitle(2, Loc.GetString("air-alarm-ui-window-tab-sensors")); - _tabContainer.OnTabChanged += idx => - { - AirAlarmTabChange!((AirAlarmTab) idx); - }; - _resyncDevices.OnPressed += _ => { _ventDevices.RemoveAllChildren(); @@ -117,8 +111,6 @@ public void UpdateState(AirAlarmUIState state) { UpdateDeviceData(addr, dev); } - - _tabContainer.CurrentTab = (int) state.Tab; } public void UpdateModeSelector(AirAlarmMode mode) diff --git a/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs b/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs index b54af3a5871..bb24da44e13 100644 --- a/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs +++ b/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs @@ -16,6 +16,8 @@ namespace Content.Client.Atmos.UI [GenerateTypedNameReferences] public sealed partial class GasAnalyzerWindow : DefaultWindow { + private NetEntity _currentEntity = NetEntity.Invalid; + public GasAnalyzerWindow() { RobustXamlLoader.Load(this); @@ -55,6 +57,13 @@ public void Populate(GasAnalyzerUserMessage msg) // Device Tab if (msg.NodeGasMixes.Length > 1) { + if (_currentEntity != msg.DeviceUid) + { + // when we get new device data switch to the device tab + CTabContainer.CurrentTab = 0; + _currentEntity = msg.DeviceUid; + } + CTabContainer.SetTabVisible(0, true); CTabContainer.SetTabTitle(0, Loc.GetString("gas-analyzer-window-tab-title-capitalized", ("title", msg.DeviceName))); // Set up Grid @@ -143,6 +152,7 @@ public void Populate(GasAnalyzerUserMessage msg) CTabContainer.SetTabVisible(0, false); CTabContainer.CurrentTab = 1; minSize = new Vector2(CEnvironmentMix.DesiredSize.X + 40, MinSize.Y); + _currentEntity = NetEntity.Invalid; } MinSize = minSize; diff --git a/Content.Client/CartridgeLoader/Cartridges/CrewManifestUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/CrewManifestUiFragment.xaml.cs index 273707cb6ea..27ddd51815e 100644 --- a/Content.Client/CartridgeLoader/Cartridges/CrewManifestUiFragment.xaml.cs +++ b/Content.Client/CartridgeLoader/Cartridges/CrewManifestUiFragment.xaml.cs @@ -1,4 +1,5 @@ -using Content.Shared.CrewManifest; +using Content.Client.CrewManifest.UI; +using Content.Shared.CrewManifest; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml index bd5879408ef..fd5a7bb1617 100644 --- a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml +++ b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml @@ -26,7 +26,7 @@ Text="{Loc 'news-read-ui-next-text'}" ToolTip="{Loc 'news-read-ui-next-tooltip'}"/> - +