From c32eea5367295c4ed653ea519ab1963459880f0c Mon Sep 17 00:00:00 2001 From: Caleb Mabry Date: Sat, 26 Mar 2022 16:32:32 -0400 Subject: Text speed --- webAO/client.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/webAO/client.ts b/webAO/client.ts index 9b60359..aa000f7 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -744,6 +744,7 @@ class Client extends EventEmitter { flip: Number(args[13]), flash: Number(args[14]), color: Number(args[15]), + speed: UPDATE_INTERVAL }; if (extrafeatures.includes('cccc_ic_support')) { @@ -1806,6 +1807,7 @@ class Viewport { color: 0, snddelay: 0, preanimdelay: 0, + speed: UPDATE_INTERVAL }; this.shouts = [ @@ -2260,7 +2262,7 @@ class Viewport { this.chatmsg.parsed = await attorneyMarkdown.applyMarkdown(chatmsg.content, this.colors[this.chatmsg.color]) this.tick(); } - + async handleTextTick(charLayers: HTMLImageElement) { const chatBox = document.getElementById('client_chat'); const waitingBox = document.getElementById('client_chatwaiting'); @@ -2300,7 +2302,28 @@ class Viewport { 's': shake, 'f': flash })) - + const textSpeeds = new Set(['{', '}']) + + // Changing Text Speed + if (textSpeeds.has(characterElement.innerHTML)) { + // Grab them all in a row + const index = this.textnow.length + for(let i = this.textnow.length; i < this.chatmsg.content.length; i++) { + const currentCharacter = this.chatmsg.parsed[i - 1].innerHTML + if (currentCharacter === '{') { + if (this.chatmsg.speed > 0) { + this.chatmsg.speed -= 20 + } + } else if(currentCharacter === '}') { + this.chatmsg.speed += 20 + } else { + // No longer at a speed character + this.textnow = this.chatmsg.content.substring(0, i); + break + } + } + } + if (characterElement.innerHTML === COMMAND_IDENTIFIER && commands.has(nextCharacterElement?.innerHTML)) { this.textnow = this.chatmsg.content.substring(0, this.textnow.length + 1); await commands.get(nextCharacterElement.innerHTML)() @@ -2350,7 +2373,7 @@ class Viewport { * XXX: This relies on a global variable `this.chatmsg`! */ async tick() { - await delay(UPDATE_INTERVAL) + await delay(this.chatmsg.speed) if (this.textnow === this.chatmsg.content) { return -- cgit From 7386f4cbec11b138e49d94a24f5a2368eb009994 Mon Sep 17 00:00:00 2001 From: Caleb Mabry Date: Sat, 26 Mar 2022 17:00:45 -0400 Subject: Adding limits of 120 ms for slowness --- webAO/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webAO/client.ts b/webAO/client.ts index aa000f7..9c1598d 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -2307,14 +2307,14 @@ class Viewport { // Changing Text Speed if (textSpeeds.has(characterElement.innerHTML)) { // Grab them all in a row - const index = this.textnow.length + const MAX_SLOW_CHATSPEED = 120 for(let i = this.textnow.length; i < this.chatmsg.content.length; i++) { const currentCharacter = this.chatmsg.parsed[i - 1].innerHTML if (currentCharacter === '{') { if (this.chatmsg.speed > 0) { this.chatmsg.speed -= 20 } - } else if(currentCharacter === '}') { + } else if(currentCharacter === '}' && this.chatmsg.speed < MAX_SLOW_CHATSPEED) { this.chatmsg.speed += 20 } else { // No longer at a speed character -- cgit From 24f5b0970e87a879967bdb1d6b15b5a90b8148d8 Mon Sep 17 00:00:00 2001 From: Caleb Mabry Date: Sat, 26 Mar 2022 17:02:14 -0400 Subject: Only do it if match closing character --- webAO/client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webAO/client.ts b/webAO/client.ts index 9c1598d..ac34334 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -2314,8 +2314,10 @@ class Viewport { if (this.chatmsg.speed > 0) { this.chatmsg.speed -= 20 } - } else if(currentCharacter === '}' && this.chatmsg.speed < MAX_SLOW_CHATSPEED) { - this.chatmsg.speed += 20 + } else if(currentCharacter === '}') { + if(this.chatmsg.speed < MAX_SLOW_CHATSPEED) { + this.chatmsg.speed += 20 + } } else { // No longer at a speed character this.textnow = this.chatmsg.content.substring(0, i); -- cgit