Make playglobalsound much quiter (#7910)

* Make playglobalsound default much quieter

Also adds volume override.

* tweak

* reviews by the cutest gradient girl
This commit is contained in:
metalgearsloth
2022-05-03 19:32:32 +10:00
committed by GitHub
parent 89fda5ec83
commit 983b004607
2 changed files with 19 additions and 3 deletions

View File

@@ -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);
}
}

View File

@@ -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 <path> [user 1] ... [user n]
play-global-sound-command-help = playglobalsound <path> [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.