From 764abf042db6017d89eeecf49809ad3fcd3ec5fb Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 17:59:36 +0200 Subject: get shout length from resources --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 77b61bb..ead9d0c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1604,7 +1604,7 @@ async changeBackground(position) { this.shoutaudio.src = shoutUrl; this.shoutaudio.play(); - this.shoutTimer = 850; + this.shoutTimer = client.resources[shout]["duration"]; } else { this.shoutTimer = 0; } -- cgit From 0a66c6ed8c88a6e9a58453cdc6293a3a14891020 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 18:00:47 +0200 Subject: move blips to the end like in client --- webAO/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index ead9d0c..632bf69 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1511,7 +1511,6 @@ async changeBackground(position) { */ async say(chatmsg) { this.chatmsg = chatmsg; - this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(this.chatmsg.blips.toLowerCase())}.wav`); this.textnow = ""; this.sfxplayed = 0; this.textTimer = 0; @@ -1651,6 +1650,8 @@ async changeBackground(position) { } } + this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(this.chatmsg.blips.toLowerCase())}.wav`); + this.tick(); } -- cgit From 4518ae6f35e907b4a08b741f2b2b8cdb94283f31 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 18:04:26 +0200 Subject: clear the timeout first, then get the html elements --- webAO/client.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 632bf69..1a4d8db 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1516,27 +1516,19 @@ async changeBackground(position) { this.textTimer = 0; this._animating = true; - const charSprite = document.getElementById("client_char"); - const pairSprite = document.getElementById("client_pair_char"); - const nameBox = document.getElementById("client_name"); - const chatBox = document.getElementById("client_chat"); - const chatContainerBox = document.getElementById("client_chatcontainer"); - const waitingBox = document.getElementById("client_chatwaiting"); - const eviBox = document.getElementById("client_evi"); - const shoutSprite = document.getElementById("client_shout"); - const chatBoxInner = document.getElementById("client_inner_chat"); - const fg = document.getElementById("client_fg"); - const gamewindow = document.getElementById("client_gamewindow"); - - let gifLength = 0; - // stop updater clearTimeout(this.updater); + const fg = document.getElementById("client_fg"); + const gamewindow = document.getElementById("client_gamewindow"); + const waitingBox = document.getElementById("client_chatwaiting"); + // Reset CSS animation fg.style.animation = ""; gamewindow.style.animation = ""; waitingBox.innerText = ""; + + const eviBox = document.getElementById("client_evi"); if (this.lastEvi !== this.chatmsg.evidence) { eviBox.style.opacity = "0"; @@ -1544,6 +1536,14 @@ async changeBackground(position) { } this.lastEvi = this.chatmsg.evidence; + const charSprite = document.getElementById("client_char"); + const pairSprite = document.getElementById("client_pair_char"); + + const nameBox = document.getElementById("client_name"); + const chatBox = document.getElementById("client_chat"); + const chatContainerBox = document.getElementById("client_chatcontainer"); + const chatBoxInner = document.getElementById("client_inner_chat"); + //Clear out the last message chatBoxInner.innerText = this.textnow; nameBox.innerText = this.chatmsg.nameplate; @@ -1580,6 +1580,7 @@ async changeBackground(position) { } // gets which shout shall played + const shoutSprite = document.getElementById("client_shout"); const shout = this.shouts[this.chatmsg.objection]; if (shout) { // Hide message box @@ -1609,6 +1610,7 @@ async changeBackground(position) { } this.chatmsg.startpreanim = true; + let gifLength = 0; switch (this.chatmsg.type) { // case 0: // normal emote, no preanim -- cgit From ca68537c61b64f40f0fa6a43f1fadb2671bfaf85 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 18:04:49 +0200 Subject: same in tick --- webAO/client.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 1a4d8db..3bcde46 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1695,6 +1695,10 @@ async changeBackground(position) { * XXX: This relies on a global variable `this.chatmsg`! */ tick() { + if (this._animating) { + this.updater = setTimeout(() => this.tick(), UPDATE_INTERVAL); + } + const nameBox = document.getElementById("client_name"); const chatBox = document.getElementById("client_chat"); const chatContainerBox = document.getElementById("client_chatcontainer"); @@ -1703,11 +1707,7 @@ async changeBackground(position) { const pairSprite = document.getElementById("client_pair_char"); const eviBox = document.getElementById("client_evi"); const shoutSprite = document.getElementById("client_shout"); - const chatBoxInner = document.getElementById("client_inner_chat"); - - if (this._animating) { - this.updater = setTimeout(() => this.tick(), UPDATE_INTERVAL); - } + const chatBoxInner = document.getElementById("client_inner_chat"); // TODO: preanims sometimes play when they're not supposed to if (this.textTimer >= this.shoutTimer && this.chatmsg.startpreanim) { -- cgit From c04ddc5a1f054e0b05ce66c0d26ae1653c41fccf Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 18:11:25 +0200 Subject: chatcontainer is only used once in this block --- webAO/client.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 3bcde46..1c306c9 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1539,9 +1539,9 @@ async changeBackground(position) { const charSprite = document.getElementById("client_char"); const pairSprite = document.getElementById("client_pair_char"); + const chatContainerBox = document.getElementById("client_chatcontainer"); const nameBox = document.getElementById("client_name"); - const chatBox = document.getElementById("client_chat"); - const chatContainerBox = document.getElementById("client_chatcontainer"); + const chatBox = document.getElementById("client_chat"); const chatBoxInner = document.getElementById("client_inner_chat"); //Clear out the last message @@ -1701,7 +1701,6 @@ async changeBackground(position) { const nameBox = document.getElementById("client_name"); const chatBox = document.getElementById("client_chat"); - const chatContainerBox = document.getElementById("client_chatcontainer"); const waitingBox = document.getElementById("client_chatwaiting"); const charSprite = document.getElementById("client_char"); const pairSprite = document.getElementById("client_pair_char"); @@ -1774,7 +1773,7 @@ async changeBackground(position) { } } - chatContainerBox.style.display = "block"; + document.getElementById("client_chatcontainer").style.display = "block"; nameBox.style.display = "block"; nameBox.style.fontSize = (nameBox.offsetHeight * 0.7) + "px"; -- cgit From eab2ace4ae4b558fd6bb224b7c62851cf6b457f3 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 18:27:44 +0200 Subject: don't skip the sfx if there was a flash/shake --- webAO/client.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 1c306c9..b8ffd3c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1299,6 +1299,18 @@ class Viewport { return `${AO_HOST}background/${encodeURI(this.bgname.toLowerCase())}/`; } + + /** + * Play any SFX + * + * @param {string} sfxname + */ + async playSFX(sfxname) { + this.sfxaudio.pause(); + this.sfxaudio.src = sfxname; + this.sfxaudio.play(); + } + /** * Changes the viewport background based on a given position. * @@ -1713,17 +1725,11 @@ async changeBackground(position) { // Effect stuff if (this.chatmsg.flash === 2) { // Shake screen - this.sfxaudio.pause(); - this.sfxplayed = 1; - this.sfxaudio.src = AO_HOST + "sounds/general/sfx-stab.wav"; - this.sfxaudio.play(); + this.playSFX(AO_HOST + "sounds/general/sfx-stab.wav"); document.getElementById("client_gamewindow").style.animation = "shake 0.2s 1"; } else if (this.chatmsg.flash === 1) { // Flash screen - this.sfxaudio.pause(); - this.sfxplayed = 1; - this.sfxaudio.src = AO_HOST + "sounds/general/sfx-realization.wav"; - this.sfxaudio.play(); + this.playSFX(AO_HOST + "sounds/general/sfx-realization.wav"); document.getElementById("client_fg").style.animation = "flash 0.4s 1"; } @@ -1838,11 +1844,9 @@ async changeBackground(position) { } if (!this.sfxplayed && this.chatmsg.snddelay + this.shoutTimer >= this.textTimer) { - this.sfxaudio.pause(); this.sfxplayed = 1; if (this.chatmsg.sound !== "0" && this.chatmsg.sound !== "1" && this.chatmsg.sound !== "" && this.chatmsg.sound !== undefined) { - this.sfxaudio.src = AO_HOST + "sounds/general/" + encodeURI(this.chatmsg.sound.toLowerCase()) + ".wav"; - this.sfxaudio.play(); + this.playSFX(AO_HOST + "sounds/general/" + encodeURI(this.chatmsg.sound.toLowerCase()) + ".wav"); } } this.textTimer = this.textTimer + UPDATE_INTERVAL; -- cgit From 3a45f347bfae89c2d567695342edfda6ea26e13a Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 18:28:32 +0200 Subject: ok enough smash music --- webAO/client.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index b8ffd3c..b106b03 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -919,12 +919,6 @@ class Client extends EventEmitter { document.getElementById("client_charselect").style.display = "none"; } else { document.getElementById("client_charselect").style.display = "block"; - viewport.sfxaudio.pause(); - viewport.sfxaudio.src = "https://s3.wasabisys.com/webao/base/sounds/general/nr_select04.dsp.wav"; - viewport.sfxaudio.play(); - const musicaudio = document.getElementById("client_musicaudio"); - musicaudio.src = "https://s3.wasabisys.com/webao/base/sounds/music/[ssbm] menu 1.mp3"; - musicaudio.play(); } } -- cgit