aboutsummaryrefslogtreecommitdiff
path: root/webAO
diff options
context:
space:
mode:
Diffstat (limited to 'webAO')
-rw-r--r--webAO/client.ts31
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