Skip to content

Commit

Permalink
AHelp Sound Improvements (Simple-Station#585)
Browse files Browse the repository at this point in the history
# Description

I don't like the bwoink.
I also don't like being notified about the thing I'm staring at.

If anyone has better quality sounds to suggest, I might use those
instead.

---

<details><summary><h1>Media</h1></summary>
<p>

## Different sounds


https://github.com/user-attachments/assets/8003f785-0cd0-44c9-94c2-919c59adac5c

## Ignore sounds when looking


https://github.com/user-attachments/assets/2ac99672-a601-41e0-a5cd-25ce9c1a5c49

</p>
</details>

---

# Changelog

:cl:
- tweak: The AdminHelp sound has changed to three that play under
different circumstances

---------

Signed-off-by: DEATHB4DEFEAT <[email protected]>
  • Loading branch information
DEATHB4DEFEAT authored Aug 2, 2024
1 parent aa9664d commit 6b86a6d
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 34 deletions.
21 changes: 7 additions & 14 deletions Content.Client/Administration/Systems/AdminSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ public sealed partial class AdminSystem : EntitySystem
{
public event Action<List<PlayerInfo>>? PlayerListChanged;

private Dictionary<NetUserId, PlayerInfo>? _playerList;
public IReadOnlyList<PlayerInfo> PlayerList
{
get
{
if (_playerList != null) return _playerList.Values.ToList();

return new List<PlayerInfo>();
}
}
public Dictionary<NetUserId, PlayerInfo> PlayerInfos = new();
public IReadOnlyList<PlayerInfo> PlayerList =>
PlayerInfos != null ? PlayerInfos.Values.ToList() : new List<PlayerInfo>();

public override void Initialize()
{
Expand All @@ -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);
}
}
Expand Down
11 changes: 9 additions & 2 deletions Content.Client/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<BwoinkTextMessage>? OnBwoinkTextMessageRecieved;
private (TimeSpan Timestamp, bool Typing) _lastTypingUpdateSent;
Expand All @@ -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));
Expand All @@ -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));
Expand Down
28 changes: 12 additions & 16 deletions Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Content.Client.UserInterface.Systems.Bwoink;
public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSystem>, IOnStateChanged<GameplayState>, IOnStateChanged<LobbyState>
{
[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!;
Expand All @@ -43,9 +42,14 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
private MenuButton? GameAHelpButton => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>()?.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()
{
Expand All @@ -55,9 +59,9 @@ public override void Initialize()
SubscribeNetworkEvent<BwoinkPlayerTypingUpdated>(PeopleTypingUpdated);

_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
_config.OnValueChanged(CCVars.AHelpSound, v => _aHelpSound = v, true);
}


public void UnloadButton()
{
if (GameAHelpButton != null)
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,6 @@ public static readonly CVarDef<bool>
CVarDef.Create("audio.admin_chat_sound_path", "/Audio/Items/pop.ogg", CVar.ARCHIVE | CVar.CLIENT | CVar.REPLICATED);
public static readonly CVarDef<float> AdminChatSoundVolume =
CVarDef.Create("audio.admin_chat_sound_volume", -5f, CVar.ARCHIVE | CVar.CLIENT | CVar.REPLICATED);
public static readonly CVarDef<string> AHelpSound =
CVarDef.Create("audio.ahelp_sound", "/Audio/Effects/adminhelp.ogg", CVar.ARCHIVE | CVar.CLIENTONLY);

/*
* HUD
Expand Down
Binary file added Resources/Audio/Admin/ahelp_error.ogg
Binary file not shown.
Binary file added Resources/Audio/Admin/ahelp_receive.ogg
Binary file not shown.
Binary file added Resources/Audio/Admin/ahelp_send.ogg
Binary file not shown.
9 changes: 9 additions & 0 deletions Resources/Audio/Admin/attributions.yml
Original file line number Diff line number Diff line change
@@ -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"
Binary file removed Resources/Audio/Effects/adminhelp.ogg
Binary file not shown.

0 comments on commit 6b86a6d

Please sign in to comment.