From 983b004607f4cfbce6f296725bfd887b9879ab5c Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 3 May 2022 19:32:32 +1000 Subject: [PATCH] Make playglobalsound much quiter (#7910) * Make playglobalsound default much quieter Also adds volume override. * tweak * reviews by the cutest gradient girl --- .../Commands/PlayGlobalSound.cs | 19 +++++++++++++++++-- .../commands/play-global-sound-command.ftl | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Content.Server/Administration/Commands/PlayGlobalSound.cs b/Content.Server/Administration/Commands/PlayGlobalSound.cs index 7e92ece246..b42abbee61 100644 --- a/Content.Server/Administration/Commands/PlayGlobalSound.cs +++ b/Content.Server/Administration/Commands/PlayGlobalSound.cs @@ -21,6 +21,7 @@ public sealed class PlayGlobalSound : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { Filter filter; + var audio = AudioParams.Default.WithVolume(-8); switch (args.Length) { @@ -37,10 +38,24 @@ public sealed class PlayGlobalSound : IConsoleCommand // One or more users specified. default: + var volumeOffset = 0; + + // Try to specify a new volume to play it at. + if (int.TryParse(args[1], out var volume)) + { + audio = audio.WithVolume(volume); + volumeOffset = 1; + } + else + { + shell.WriteError(Loc.GetString("play-global-sound-command-volume-parse", ("volume", args[1]))); + return; + } + filter = Filter.Empty(); // Skip the first argument, which is the sound path. - for (var i = 1; i < args.Length; i++) + for (var i = 1 + volumeOffset; i < args.Length; i++) { var username = args[i]; @@ -55,6 +70,6 @@ public sealed class PlayGlobalSound : IConsoleCommand break; } - SoundSystem.Play(filter, args[0], AudioParams.Default); + SoundSystem.Play(filter, args[0], audio); } } diff --git a/Resources/Locale/en-US/administration/commands/play-global-sound-command.ftl b/Resources/Locale/en-US/administration/commands/play-global-sound-command.ftl index 2be289fd5f..2c4d9fbc72 100644 --- a/Resources/Locale/en-US/administration/commands/play-global-sound-command.ftl +++ b/Resources/Locale/en-US/administration/commands/play-global-sound-command.ftl @@ -1,3 +1,4 @@ play-global-sound-command-description = Plays a global sound for a specific player or for every connected player if no players are specified. -play-global-sound-command-help = playglobalsound [user 1] ... [user n] +play-global-sound-command-help = playglobalsound [volume] [user 1] ... [user n] play-global-sound-command-player-not-found = Player "{$username}" not found. +play-global-sound-command-volume-parse = Invalid volume of {$volume} specified.