diff --git a/Content.Client/Administration/Systems/AdminSystem.cs b/Content.Client/Administration/Systems/AdminSystem.cs index f7451d23047..db1b721343e 100644 --- a/Content.Client/Administration/Systems/AdminSystem.cs +++ b/Content.Client/Administration/Systems/AdminSystem.cs @@ -10,16 +10,9 @@ public sealed partial class AdminSystem : EntitySystem { public event Action>? PlayerListChanged; - private Dictionary? _playerList; - public IReadOnlyList PlayerList - { - get - { - if (_playerList != null) return _playerList.Values.ToList(); - - return new List(); - } - } + public Dictionary PlayerInfos = new(); + public IReadOnlyList PlayerList => + PlayerInfos != null ? PlayerInfos.Values.ToList() : new List(); public override void Initialize() { @@ -40,15 +33,15 @@ private void OnPlayerInfoChanged(PlayerInfoChangedEvent ev) { if(ev.PlayerInfo == null) return; - if (_playerList == null) _playerList = new(); + if (PlayerInfos == null) PlayerInfos = new(); - _playerList[ev.PlayerInfo.SessionId] = ev.PlayerInfo; - PlayerListChanged?.Invoke(_playerList.Values.ToList()); + PlayerInfos[ev.PlayerInfo.SessionId] = ev.PlayerInfo; + PlayerListChanged?.Invoke(PlayerInfos.Values.ToList()); } private void OnPlayerListChanged(FullPlayerListEvent msg) { - _playerList = msg.PlayersInfo.ToDictionary(x => x.SessionId, x => x); + PlayerInfos = msg.PlayersInfo.ToDictionary(x => x.SessionId, x => x); PlayerListChanged?.Invoke(msg.PlayersInfo); } } diff --git a/Content.Client/Administration/Systems/BwoinkSystem.cs b/Content.Client/Administration/Systems/BwoinkSystem.cs index 5166dc8416b..a3b295d6b6e 100644 --- a/Content.Client/Administration/Systems/BwoinkSystem.cs +++ b/Content.Client/Administration/Systems/BwoinkSystem.cs @@ -1,7 +1,10 @@ #nullable enable +using Content.Client.UserInterface.Systems.Bwoink; using Content.Shared.Administration; using JetBrains.Annotations; +using Robust.Client.Audio; using Robust.Shared.Network; +using Robust.Shared.Player; using Robust.Shared.Timing; namespace Content.Client.Administration.Systems @@ -10,6 +13,8 @@ namespace Content.Client.Administration.Systems public sealed class BwoinkSystem : SharedBwoinkSystem { [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly AudioSystem _audio = default!; + [Dependency] private readonly AdminSystem _adminSystem = default!; public event EventHandler? OnBwoinkTextMessageRecieved; private (TimeSpan Timestamp, bool Typing) _lastTypingUpdateSent; @@ -21,6 +26,10 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes public void Send(NetUserId channelId, string text, bool playSound) { + var info = _adminSystem.PlayerInfos.GetValueOrDefault(channelId)?.Connected ?? true; + _audio.PlayGlobal(info ? AHelpUIController.AHelpSendSound : AHelpUIController.AHelpErrorSound, + Filter.Local(), false); + // Reuse the channel ID as the 'true sender'. // Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help. RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound)); @@ -31,9 +40,7 @@ public void SendInputTextUpdated(NetUserId channel, bool typing) { if (_lastTypingUpdateSent.Typing == typing && _lastTypingUpdateSent.Timestamp + TimeSpan.FromSeconds(1) > _timing.RealTime) - { return; - } _lastTypingUpdateSent = (_timing.RealTime, typing); RaiseNetworkEvent(new BwoinkClientTypingUpdated(channel, typing)); diff --git a/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs b/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs index 2c913a2d580..2d2be1babca 100644 --- a/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs +++ b/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs @@ -33,7 +33,6 @@ namespace Content.Client.UserInterface.Systems.Bwoink; public sealed class AHelpUIController: UIController, IOnSystemChanged, IOnStateChanged, IOnStateChanged { [Dependency] private readonly IClientAdminManager _adminManager = default!; - [Dependency] private readonly IConfigurationManager _config = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IClyde _clyde = default!; [Dependency] private readonly IUserInterfaceManager _uiManager = default!; @@ -43,9 +42,14 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged UIManager.GetActiveUIWidgetOrNull()?.AHelpButton; private Button? LobbyAHelpButton => (UIManager.ActiveScreen as LobbyGui)?.AHelpButton; public IAHelpUIHandler? UIHelper; + private bool _discordRelayActive; private bool _hasUnreadAHelp; - private string? _aHelpSound; + + public const string AHelpErrorSound = "/Audio/Admin/ahelp_error.ogg"; + public const string AHelpReceiveSound = "/Audio/Admin/ahelp_receive.ogg"; + public const string AHelpSendSound = "/Audio/Admin/ahelp_send.ogg"; + public override void Initialize() { @@ -55,9 +59,9 @@ public override void Initialize() SubscribeNetworkEvent(PeopleTypingUpdated); _adminManager.AdminStatusUpdated += OnAdminStatusUpdated; - _config.OnValueChanged(CCVars.AHelpSound, v => _aHelpSound = v, true); } + public void UnloadButton() { if (GameAHelpButton != null) @@ -112,14 +116,10 @@ public void OnSystemUnloaded(BwoinkSystem system) private void SetAHelpPressed(bool pressed) { if (GameAHelpButton != null) - { GameAHelpButton.Pressed = pressed; - } if (LobbyAHelpButton != null) - { LobbyAHelpButton.Pressed = pressed; - } UIManager.ClickSound(); UnreadAHelpRead(); @@ -130,22 +130,18 @@ private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage Logger.InfoS("c.s.go.es.bwoink", $"@{message.UserId}: {message.Text}"); var localPlayer = _playerManager.LocalSession; if (localPlayer == null) - { return; - } - if (message.PlaySound && localPlayer.UserId != message.TrueSender) + + EnsureUIHelper(); + + if (message.PlaySound && localPlayer.UserId != message.TrueSender && !UIHelper!.IsOpen) { - if (_aHelpSound != null) - _audio.PlayGlobal(_aHelpSound, Filter.Local(), false); + _audio.PlayGlobal(AHelpReceiveSound, Filter.Local(), false); _clyde.RequestWindowAttention(); } - EnsureUIHelper(); - if (!UIHelper!.IsOpen) - { UnreadAHelpReceived(); - } UIHelper!.Receive(message); } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 628fb797d0b..96941663244 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -818,8 +818,6 @@ public static readonly CVarDef CVarDef.Create("audio.admin_chat_sound_path", "/Audio/Items/pop.ogg", CVar.ARCHIVE | CVar.CLIENT | CVar.REPLICATED); public static readonly CVarDef AdminChatSoundVolume = CVarDef.Create("audio.admin_chat_sound_volume", -5f, CVar.ARCHIVE | CVar.CLIENT | CVar.REPLICATED); - public static readonly CVarDef AHelpSound = - CVarDef.Create("audio.ahelp_sound", "/Audio/Effects/adminhelp.ogg", CVar.ARCHIVE | CVar.CLIENTONLY); /* * HUD diff --git a/Resources/Audio/Admin/ahelp_error.ogg b/Resources/Audio/Admin/ahelp_error.ogg new file mode 100755 index 00000000000..bcdb3267900 Binary files /dev/null and b/Resources/Audio/Admin/ahelp_error.ogg differ diff --git a/Resources/Audio/Admin/ahelp_receive.ogg b/Resources/Audio/Admin/ahelp_receive.ogg new file mode 100755 index 00000000000..eb31b3a8ab3 Binary files /dev/null and b/Resources/Audio/Admin/ahelp_receive.ogg differ diff --git a/Resources/Audio/Admin/ahelp_send.ogg b/Resources/Audio/Admin/ahelp_send.ogg new file mode 100755 index 00000000000..427605cfb80 Binary files /dev/null and b/Resources/Audio/Admin/ahelp_send.ogg differ diff --git a/Resources/Audio/Admin/attributions.yml b/Resources/Audio/Admin/attributions.yml new file mode 100644 index 00000000000..8df7e38c578 --- /dev/null +++ b/Resources/Audio/Admin/attributions.yml @@ -0,0 +1,9 @@ +- files: [ "ahelp_error" ] + license: "CC-BY-NC-SA-3.0" + copyright: "CM-SS13" + source: "https://github.com/cmss13-devs/cmss13/commit/497204fb1660977fb6bf1fe8de153c65c8299d7d" + +- files: [ "ahelp_receive", "ahelp_send" ] + license: "CC-BY-NC-SA-3.0" + copyright: "CM-SS13" + source: "https://github.com/cmss13-devs/cmss13/commit/21e6447cc08aea502f671c819fdbcecbb85e6028" diff --git a/Resources/Audio/Effects/adminhelp.ogg b/Resources/Audio/Effects/adminhelp.ogg deleted file mode 100644 index 704c0fd6d20..00000000000 Binary files a/Resources/Audio/Effects/adminhelp.ogg and /dev/null differ