From aa2ab6fbd6f55180b90bc841fc83ef6ffa66b4fe Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 27 Jan 2019 13:24:16 +0100 Subject: [PATCH] Made chat notifications a littlebit more silent --- shared/js/connection.ts | 8 ++++---- shared/js/sound/Sounds.ts | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/shared/js/connection.ts b/shared/js/connection.ts index 75510c6c..a825d25a 100644 --- a/shared/js/connection.ts +++ b/shared/js/connection.ts @@ -1189,17 +1189,17 @@ class ConnectionCommandHandler { return; } if(invoker == this.connection._client.getClient()) { - sound.play(Sound.MESSAGE_SEND); + sound.play(Sound.MESSAGE_SEND, {default_volume: .5}); target.chat(true).appendMessage("{0}: {1}", true, this.connection._client.getClient().createChatTag(true), MessageHelper.bbcode_chat(json["msg"])); } else { - sound.play(Sound.MESSAGE_RECEIVED); + sound.play(Sound.MESSAGE_RECEIVED, {default_volume: .5}); invoker.chat(true).appendMessage("{0}: {1}", true, ClientEntry.chatTag(json["invokerid"], json["invokername"], json["invokeruid"], true), MessageHelper.bbcode_chat(json["msg"])); } } else if(mode == 2) { if(json["invokerid"] == this.connection._client.clientId) - sound.play(Sound.MESSAGE_SEND); + sound.play(Sound.MESSAGE_SEND, {default_volume: .5}); else - sound.play(Sound.MESSAGE_RECEIVED); + sound.play(Sound.MESSAGE_RECEIVED, {default_volume: .5}); chat.channelChat().appendMessage("{0}: {1}", true, ClientEntry.chatTag(json["invokerid"], json["invokername"], json["invokeruid"], true), MessageHelper.bbcode_chat(json["msg"])) } else if(mode == 3) { chat.serverChat().appendMessage("{0}: {1}", true, ClientEntry.chatTag(json["invokerid"], json["invokername"], json["invokeruid"], true), MessageHelper.bbcode_chat(json["msg"])); diff --git a/shared/js/sound/Sounds.ts b/shared/js/sound/Sounds.ts index 3b2f0ed8..72c64648 100644 --- a/shared/js/sound/Sounds.ts +++ b/shared/js/sound/Sounds.ts @@ -83,10 +83,14 @@ namespace sound { speech_mapping[key] = {key: key, filename: file} as SpeechFile; } - export function get_sound_volume(sound: Sound) : number { + export function get_sound_volume(sound: Sound, default_volume?: number) : number { let result = speech_volume[sound]; - if(typeof(result) === "undefined") - result = 1; + if(typeof(result) === "undefined") { + if(typeof(default_volume) !== "undefined") + result = default_volume; + else + result = 1; + } return result; } @@ -213,6 +217,8 @@ namespace sound { export interface PlaybackOptions { ignore_muted?: boolean; ignore_overlap?: boolean; + + default_volume?: number; } export function play(sound: Sound, options?: PlaybackOptions) { @@ -234,7 +240,7 @@ namespace sound { const path = "audio/" + file.filename; const context = audio.player.context(); - const volume = get_sound_volume(sound); + const volume = get_sound_volume(sound, options.default_volume); console.log(tr("Replaying sound %s (Sound volume: %o | Master volume %o)"), sound, volume, master_volume); if(volume == 0) return;