diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-03-27 01:29:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-27 01:29:07 +0100 |
| commit | 053898d659137d59639b8af881b6958dabda0bb4 (patch) | |
| tree | 7308cb1d0551364eb8c56aeb9035ca1e972e4cf3 /webAO/client.ts | |
| parent | 6ef53f2461005153852ab9deb4d8e0ac7319be97 (diff) | |
| parent | 24f5b0970e87a879967bdb1d6b15b5a90b8148d8 (diff) | |
Merge pull request #137 from AttorneyOnline/blip-speed
Text speed
Diffstat (limited to 'webAO/client.ts')
| -rw-r--r-- | webAO/client.ts | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/webAO/client.ts b/webAO/client.ts index 9b60359..ac34334 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,30 @@ 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 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 === '}') { + 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); + 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 +2375,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 |
