From d025e6fb809c6e85f0f3444aae2ae39f744502ad Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 21 Mar 2020 17:36:28 +0100 Subject: fix #43 by clearing it on dead connection --- webAO/client.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 4facca7..6fda3fc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -478,6 +478,11 @@ class Client extends EventEmitter { */ cleanup() { clearInterval(this.checkUpdater); + + // the connection got rekt, get rid of the old musiclist + document.getElementById("areas").innerHTML = ""; + document.getElementById("client_musiclist").innerHTML = ""; + document.getElementById("client_chartable").innerHTML = ""; } /** @@ -2166,7 +2171,9 @@ export function ReconnectButton() { client = new Client(serverIP); if (client) { mode = "join"; // HACK: see client.onOpen + document.getElementById("client_error").style.display = "none"; + } } window.ReconnectButton = ReconnectButton; -- cgit From 2ed9af82f21f1390d507f04638157b63bfd4b949 Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 25 Mar 2020 23:12:27 +0100 Subject: move encoding stuff to seperate js file --- webAO/client.js | 92 ++------------------------------------------------------- 1 file changed, 3 insertions(+), 89 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 6fda3fc..2ddfb72 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -6,6 +6,8 @@ import Fingerprint2 from 'fingerprintjs2'; +import { unescapeChat, escapeChat, encodeChat, decodeChat, safe_tags } from './encoding.js'; + // Load some defaults for the background and evidence dropdowns import character_arr from "./characters.js"; import background_arr from "./backgrounds.js"; @@ -13,8 +15,6 @@ import evidence_arr from "./evidence.js"; import { EventEmitter } from "events"; -const version = 2.4; - let client; let viewport; @@ -2617,90 +2617,4 @@ export function toggleShout(shout) { selectedShout = shout; } } -window.toggleShout = toggleShout; - -/** - * Escapes a string to be HTML-safe. - * - * XXX: This is unnecessary if we use `createTextNode` instead! - * @param {string} unsafe an unsanitized string - */ -function safe_tags(unsafe) { - if (unsafe) { - return unsafe - .replace(/&/g, "&") - .replace(/") - .replace(/&/g, "") - .replace(/%/g, "") - .replace(/\$/g, ""); -} - -/** - * Unescapes a string to AO1 escape codes. - * @param {string} estring the string to be unescaped - */ -function unescapeChat(estring) { - return estring - .replace(//g, "#") - .replace(//g, "&") - .replace(//g, "%") - .replace(//g, "$"); -} - -/** - * Encode text on client side. - * @param {string} estring the string to be encoded - */ -function encodeChat(estring) { - const selectedEncoding = document.getElementById("client_encoding").value; - if (selectedEncoding === "unicode") { - // This approach works by escaping all special characters to Unicode escape sequences. - // Source: https://gist.github.com/mathiasbynens/1243213 - return estring.replace(/[^\0-~]/g, function (ch) { - return "\\u" + ("000" + ch.charCodeAt().toString(16)).slice(-4); - }); - } else if (selectedEncoding === "utf16") { - // Source: https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String - const buffer = new ArrayBuffer(estring.length * 2); - const result = new Uint16Array(buffer); - for (let i = 0, strLen = estring.length; i < strLen; i++) { - result[i] = estring.charCodeAt(i); - } - return String(result); - } else { - return estring; - } -} - -/** - * Decodes text on client side. - * @param {string} estring the string to be decoded - */ -function decodeChat(estring) { - const selectedDecoding = document.getElementById("client_decoding").value; - if (selectedDecoding === "unicode") { - // Source: https://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode - return estring.replace(/\\u([\d\w]{1,})/gi, function (match, group) { - return String.fromCharCode(parseInt(group, 16)); - }); - } else if (selectedDecoding === "utf16") { - // Source: https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String - return String.fromCharCode.apply(null, new Uint16Array(estring.split(","))); - } else { - return estring; - } -} \ No newline at end of file +window.toggleShout = toggleShout; \ No newline at end of file -- cgit From 84d274165022cd910984a1df145db6e1e4cd49a2 Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 25 Mar 2020 23:17:34 +0100 Subject: get version from package.json --- webAO/client.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 2ddfb72..014ffb0 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -15,6 +15,8 @@ import evidence_arr from "./evidence.js"; import { EventEmitter } from "events"; +const version = require('../package.json').version; + let client; let viewport; -- cgit From 86abb096570c94110bb48edb4b37021eb2cbd273 Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 27 Mar 2020 11:22:35 +0100 Subject: add epic charselect music most people probably won't hear it because it is automatically played before the user interacts with the page. this is blocked by most browsers --- webAO/client.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 014ffb0..51669ed 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -893,6 +893,12 @@ 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 From 85fa666f2d3ee13760ded11e34e89fe349aab75f Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 27 Mar 2020 14:39:51 +0100 Subject: get rid of require --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 51669ed..e68caf0 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -15,7 +15,7 @@ import evidence_arr from "./evidence.js"; import { EventEmitter } from "events"; -const version = require('../package.json').version; +import { version } from '../package.json'; let client; let viewport; -- cgit From 96d39ddd608d770d490c41d64dde9fcb7ccf0274 Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 27 Mar 2020 15:24:58 +0100 Subject: play the classic annoying modcall sound --- webAO/client.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index e68caf0..27be410 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -975,6 +975,9 @@ class Client extends EventEmitter { if (oocLog.scrollTop > oocLog.scrollHeight - 60) { oocLog.scrollTop = oocLog.scrollHeight; } + viewport.sfxaudio.pause(); + viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; + viewport.sfxaudio.play(); } /** -- cgit From 615e4bf8751f940005c5e5d501b6689a19eb6e49 Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 27 Mar 2020 16:26:22 +0100 Subject: remember the modcall sfx and actually use it --- webAO/client.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 27be410..2d21e4c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -12,6 +12,7 @@ import { unescapeChat, escapeChat, encodeChat, decodeChat, safe_tags } from './e import character_arr from "./characters.js"; import background_arr from "./backgrounds.js"; import evidence_arr from "./evidence.js"; +import sfx_arr from "./sounds.js"; import { EventEmitter } from "events"; @@ -382,6 +383,13 @@ class Client extends EventEmitter { evidence_select.add(new Option(evidence)); }); + // Load sfx for modcalls + const modcall_select = document.getElementById("client_modcall"); + sfx_arr.forEach(evidence => { + modcall_select.add(new Option(evidence)); + }); + document.getElementById("client_modcall").value = getCookie("modcall_sfx") || "sfx-gallery.wav"; + // Read cookies and set the UI to its values document.getElementById("OOC_name").value = getCookie("OOC_name") || "web"+parseInt(Math.random()*100+10); @@ -975,9 +983,13 @@ class Client extends EventEmitter { if (oocLog.scrollTop > oocLog.scrollHeight - 60) { oocLog.scrollTop = oocLog.scrollHeight; } + const sfxname = document.getElementById("client_modcall").value; viewport.sfxaudio.pause(); - viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; + const oldvolume = viewport.sfxaudio.volume; + viewport.sfxaudio.volume = 1; + viewport.sfxaudio.src = AO_HOST + "sounds/general/" + sfxname + ".wav"; viewport.sfxaudio.play(); + viewport.sfxaudio.volume = oldvolume; } /** @@ -2048,6 +2060,14 @@ export function reloadTheme() { } window.reloadTheme = reloadTheme; +/** + * Triggered by the modcall sfx dropdown + */ +export function changeModcall() { + setCookie("modcall_sfx", document.getElementById("client_modcall").value); +} +window.changeModcall = changeModcall; + /** * Triggered by the ini button. */ -- cgit From a8297e1ad8a00940509b2853e8d4adb05a30974a Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 1 Apr 2020 12:07:18 +0200 Subject: add streaming music from 1.8 --- webAO/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 2d21e4c..fd92e90 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -589,7 +589,11 @@ class Client extends EventEmitter { const charID = Number(args[2]); const music = viewport.music; music.pause(); - music.src = MUSIC_HOST + track.toLowerCase(); + if(track.startsWith("http")) { + music.src = track; + } else { + music.src = MUSIC_HOST + track.toLowerCase(); + } music.play(); if (charID >= 0) { const musicname = this.chars[charID].name; -- cgit From 36e85b5fb991e69254636804fd0ab8c9ff83690e Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 1 Apr 2020 22:09:02 +0200 Subject: add logic to load them --- webAO/client.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index fd92e90..6a3b192 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -14,6 +14,8 @@ import background_arr from "./backgrounds.js"; import evidence_arr from "./evidence.js"; import sfx_arr from "./sounds.js"; +import chatbox_arr from "./styles/chatbox/chatboxes.js"; + import { EventEmitter } from "events"; import { version } from '../package.json'; @@ -515,9 +517,11 @@ class Client extends EventEmitter { let msg_nameplate = args[3]; let msg_blips = "male"; + let char_chatbox = "default"; try { msg_nameplate = this.chars[args[9]].showname; msg_blips = this.chars[args[9]].gender; + char_chatbox = this.chars[args[9]].chat; } catch (e) { //we already set defaults } @@ -526,6 +530,7 @@ class Client extends EventEmitter { deskmod: safe_tags(args[1]).toLowerCase(), preanim: safe_tags(args[2]).toLowerCase(), // get preanim nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed + chatbox: char_chatbox, name: safe_tags(args[3]), sprite: safe_tags(args[4]).toLowerCase(), content: this.prepChat(args[5]), // Escape HTML tags @@ -652,7 +657,8 @@ class Client extends EventEmitter { name: chargs[0], showname: chargs[0], side: "def", - gender: "male" + gender: "male", + chat: "default" }; cini.options = Object.assign(default_options, cini.options); @@ -667,6 +673,8 @@ class Client extends EventEmitter { showname: safe_tags(cini.options.showname), desc: safe_tags(chargs[1]), gender: safe_tags(cini.options.gender).toLowerCase(), + side: safe_tags(cini.options.side).toLowerCase(), + chat: safe_tags(cini.options.chat).toLowerCase(), evidence: chargs[3], icon: icon, inifile: cini, @@ -1508,6 +1516,7 @@ async changeBackground(position) { const pairSprite = document.getElementById("client_pair_char"); const nameBox = document.getElementById("client_name"); const chatBox = document.getElementById("client_chat"); + const chatbox_theme = document.getElementById("chatbox_theme"); const chatContainerBox = document.getElementById("client_chatcontainer"); const waitingBox = document.getElementById("client_chatwaiting"); const eviBox = document.getElementById("client_evi"); @@ -1622,6 +1631,12 @@ async changeBackground(position) { this.changeBackground(chatmsg.side); + if (chatbox_arr.includes(chatmsg.chatbox)) { + chatbox_theme.href = "styles/chatbox/" + chatmsg.chatbox + ".css"; + } else { + chatbox_theme.href = "styles/chatbox/default.css"; + } + // Flip the character if (this.chatmsg.flip === 1) { charSprite.style.transform = "scaleX(-1)"; -- cgit From 094927ecdad9df116e2cde4b3557c68e4a6ab85d Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 11:31:55 +0200 Subject: don't throw an exception if the chars aren't loaded yet --- webAO/client.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index fd92e90..f7e89a6 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -513,15 +513,22 @@ class Client extends EventEmitter { if (args[4] !== viewport.chatmsg.content) { document.getElementById("client_inner_chat").innerHTML = ""; + const char_id = Number(args[9]) + let msg_nameplate = args[3]; let msg_blips = "male"; + let char_muted = false; + try { - msg_nameplate = this.chars[args[9]].showname; - msg_blips = this.chars[args[9]].gender; + msg_nameplate = this.chars[char_id].showname; + msg_blips = this.chars[char_id].gender; + char_muted = this.chars[char_id].muted; } catch (e) { //we already set defaults } + if (char_muted === false) { + let chatmsg = { deskmod: safe_tags(args[1]).toLowerCase(), preanim: safe_tags(args[2]).toLowerCase(), // get preanim @@ -533,7 +540,7 @@ class Client extends EventEmitter { sound: safe_tags(args[7]).toLowerCase(), blips: safe_tags(msg_blips), type: Number(args[8]), - charid: Number(args[9]), + charid: char_id, snddelay: Number(args[10]), objection: Number(args[11]), evidence: safe_tags(args[12]), @@ -559,12 +566,13 @@ class Client extends EventEmitter { } } + // our own message appeared, reset the buttons if (chatmsg.charid === this.charID) { resetICParams(); } - if (client.chars[chatmsg.charid].muted === false) - viewport.say(chatmsg); // no await + viewport.say(chatmsg); // no await + } } } -- cgit From 9ef7df122e4174bbfbaf391f77ae1f652822a97b Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 11:38:08 +0200 Subject: detect iniedit and load the new char --- webAO/client.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index f7e89a6..65e3798 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -513,7 +513,8 @@ class Client extends EventEmitter { if (args[4] !== viewport.chatmsg.content) { document.getElementById("client_inner_chat").innerHTML = ""; - const char_id = Number(args[9]) + const char_id = Number(args[9]); + const char_name = safe_tags(args[3]); let msg_nameplate = args[3]; let msg_blips = "male"; @@ -523,6 +524,11 @@ class Client extends EventEmitter { msg_nameplate = this.chars[char_id].showname; msg_blips = this.chars[char_id].gender; char_muted = this.chars[char_id].muted; + + if(this.chars[char_id].showname !== char_name) { + // someone is iniediting + this.handleCharacterInfo(char_name,char_id); + } } catch (e) { //we already set defaults } @@ -533,7 +539,7 @@ class Client extends EventEmitter { deskmod: safe_tags(args[1]).toLowerCase(), preanim: safe_tags(args[2]).toLowerCase(), // get preanim nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed - name: safe_tags(args[3]), + name: char_name, sprite: safe_tags(args[4]).toLowerCase(), content: this.prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), -- cgit From 9211eca4316ab10c8064678288228d7541542532 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 11:49:45 +0200 Subject: name not showname and log it when it happens --- webAO/client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 65e3798..2612bfc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -525,12 +525,13 @@ class Client extends EventEmitter { msg_blips = this.chars[char_id].gender; char_muted = this.chars[char_id].muted; - if(this.chars[char_id].showname !== char_name) { - // someone is iniediting + if(this.chars[char_id].name !== char_name) { + console.info(this.chars[char_id].name + " is iniediting to " + char_name); this.handleCharacterInfo(char_name,char_id); } } catch (e) { //we already set defaults + console.error("we're still missing some character data"); } if (char_muted === false) { -- cgit From 8e18260349e57aaed9fd6a4ce77876f0f1423a14 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:04:05 +0200 Subject: it wants an array, set better defaults --- webAO/client.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 2612bfc..84b7b87 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -527,10 +527,13 @@ class Client extends EventEmitter { if(this.chars[char_id].name !== char_name) { console.info(this.chars[char_id].name + " is iniediting to " + char_name); - this.handleCharacterInfo(char_name,char_id); + const chargs = (char_name + "&" + "filthy iniedtier").split("&"); + this.handleCharacterInfo(chargs,char_id); } } catch (e) { - //we already set defaults + msg_nameplate = args[3]; + msg_blips = "male"; + char_muted = false; console.error("we're still missing some character data"); } @@ -654,6 +657,7 @@ class Client extends EventEmitter { } catch (err) { cini = {}; img.classList.add("noini"); + console.warn("character " + chargs[0] + " is missing from webAO") // If it does, give the user a visual indication that the character is unusable } -- cgit From f87f98d1e265bf205579b69c41e5df5f3267a625 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:07:07 +0200 Subject: if we don't know the name display a generic message --- webAO/client.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 84b7b87..d9eb830 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -604,8 +604,9 @@ class Client extends EventEmitter { */ handleMC(args) { const track = args[1]; - const charID = Number(args[2]); + let charID = Number(args[2]); const music = viewport.music; + let musicname; music.pause(); if(track.startsWith("http")) { music.src = track; @@ -613,6 +614,13 @@ class Client extends EventEmitter { music.src = MUSIC_HOST + track.toLowerCase(); } music.play(); + + try { + musicname = this.chars[charID].name; + } catch(e) { + charID = -1; + } + if (charID >= 0) { const musicname = this.chars[charID].name; appendICLog(`${musicname} changed music to ${track}`); @@ -657,7 +665,7 @@ class Client extends EventEmitter { } catch (err) { cini = {}; img.classList.add("noini"); - console.warn("character " + chargs[0] + " is missing from webAO") + console.warn("character " + chargs[0] + " is missing from webAO"); // If it does, give the user a visual indication that the character is unusable } -- cgit From 8a52f77a50055a1d2f80a4e79582d521d8980c5a Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:51:27 +0200 Subject: it's not a const anymore --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d9eb830..e2d7911 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -622,7 +622,7 @@ class Client extends EventEmitter { } if (charID >= 0) { - const musicname = this.chars[charID].name; + musicname = this.chars[charID].name; appendICLog(`${musicname} changed music to ${track}`); } else { appendICLog(`The music was changed to ${track}`); -- cgit From beef46a39b486e025748d2c9d71e95382aa5e1da Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:55:52 +0200 Subject: this. --- webAO/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index e2d7911..483468c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1525,7 +1525,7 @@ async changeBackground(position) { */ async say(chatmsg) { this.chatmsg = chatmsg; - this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(chatmsg.blips.toLowerCase())}.wav`); + 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; @@ -1571,7 +1571,7 @@ async changeBackground(position) { } this.lastChar = this.chatmsg.name; - appendICLog(chatmsg.content, chatmsg.nameplate); + appendICLog(this.chatmsg.content, this.chatmsg.nameplate); // start checking the files try { @@ -1634,14 +1634,14 @@ async changeBackground(position) { chatBox.style.display = "none"; chatContainerBox.style.display = "none"; // If preanim existed then determine the length - gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(chatmsg.name.toLowerCase())}/${encodeURI(chatmsg.preanim)}.gif`); + gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${encodeURI(this.chatmsg.preanim)}.gif`); this.chatmsg.startspeaking = false; break; // case 5: // zoom default: // due to a retarded client bug, we need to strip the sfx from the MS, if the preanim isn't playing - chatmsg.sound = ""; + this.chatmsg.sound = ""; this.chatmsg.startspeaking = true; break; } -- cgit From a7586b1280551b594d7b527b84232582acfd9f45 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 13:05:51 +0200 Subject: add guilty sfx --- webAO/client.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index fd92e90..e6c0c29 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -144,14 +144,16 @@ class Client extends EventEmitter { "duration": 1600, "sfx": AO_HOST + "sounds/general/sfx-testimony2.wav" }, + "guilty": { + "src": AO_HOST + "themes/" + THEME + "/guilty.gif", + "duration": 2870, + "sfx": AO_HOST + "sounds/general/sfx-guilty.wav" + }, "notguilty": { "src": AO_HOST + "themes/" + THEME + "/notguilty.gif", - "duration": 2440 + "duration": 2440, + "sfx": AO_HOST + "sounds/general/sfx-notguilty.wav" }, - "guilty": { - "src": AO_HOST + "themes/" + THEME + "/guilty.gif", - "duration": 2870 - } }; this.selectedEmote = -1; -- cgit From eeb99309a07e45701f1b76676eec202bbf59a9c2 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 22:45:19 +0200 Subject: remove modcall changing because the sfx barely work --- webAO/client.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index e6c0c29..796905d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -385,13 +385,6 @@ class Client extends EventEmitter { evidence_select.add(new Option(evidence)); }); - // Load sfx for modcalls - const modcall_select = document.getElementById("client_modcall"); - sfx_arr.forEach(evidence => { - modcall_select.add(new Option(evidence)); - }); - document.getElementById("client_modcall").value = getCookie("modcall_sfx") || "sfx-gallery.wav"; - // Read cookies and set the UI to its values document.getElementById("OOC_name").value = getCookie("OOC_name") || "web"+parseInt(Math.random()*100+10); @@ -980,7 +973,7 @@ class Client extends EventEmitter { } /** - * Handles a call mod message. + * Handles a modcall * @param {Array} args packet arguments */ handleZZ(args) { @@ -989,11 +982,10 @@ class Client extends EventEmitter { if (oocLog.scrollTop > oocLog.scrollHeight - 60) { oocLog.scrollTop = oocLog.scrollHeight; } - const sfxname = document.getElementById("client_modcall").value; viewport.sfxaudio.pause(); const oldvolume = viewport.sfxaudio.volume; viewport.sfxaudio.volume = 1; - viewport.sfxaudio.src = AO_HOST + "sounds/general/" + sfxname + ".wav"; + viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; viewport.sfxaudio.play(); viewport.sfxaudio.volume = oldvolume; } @@ -2069,10 +2061,10 @@ window.reloadTheme = reloadTheme; /** * Triggered by the modcall sfx dropdown */ -export function changeModcall() { - setCookie("modcall_sfx", document.getElementById("client_modcall").value); +export function modcall_test() { + client.handleZZ("test#test".split("#")); } -window.changeModcall = changeModcall; +window.modcall_test = modcall_test; /** * Triggered by the ini button. -- cgit From 60a9f47f9117c4188f5eae26642b79bc8d8f7c74 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 4 Apr 2020 14:34:28 +0200 Subject: use prepChat for music and more in general --- webAO/client.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 796905d..79759f0 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -6,7 +6,7 @@ import Fingerprint2 from 'fingerprintjs2'; -import { unescapeChat, escapeChat, encodeChat, decodeChat, safe_tags } from './encoding.js'; +import { escapeChat, encodeChat, prepChat, safe_tags } from './encoding.js'; // Load some defaults for the background and evidence dropdowns import character_arr from "./characters.js"; @@ -490,15 +490,6 @@ class Client extends EventEmitter { document.getElementById("client_chartable").innerHTML = ""; } - /** - * XXX: a nasty hack made by gameboyprinter. - * @param {string} msg chat message to prepare for display - */ - prepChat(msg) { - // TODO: make this less awful - return unescapeChat(decodeChat(msg)); - } - /** * Handles an in-character chat message. * @param {*} args packet arguments @@ -523,7 +514,7 @@ class Client extends EventEmitter { nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed name: safe_tags(args[3]), sprite: safe_tags(args[4]).toLowerCase(), - content: this.prepChat(args[5]), // Escape HTML tags + content: prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), sound: safe_tags(args[7]).toLowerCase(), blips: safe_tags(msg_blips), @@ -569,7 +560,7 @@ class Client extends EventEmitter { */ handleCT(args) { const oocLog = document.getElementById("client_ooclog"); - oocLog.innerHTML += `${decodeChat(unescapeChat(args[1]))}: ${decodeChat(unescapeChat(args[2]))}\r\n`; + oocLog.innerHTML += `${prepChat(args[1])}: ${prepChat(args[2])}\r\n`; if (oocLog.scrollTop > oocLog.scrollHeight - 600) { oocLog.scrollTop = oocLog.scrollHeight; } @@ -580,14 +571,14 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ handleMC(args) { - const track = args[1]; + const track = prepChat(args[1]); const charID = Number(args[2]); const music = viewport.music; music.pause(); if(track.startsWith("http")) { music.src = track; } else { - music.src = MUSIC_HOST + track.toLowerCase(); + music.src = MUSIC_HOST + encodeURI(track.toLowerCase()); } music.play(); if (charID >= 0) { @@ -735,8 +726,8 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { const arg = args[i].split("&"); this.evidences[i - 1] = { - name: decodeChat(unescapeChat(arg[0])), - desc: decodeChat(unescapeChat(arg[1])), + name: prepChat(arg[0]), + desc: prepChat(arg[1]), filename: safe_tags(arg[2]), icon: AO_HOST + "evidence/" + encodeURI(arg[2].toLowerCase()) }; @@ -978,7 +969,7 @@ class Client extends EventEmitter { */ handleZZ(args) { const oocLog = document.getElementById("client_ooclog"); - oocLog.innerHTML += `$Alert: ${decodeChat(unescapeChat(args[1]))}\r\n`; + oocLog.innerHTML += `$Alert: ${prepChat(args[1])}\r\n`; if (oocLog.scrollTop > oocLog.scrollHeight - 60) { oocLog.scrollTop = oocLog.scrollHeight; } @@ -1608,7 +1599,7 @@ async changeBackground(position) { // zoom default: // due to a retarded client bug, we need to strip the sfx from the MS, if the preanim isn't playing - chatmsg.sound = ""; + this.chatmsg.sound = ""; this.chatmsg.startspeaking = true; break; } -- cgit 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/client.js') 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/client.js') 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/client.js') 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/client.js') 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/client.js') 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/client.js') 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/client.js') 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 From 34908dcaef5940ae40c95865e4bf7f875d1d0a6f Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 7 Apr 2020 19:12:32 +0200 Subject: make AA the default chatbox --- webAO/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index c97c136..120936d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -672,7 +672,7 @@ class Client extends EventEmitter { showname: chargs[0], side: "def", gender: "male", - chat: "default" + chat: "aa" }; cini.options = Object.assign(default_options, cini.options); @@ -1654,7 +1654,7 @@ async changeBackground(position) { if (chatbox_arr.includes(chatmsg.chatbox)) { chatbox_theme.href = "styles/chatbox/" + chatmsg.chatbox + ".css"; } else { - chatbox_theme.href = "styles/chatbox/default.css"; + chatbox_theme.href = "styles/chatbox/aa.css"; } // Flip the character -- cgit From 40b05d6a8d49aa31379d4f9ad1426d54ce0d8062 Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 8 Apr 2020 13:49:20 +0200 Subject: hide chatcontainer instead of chatbox and namebox + base the font size on the background, not itself --- webAO/client.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 120936d..121b5fc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1555,7 +1555,6 @@ async changeBackground(position) { const chatContainerBox = document.getElementById("client_chatcontainer"); const nameBox = document.getElementById("client_name"); - const chatBox = document.getElementById("client_chat"); const chatBoxInner = document.getElementById("client_inner_chat"); //Clear out the last message @@ -1598,8 +1597,6 @@ async changeBackground(position) { const shout = this.shouts[this.chatmsg.objection]; if (shout) { // Hide message box - nameBox.style.display = "none"; - chatBox.style.display = "none"; chatContainerBox.style.display = "none"; shoutSprite.src = client.resources[shout]["src"]; shoutSprite.style.display = "block"; @@ -1631,8 +1628,6 @@ async changeBackground(position) { case 1: // play preanim // Hide message box - nameBox.style.display = "none"; - chatBox.style.display = "none"; chatContainerBox.style.display = "none"; // If preanim existed then determine the length gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${encodeURI(this.chatmsg.preanim)}.gif`); @@ -1720,8 +1715,7 @@ async changeBackground(position) { this.updater = setTimeout(() => this.tick(), UPDATE_INTERVAL); } - const nameBox = document.getElementById("client_name"); - const chatBox = document.getElementById("client_chat"); + const gamewindow = document.getElementById("client_gamewindow"); const waitingBox = document.getElementById("client_chatwaiting"); const charSprite = document.getElementById("client_char"); const pairSprite = document.getElementById("client_pair_char"); @@ -1735,7 +1729,7 @@ async changeBackground(position) { if (this.chatmsg.flash === 2) { // Shake screen this.playSFX(AO_HOST + "sounds/general/sfx-stab.wav"); - document.getElementById("client_gamewindow").style.animation = "shake 0.2s 1"; + gamewindow.style.animation = "shake 0.2s 1"; } else if (this.chatmsg.flash === 1) { // Flash screen this.playSFX(AO_HOST + "sounds/general/sfx-realization.wav"); @@ -1788,16 +1782,14 @@ async changeBackground(position) { } } - document.getElementById("client_chatcontainer").style.display = "block"; + const chatContainerBox = document.getElementById("client_chatcontainer"); + const gameHeight = document.getElementById("client_background").offsetHeight; + chatContainerBox.style.display = "block"; - nameBox.style.display = "block"; - nameBox.style.fontSize = (nameBox.offsetHeight * 0.7) + "px"; + chatContainerBox.style.fontSize = (gameHeight * 0.05) + "px"; chatBoxInner.className = "text_" + this.colors[this.chatmsg.color]; - chatBox.style.display = "block"; - chatBox.style.fontSize = (chatBox.offsetHeight * 0.25) + "px"; - this.chatmsg.startspeaking = false; if (this.chatmsg.preanimdelay === 0) { -- cgit From 5b114b21f805b3e1246f70402924a98b90181685 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 11 Apr 2020 16:15:55 +0200 Subject: give the name tag an inner p --- webAO/client.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 121b5fc..0e86aaf 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1554,12 +1554,12 @@ async changeBackground(position) { const pairSprite = document.getElementById("client_pair_char"); const chatContainerBox = document.getElementById("client_chatcontainer"); - const nameBox = document.getElementById("client_name"); + const nameBoxInner = document.getElementById("client_inner_name"); const chatBoxInner = document.getElementById("client_inner_chat"); //Clear out the last message chatBoxInner.innerText = this.textnow; - nameBox.innerText = this.chatmsg.nameplate; + nameBoxInner.innerText = this.chatmsg.nameplate; if (this.lastChar !== this.chatmsg.name) { charSprite.style.display = "none"; @@ -1651,6 +1651,7 @@ async changeBackground(position) { } else { chatbox_theme.href = "styles/chatbox/aa.css"; } + resizeChatbox(); // Flip the character if (this.chatmsg.flip === 1) { @@ -1782,12 +1783,11 @@ async changeBackground(position) { } } + resizeChatbox(); + const chatContainerBox = document.getElementById("client_chatcontainer"); - const gameHeight = document.getElementById("client_background").offsetHeight; chatContainerBox.style.display = "block"; - chatContainerBox.style.fontSize = (gameHeight * 0.05) + "px"; - chatBoxInner.className = "text_" + this.colors[this.chatmsg.color]; this.chatmsg.startspeaking = false; @@ -2422,6 +2422,17 @@ export function getIndexFromSelect(select_box, value) { } window.getIndexFromSelect = getIndexFromSelect; +/** + * Set the font size for the chatbox + */ +export function resizeChatbox() { + const chatContainerBox = document.getElementById("client_chatcontainer"); + const gameHeight = document.getElementById("client_background").offsetHeight; + + chatContainerBox.style.fontSize = (gameHeight * 0.05) + "px"; +} +window.resizeChatbox = resizeChatbox; + /** * Update evidence icon. */ -- cgit From 07cbf4bda7f53ac67119f508c7ebf4e2d572728b Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 11 Apr 2020 21:47:02 +0200 Subject: save showname to a cookie --- webAO/client.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index b106b03..90561cc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1915,6 +1915,15 @@ function setCookie(cname, value) { document.cookie = cname + "=" + value; } +/** + * Triggered when the showname is changed + * @param {KeyboardEvent} event + */ +export function onShownameChange(event) { + setCookie("showname",document.getElementById("client_oocinputbox").value); +} +window.onShownameChange = onShownameChange; + /** * Triggered when the Return key is pressed on the out-of-character chat input box. * @param {KeyboardEvent} event -- cgit From 8c7a70d5b38a922bd9a18e7ea922c3e4e5fc6c57 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 11 Apr 2020 21:50:22 +0200 Subject: set the showname from the cookie --- webAO/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 90561cc..1385c08 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -387,6 +387,7 @@ class Client extends EventEmitter { // Read cookies and set the UI to its values document.getElementById("OOC_name").value = getCookie("OOC_name") || "web"+parseInt(Math.random()*100+10); + document.getElementById("ic_chat_name").value = getCookie("showname") || ""; // Read cookies and set the UI to its values var cookietheme = getCookie("theme") || "default"; @@ -1920,7 +1921,7 @@ function setCookie(cname, value) { * @param {KeyboardEvent} event */ export function onShownameChange(event) { - setCookie("showname",document.getElementById("client_oocinputbox").value); + setCookie("showname",document.getElementById("ic_chat_name").value); } window.onShownameChange = onShownameChange; -- cgit From 13df07b8d246c18de314e6b7f61c646214098746 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 11 Apr 2020 21:51:05 +0200 Subject: Revert "set the showname from the cookie" This reverts commit 8c7a70d5b38a922bd9a18e7ea922c3e4e5fc6c57. --- webAO/client.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 1385c08..90561cc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -387,7 +387,6 @@ class Client extends EventEmitter { // Read cookies and set the UI to its values document.getElementById("OOC_name").value = getCookie("OOC_name") || "web"+parseInt(Math.random()*100+10); - document.getElementById("ic_chat_name").value = getCookie("showname") || ""; // Read cookies and set the UI to its values var cookietheme = getCookie("theme") || "default"; @@ -1921,7 +1920,7 @@ function setCookie(cname, value) { * @param {KeyboardEvent} event */ export function onShownameChange(event) { - setCookie("showname",document.getElementById("ic_chat_name").value); + setCookie("showname",document.getElementById("client_oocinputbox").value); } window.onShownameChange = onShownameChange; -- cgit From 9b4e487245f7fb6862dc3bba84f9425b18894cec Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 11 Apr 2020 21:51:06 +0200 Subject: Revert "save showname to a cookie" This reverts commit 07cbf4bda7f53ac67119f508c7ebf4e2d572728b. --- webAO/client.js | 9 --------- 1 file changed, 9 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 90561cc..b106b03 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1915,15 +1915,6 @@ function setCookie(cname, value) { document.cookie = cname + "=" + value; } -/** - * Triggered when the showname is changed - * @param {KeyboardEvent} event - */ -export function onShownameChange(event) { - setCookie("showname",document.getElementById("client_oocinputbox").value); -} -window.onShownameChange = onShownameChange; - /** * Triggered when the Return key is pressed on the out-of-character chat input box. * @param {KeyboardEvent} event -- cgit From c1d9176c5ecd353db6e995d401b6e4f2aa4eb303 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 16:48:42 +0200 Subject: rename the musiclist html --- webAO/client.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index b106b03..dcbc36c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -773,8 +773,8 @@ class Client extends EventEmitter { } resetMusiclist() { - const hmusiclist = document.getElementById("client_musiclist"); - hmusiclist.innerHTML = ""; + const musiclist_element = document.getElementById("client_musiclist"); + musiclist_element.innerHTML = ""; this.areas = []; } @@ -789,13 +789,13 @@ class Client extends EventEmitter { this.resetMusiclist(); } this.sendServer("AM#" + ((args[1] / 10) + 1) + "#%"); - const hmusiclist = document.getElementById("client_musiclist"); + const musiclist_element = document.getElementById("client_musiclist"); for (let i = 2; i < args.length - 1; i++) { if (i % 2 === 0) { document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; const newentry = document.createElement("OPTION"); newentry.text = args[i]; - hmusiclist.options.add(newentry); + musiclist_element.options.add(newentry); } } } @@ -807,7 +807,7 @@ class Client extends EventEmitter { handleSM(args) { document.getElementById("client_loadingtext").innerHTML = "Loading Music "; this.resetMusiclist(); - const hmusiclist = document.getElementById("client_musiclist"); + const musiclist_element = document.getElementById("client_musiclist"); let flagAudio = false; for (let i = 1; i < args.length - 1; i++) { @@ -821,7 +821,7 @@ class Client extends EventEmitter { // After reached the audio put everything in the music list const newentry = document.createElement("OPTION"); newentry.text = args[i]; - hmusiclist.options.add(newentry); + musiclist_element.options.add(newentry); } else { this.areas[i] = { name: safe_tags(args[i]), @@ -853,7 +853,7 @@ class Client extends EventEmitter { if (area_box.lastChild.textContent.startsWith("=")) { const audio_title = document.createElement("OPTION"); audio_title.text = area_box.lastChild.textContent; - hmusiclist.insertBefore(audio_title, hmusiclist.firstChild); + musiclist_element.insertBefore(audio_title, musiclist_element.firstChild); area_box.removeChild(area_box.lastChild); } -- cgit From 3a8a9c7cb30d72e69ec87602cdecfcbc36866ea2 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 16:58:13 +0200 Subject: save the musiclist to an array for later filtering --- webAO/client.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index dcbc36c..bb0f3cf 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -120,6 +120,7 @@ class Client extends EventEmitter { this.emotes = []; this.evidences = []; this.areas = []; + this.musics = []; this.resources = { "holdit": { @@ -161,8 +162,6 @@ class Client extends EventEmitter { this.checkUpdater = null; - // Only used for RMC/'music' packets, not EM/SM/MC packets. - this.musicList = Object(); /** * Assign handlers for all commands * If you implement a new command, you need to add it here @@ -485,8 +484,7 @@ class Client extends EventEmitter { clearInterval(this.checkUpdater); // the connection got rekt, get rid of the old musiclist - document.getElementById("areas").innerHTML = ""; - document.getElementById("client_musiclist").innerHTML = ""; + this.resetMusiclist(); document.getElementById("client_chartable").innerHTML = ""; } @@ -773,9 +771,10 @@ class Client extends EventEmitter { } resetMusiclist() { - const musiclist_element = document.getElementById("client_musiclist"); - musiclist_element.innerHTML = ""; + this.musics = []; this.areas = []; + document.getElementById("client_musiclist").innerHTML = ""; + document.getElementById("areas").innerHTML = ""; } /** @@ -796,6 +795,7 @@ class Client extends EventEmitter { const newentry = document.createElement("OPTION"); newentry.text = args[i]; musiclist_element.options.add(newentry); + this.musics.push(args[i]); } } } @@ -822,6 +822,7 @@ class Client extends EventEmitter { const newentry = document.createElement("OPTION"); newentry.text = args[i]; musiclist_element.options.add(newentry); + this.musics.push(args[i]); } else { this.areas[i] = { name: safe_tags(args[i]), -- cgit From 0b66f20070e96c5d47a3a048c8355b6a3c930f5b Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:07:45 +0200 Subject: move music handler into own function --- webAO/client.js | 84 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 40 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index bb0f3cf..b28498b 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -777,6 +777,47 @@ class Client extends EventEmitter { document.getElementById("areas").innerHTML = ""; } + handleMusicInfo(trackindex,trackname) { + const musiclist_element = document.getElementById("client_musiclist"); + let flagAudio = false; + + if (/\.(?:wav|mp3|mp4|ogg|opus)$/i.test(trackname) && !flagAudio) { + flagAudio = true; + } + + if (flagAudio) { + // After reached the audio put everything in the music list + const newentry = document.createElement("OPTION"); + newentry.text = trackname; + musiclist_element.options.add(newentry); + this.musics.push(trackname); + } else { + const thisarea = { + name: trackname, + players: 0, + status: "IDLE", + cm: "", + locked: "FREE" + }; + + this.areas.push(thisarea); + + // Create area button + let newarea = document.createElement("SPAN"); + newarea.classList = "area-button area-default"; + newarea.id = "area" + trackindex; + newarea.innerText = thisarea.name; + newarea.title = "Players:
" + + "Status:
" + + "CM: "; + newarea.onclick = function () { + area_click(this); + }; + + document.getElementById("areas").appendChild(newarea); + } + } + /** * Handles incoming music information, containing multiple entries * per packet. @@ -788,14 +829,11 @@ class Client extends EventEmitter { this.resetMusiclist(); } this.sendServer("AM#" + ((args[1] / 10) + 1) + "#%"); - const musiclist_element = document.getElementById("client_musiclist"); + for (let i = 2; i < args.length - 1; i++) { if (i % 2 === 0) { document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - const newentry = document.createElement("OPTION"); - newentry.text = args[i]; - musiclist_element.options.add(newentry); - this.musics.push(args[i]); + this.handleMusicInfo(i,safe_tags(args[i])); } } } @@ -807,45 +845,11 @@ class Client extends EventEmitter { handleSM(args) { document.getElementById("client_loadingtext").innerHTML = "Loading Music "; this.resetMusiclist(); - const musiclist_element = document.getElementById("client_musiclist"); - let flagAudio = false; for (let i = 1; i < args.length - 1; i++) { // Check when found the song for the first time document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - if (/\.(?:wav|mp3|mp4|ogg|opus)$/i.test(args[i]) && !flagAudio) { - flagAudio = true; - } - - if (flagAudio) { - // After reached the audio put everything in the music list - const newentry = document.createElement("OPTION"); - newentry.text = args[i]; - musiclist_element.options.add(newentry); - this.musics.push(args[i]); - } else { - this.areas[i] = { - name: safe_tags(args[i]), - players: 0, - status: "IDLE", - cm: "", - locked: "FREE" - }; - - // Create area button - let newarea = document.createElement("SPAN"); - newarea.classList = "area-button area-default"; - newarea.id = "area" + i; - newarea.innerText = this.areas[i].name; - newarea.title = "Players:
" + - "Status:
" + - "CM: "; - newarea.onclick = function () { - area_click(this); - }; - - document.getElementById("areas").appendChild(newarea); - } + this.handleMusicInfo(i,safe_tags(args[i])); } // We need to check if the last area that we got was actually a category -- cgit From 6e5016945bbb8af7c30c03f56844ec7049903e34 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:14:19 +0200 Subject: add filter to the search boxes onchange --- webAO/client.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index b28498b..7e29c42 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1984,6 +1984,18 @@ function resetICParams() { } } +/** + * Triggered when the music search bar is changed + * @param {MouseEvent} event + */ +export function musiclist_filter(_event) { + const musiclist_element = document.getElementById("client_musiclist"); + musiclist_element.innerHTML = ""; + + +} +window.musiclist_filter = musiclist_filter; + /** * Triggered when an item on the music list is clicked. * @param {MouseEvent} event -- cgit From 51f46e2fb1a68edd584a27b30937013301b94d23 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:21:43 +0200 Subject: fix area and category header detection --- webAO/client.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 7e29c42..14fd35c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -778,10 +778,9 @@ class Client extends EventEmitter { } handleMusicInfo(trackindex,trackname) { - const musiclist_element = document.getElementById("client_musiclist"); let flagAudio = false; - if (/\.(?:wav|mp3|mp4|ogg|opus)$/i.test(trackname) && !flagAudio) { + if (/\.(?:wav|mp3|mp4|ogg|opus)$/i.test(trackname) || trackname.startsWith("=")) { flagAudio = true; } @@ -789,7 +788,7 @@ class Client extends EventEmitter { // After reached the audio put everything in the music list const newentry = document.createElement("OPTION"); newentry.text = trackname; - musiclist_element.options.add(newentry); + document.getElementById("client_musiclist").options.add(newentry); this.musics.push(trackname); } else { const thisarea = { @@ -828,7 +827,6 @@ class Client extends EventEmitter { if(args[1] === "0") { this.resetMusiclist(); } - this.sendServer("AM#" + ((args[1] / 10) + 1) + "#%"); for (let i = 2; i < args.length - 1; i++) { if (i % 2 === 0) { @@ -836,6 +834,9 @@ class Client extends EventEmitter { this.handleMusicInfo(i,safe_tags(args[i])); } } + + // get the next batch of tracks + this.sendServer("AM#" + ((args[1] / 10) + 1) + "#%"); } /** @@ -852,16 +853,6 @@ class Client extends EventEmitter { this.handleMusicInfo(i,safe_tags(args[i])); } - // We need to check if the last area that we got was actually a category - // header for music. If it was, then move it over to the music list. - const area_box = document.getElementById("areas"); - if (area_box.lastChild.textContent.startsWith("=")) { - const audio_title = document.createElement("OPTION"); - audio_title.text = area_box.lastChild.textContent; - musiclist_element.insertBefore(audio_title, musiclist_element.firstChild); - area_box.removeChild(area_box.lastChild); - } - // Music done, carry on this.sendServer("RD#%"); } -- cgit From b126e7798d83a6617ea055e0f37d0167a0f65d06 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:27:46 +0200 Subject: messed up the order --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 14fd35c..5156ea3 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -850,7 +850,7 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { // Check when found the song for the first time document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - this.handleMusicInfo(i,safe_tags(args[i])); + this.handleMusicInfo(i-1,safe_tags(args[i])); } // Music done, carry on -- cgit From 046feadf97a2faf6f62809df17c49cd29c112f93 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:45:57 +0200 Subject: actually filter the list --- webAO/client.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 5156ea3..d2aedc1 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1981,9 +1981,17 @@ function resetICParams() { */ export function musiclist_filter(_event) { const musiclist_element = document.getElementById("client_musiclist"); + const searchname = document.getElementById("client_musicsearch").value; + musiclist_element.innerHTML = ""; - + for (const trackname of client.musics){ + if (trackname.toLowerCase().indexOf(searchname.toLowerCase()) !== -1) { + const newentry = document.createElement("OPTION"); + newentry.text = trackname; + musiclist_element.options.add(newentry); + } + } } window.musiclist_filter = musiclist_filter; -- cgit From 63d9da0ce725392108bd65e3d790a067285fb9e4 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:48:35 +0200 Subject: this broke songs with an & in them --- webAO/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d2aedc1..49203de 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -831,7 +831,7 @@ class Client extends EventEmitter { for (let i = 2; i < args.length - 1; i++) { if (i % 2 === 0) { document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - this.handleMusicInfo(i,safe_tags(args[i])); + this.handleMusicInfo(i,args[i]); } } @@ -850,7 +850,7 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { // Check when found the song for the first time document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - this.handleMusicInfo(i-1,safe_tags(args[i])); + this.handleMusicInfo(i-1,args[i]); } // Music done, carry on -- cgit From 9ccc3be8e021aeb6ddcd6b50b758bb8bec7060ef Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 17:54:45 +0200 Subject: Revert "this broke songs with an & in them" This reverts commit 63d9da0ce725392108bd65e3d790a067285fb9e4. --- webAO/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 49203de..d2aedc1 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -831,7 +831,7 @@ class Client extends EventEmitter { for (let i = 2; i < args.length - 1; i++) { if (i % 2 === 0) { document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - this.handleMusicInfo(i,args[i]); + this.handleMusicInfo(i,safe_tags(args[i])); } } @@ -850,7 +850,7 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { // Check when found the song for the first time document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - this.handleMusicInfo(i-1,args[i]); + this.handleMusicInfo(i-1,safe_tags(args[i])); } // Music done, carry on -- cgit From bd3194ccde09d0353e0a2d1ccbcc68f370c70926 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 18:02:44 +0200 Subject: fix area index with old loading --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d2aedc1..9390634 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -831,7 +831,7 @@ class Client extends EventEmitter { for (let i = 2; i < args.length - 1; i++) { if (i % 2 === 0) { document.getElementById("client_loadingtext").innerHTML = `Loading Music ${i}/${this.music_list_length}`; - this.handleMusicInfo(i,safe_tags(args[i])); + this.handleMusicInfo(args[i-1],safe_tags(args[i])); } } -- cgit From 97caca41dfa78158fb64a0229f173d5d6f45a409 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 18:20:56 +0200 Subject: fix off-by-one in ARUP code --- webAO/client.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9390634..9be4529 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1029,23 +1029,23 @@ class Client extends EventEmitter { */ handleARUP(args) { args = args.slice(1); - for (let i = 1; i < args.length - 1; i++) { + for (let i = 0; i < args.length - 2; i++) { if (this.areas[i]) { // the server sends us ARUP before we even get the area list const thisarea = document.getElementById("area" + i); switch (Number(args[0])) { case 0: // playercount - this.areas[i].players = Number(args[i]); + this.areas[i].players = Number(args[i+1]); thisarea.innerText = `${this.areas[i].name} (${this.areas[i].players})`; break; case 1: // status - this.areas[i].status = safe_tags(args[i]); + this.areas[i].status = safe_tags(args[i+1]); thisarea.classList = "area-button area-" + this.areas[i].status.toLowerCase(); break; case 2: - this.areas[i].cm = safe_tags(args[i]); + this.areas[i].cm = safe_tags(args[i+1]); break; case 3: - this.areas[i].locked = safe_tags(args[i]); + this.areas[i].locked = safe_tags(args[i+1]); break; } -- cgit From 919ad6b770ea205c110d0e385c219a8079280f91 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Apr 2020 19:13:10 +0200 Subject: filter charlist --- webAO/client.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9be4529..b5c8c2f 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1124,9 +1124,9 @@ class Client extends EventEmitter { let img = document.getElementById(`demo_${i}`); if (args[i + 1] === "-1") - img.style = "opacity: 0.25"; + img.style.opacity = 0.25; else if (args[i + 1] === "0") - img.style = ""; + img.style.opacity = 1; } } @@ -2277,6 +2277,24 @@ function appendICLog(msg, name = "", time = new Date()) { lastICMessageTime = new Date(); } +/** + * Triggered when the music search bar is changed + * @param {MouseEvent} event + */ +export function chartable_filter(_event) { + const searchname = document.getElementById("client_charactersearch").value; + + client.chars.forEach(function (character, charid) { + const demothing = document.getElementById(`demo_${charid}`); + if (character.name.toLowerCase().indexOf(searchname.toLowerCase()) === -1) { + demothing.style.display = "none"; + } else { + demothing.style.display = "inline-block"; + } + }); +} +window.chartable_filter = chartable_filter; + /** * Requests to play as a character. * @param {number} ccharacter the character ID; if this is a large number, -- cgit From cc95e7d8393e6862b571e6c83c713a3284a6f895 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 18 Apr 2020 15:32:07 +0200 Subject: let the users pin the box to 1 style if they want --- webAO/client.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index c44ed74..dace52b 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1641,12 +1641,7 @@ async changeBackground(position) { this.changeBackground(chatmsg.side); - const chatbox_theme = document.getElementById("chatbox_theme"); - if (chatbox_arr.includes(chatmsg.chatbox)) { - chatbox_theme.href = "styles/chatbox/" + chatmsg.chatbox + ".css"; - } else { - chatbox_theme.href = "styles/chatbox/aa.css"; - } + setChatbox(chatmsg.chatbox); resizeChatbox(); // Flip the character @@ -2438,6 +2433,20 @@ export function getIndexFromSelect(select_box, value) { } window.getIndexFromSelect = getIndexFromSelect; +export function setChatbox(style) { + const chatbox_theme = document.getElementById("chatbox_theme"); + const selected_theme = document.getElementById("client_chatboxselect").value; + if(selected_theme === "dynamic") { + if (chatbox_arr.includes(style)) { + chatbox_theme.href = "styles/chatbox/" + style + ".css"; + } else { + chatbox_theme.href = "styles/chatbox/aa.css"; + } + } else { + chatbox_theme.href = "styles/chatbox/" + selected_theme + ".css"; + } +} + /** * Set the font size for the chatbox */ -- cgit From 7807d85ab18edadba33de36b324353f51cf51036 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 18 Apr 2020 16:04:27 +0200 Subject: load chatbox from cookie --- webAO/client.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index dace52b..9d35c4d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -395,6 +395,11 @@ class Client extends EventEmitter { document.querySelector('#client_themeselect [value="' + cookietheme + '"]').selected = true; reloadTheme(); + var cookiechatbox = getCookie("chatbox") || "dynamic"; + + document.querySelector('#client_chatboxselect [value="' + cookiechatbox + '"]').selected = true; + setChatbox(cookiechatbox); + document.getElementById("client_musicaudio").volume = getCookie("musicVolume") || 1; changeMusicVolume(); document.getElementById("client_svolume").value = getCookie("sfxVolume") || 1; @@ -2436,6 +2441,7 @@ window.getIndexFromSelect = getIndexFromSelect; export function setChatbox(style) { const chatbox_theme = document.getElementById("chatbox_theme"); const selected_theme = document.getElementById("client_chatboxselect").value; + setCookie("chatbox", selected_theme); if(selected_theme === "dynamic") { if (chatbox_arr.includes(style)) { chatbox_theme.href = "styles/chatbox/" + style + ".css"; -- cgit From 786949e40f004b98b8006ab43f34da9f3bf98f54 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 18 Apr 2020 16:08:21 +0200 Subject: export the function --- webAO/client.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9d35c4d..9392f2c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2438,6 +2438,9 @@ export function getIndexFromSelect(select_box, value) { } window.getIndexFromSelect = getIndexFromSelect; +/** + * Set the style of the chatbox + */ export function setChatbox(style) { const chatbox_theme = document.getElementById("chatbox_theme"); const selected_theme = document.getElementById("client_chatboxselect").value; @@ -2452,6 +2455,7 @@ export function setChatbox(style) { chatbox_theme.href = "styles/chatbox/" + selected_theme + ".css"; } } +window.setChatbox = setChatbox; /** * Set the font size for the chatbox -- cgit From f7604b2e750bab3d8ccdd8b241c0cba05a6ac490 Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 19 Apr 2020 18:31:54 +0200 Subject: add text centering --- webAO/client.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 54458e5..1913d71 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1667,6 +1667,14 @@ async changeBackground(position) { this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(this.chatmsg.blips.toLowerCase())}.wav`); + // process markup + if(this.chatmsg.content.startsWith("~~")) { + chatBoxInner.style.textAlign = "center"; + this.chatmsg.content = this.chatmsg.content.substring(2, this.chatmsg.content.length); + } else { + chatBoxInner.style.textAlign = "initial"; + } + this.tick(); } -- cgit From 9ba6090591afa56ce0ee72469c5874b7b8303e9a Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 25 Apr 2020 18:55:02 +0200 Subject: don't use the emoji for the spinner --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 1913d71..cce9b01 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1821,7 +1821,7 @@ async changeBackground(position) { if (this.textnow === this.chatmsg.content) { charSprite.src = this.silentSprite; charSprite.style.display = ""; - waitingBox.innerHTML = "▶"; + waitingBox.innerHTML = "►"; this._animating = false; clearTimeout(this.updater); } -- cgit From 97ff757a7647cfdbcd5ae094e041eabbda3bf70d Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 25 Apr 2020 20:45:04 +0200 Subject: use opacity instead of display to hide things --- webAO/client.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index cce9b01..15d4b3d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1370,15 +1370,15 @@ async changeBackground(position) { if (viewport.chatmsg.type === 5) { document.getElementById("client_court").src = `${AO_HOST}themes/default/${encodeURI(speedLines)}`; - document.getElementById("client_bench").style.display = "none"; + document.getElementById("client_bench").style.opacity = 0; } else { document.getElementById("client_court").src = bgfolder + bg; if (desk) { const deskFilename = await fileExists(bgfolder + desk.ao2) ? desk.ao2 : desk.ao1; document.getElementById("client_bench").src = bgfolder + deskFilename; - document.getElementById("client_bench").style.display = "block"; + document.getElementById("client_bench").style.opacity = 1; } else { - document.getElementById("client_bench").style.display = "none"; + document.getElementById("client_bench").style.opacity = 0; } } } @@ -1404,7 +1404,7 @@ async changeBackground(position) { const testimonyOverlay = document.getElementById("client_testimony"); testimonyOverlay.src = client.resources[testimony].src; - testimonyOverlay.style.display = ""; + testimonyOverlay.style.opacity = 1; this.testimonyTimer = 0; this.testimonyUpdater = setTimeout(() => this.updateTestimony(), UPDATE_INTERVAL); @@ -1511,7 +1511,7 @@ async changeBackground(position) { disposeTestimony() { client.testimonyID = 0; this.testimonyTimer = 0; - document.getElementById("client_testimony").style.display = "none"; + document.getElementById("client_testimony").style.opacity = 0; clearTimeout(this.testimonyUpdater); } @@ -1563,9 +1563,9 @@ async changeBackground(position) { nameBoxInner.innerText = this.chatmsg.nameplate; if (this.lastChar !== this.chatmsg.name) { - charSprite.style.display = "none"; + charSprite.style.opacity = 0; charSprite.src = transparentPNG; - pairSprite.style.display = "none"; + pairSprite.style.opacity = 0; pairSprite.src = transparentPNG; } this.lastChar = this.chatmsg.name; @@ -1598,9 +1598,9 @@ async changeBackground(position) { const shout = this.shouts[this.chatmsg.objection]; if (shout) { // Hide message box - chatContainerBox.style.display = "none"; + chatContainerBox.style.opacity = 0; shoutSprite.src = client.resources[shout]["src"]; - shoutSprite.style.display = "block"; + shoutSprite.style.opacity = 1; let shoutUrl; @@ -1629,7 +1629,7 @@ async changeBackground(position) { case 1: // play preanim // Hide message box - chatContainerBox.style.display = "none"; + chatContainerBox.style.opacity = 0; // If preanim existed then determine the length gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${encodeURI(this.chatmsg.preanim)}.gif`); this.chatmsg.startspeaking = false; @@ -1743,11 +1743,11 @@ async changeBackground(position) { // Pre-animation stuff if (this.chatmsg.preanimdelay > 0) { - shoutSprite.style.display = "none"; + shoutSprite.style.opacity = 0; const charName = this.chatmsg.name.toLowerCase(); const preanim = this.chatmsg.preanim.toLowerCase(); charSprite.src = `${AO_HOST}characters/${encodeURI(charName)}/${encodeURI(preanim)}.gif`; - charSprite.style.display = ""; + charSprite.style.opacity = 1; } if (extrafeatures.includes("cccc_ic_support")) { @@ -1757,9 +1757,9 @@ async changeBackground(position) { pairSprite.style.left = this.chatmsg.other_offset + "%"; charSprite.style.left = this.chatmsg.self_offset + "%"; pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; - pairSprite.style.display = ""; + pairSprite.style.opacity = 1; } else { - pairSprite.style.display = "none"; + pairSprite.style.opacity = 0; charSprite.style.left = 0; } @@ -1790,14 +1790,14 @@ async changeBackground(position) { resizeChatbox(); const chatContainerBox = document.getElementById("client_chatcontainer"); - chatContainerBox.style.display = "block"; + chatContainerBox.style.opacity = 1; chatBoxInner.className = "text_" + this.colors[this.chatmsg.color]; this.chatmsg.startspeaking = false; if (this.chatmsg.preanimdelay === 0) { - shoutSprite.style.display = "none"; + shoutSprite.style.opacity = 0; this.changeBackground(this.chatmsg.side); } @@ -1808,19 +1808,19 @@ async changeBackground(position) { pairSprite.style.left = this.chatmsg.other_offset + "%"; charSprite.style.left = this.chatmsg.self_offset + "%"; pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; - pairSprite.style.display = ""; + pairSprite.style.opacity = 1; } else { - pairSprite.style.display = "none"; + pairSprite.style.opacity = 0; charSprite.style.left = 0; } } charSprite.src = this.speakingSprite; - charSprite.style.display = ""; + charSprite.style.opacity = 1; if (this.textnow === this.chatmsg.content) { charSprite.src = this.silentSprite; - charSprite.style.display = ""; + charSprite.style.opacity = 1; waitingBox.innerHTML = "►"; this._animating = false; clearTimeout(this.updater); @@ -1840,7 +1840,7 @@ async changeBackground(position) { this.textTimer = 0; this._animating = false; charSprite.src = this.silentSprite; - charSprite.style.display = ""; + charSprite.style.opacity = 1; waitingBox.innerHTML = "▶"; clearTimeout(this.updater); } -- cgit From 1d9bf732f0d186385e63cba2098751c24c62d514 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 25 Apr 2020 21:11:05 +0200 Subject: waiting spinner: forgot one occurence --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 15d4b3d..a820911 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1841,7 +1841,7 @@ async changeBackground(position) { this._animating = false; charSprite.src = this.silentSprite; charSprite.style.opacity = 1; - waitingBox.innerHTML = "▶"; + waitingBox.innerHTML = "►"; clearTimeout(this.updater); } } -- cgit From 25f671e4a8e815524940c48d72fae0faecdf1e32 Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 26 Apr 2020 16:25:38 +0200 Subject: set the bench class name --- webAO/client.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index a820911..889c3b7 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1323,6 +1323,9 @@ class Viewport { async changeBackground(position) { const bgfolder = viewport.bgFolder; + const bench = document.getElementById("client_bench"); + const court = document.getElementById("client_court"); + const positions = { def: { bg: "defenseempty.png", @@ -1368,17 +1371,19 @@ async changeBackground(position) { const { bg, desk, speedLines } = positions[position]; + bench.className = position + "_bench"; + if (viewport.chatmsg.type === 5) { - document.getElementById("client_court").src = `${AO_HOST}themes/default/${encodeURI(speedLines)}`; - document.getElementById("client_bench").style.opacity = 0; + court.src = `${AO_HOST}themes/default/${encodeURI(speedLines)}`; + bench.style.opacity = 0; } else { - document.getElementById("client_court").src = bgfolder + bg; + court.src = bgfolder + bg; if (desk) { const deskFilename = await fileExists(bgfolder + desk.ao2) ? desk.ao2 : desk.ao1; - document.getElementById("client_bench").src = bgfolder + deskFilename; - document.getElementById("client_bench").style.opacity = 1; + bench.src = bgfolder + deskFilename; + bench.style.opacity = 1; } else { - document.getElementById("client_bench").style.opacity = 0; + bench.style.opacity = 0; } } } -- cgit From 4373f2f70eb3e3488f1961d2d7d683757cca951c Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 26 Apr 2020 16:44:53 +0200 Subject: do the same for the bg --- webAO/client.js | 1 + 1 file changed, 1 insertion(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 889c3b7..3d9b6b5 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1372,6 +1372,7 @@ async changeBackground(position) { const { bg, desk, speedLines } = positions[position]; bench.className = position + "_bench"; + court.className = position + "_court"; if (viewport.chatmsg.type === 5) { court.src = `${AO_HOST}themes/default/${encodeURI(speedLines)}`; -- cgit From dcb35d7ee1ebc04ef58e686b795935e3b3e9c2bb Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 26 Apr 2020 17:46:22 +0200 Subject: use the png and css animation for objections --- webAO/client.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 3d9b6b5..e3fb830 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -126,15 +126,15 @@ class Client extends EventEmitter { this.resources = { "holdit": { - "src": AO_HOST + "themes/" + THEME + "/holdit.gif", + "src": AO_HOST + "misc/default/holdit_bubble.png", "duration": 720 }, "objection": { - "src": AO_HOST + "themes/" + THEME + "/objection.gif", + "src": AO_HOST + "misc/default/objection_bubble.png", "duration": 720 }, "takethat": { - "src": AO_HOST + "themes/" + THEME + "/takethat.gif", + "src": AO_HOST + "misc/default/takethat_bubble.png", "duration": 840 }, "witnesstestimony": { @@ -1607,6 +1607,7 @@ async changeBackground(position) { chatContainerBox.style.opacity = 0; shoutSprite.src = client.resources[shout]["src"]; shoutSprite.style.opacity = 1; + shoutSprite.style.animation = "bubble 700ms steps(10, jump-both)"; let shoutUrl; @@ -1750,6 +1751,7 @@ async changeBackground(position) { // Pre-animation stuff if (this.chatmsg.preanimdelay > 0) { shoutSprite.style.opacity = 0; + shoutSprite.style.animation = ""; const charName = this.chatmsg.name.toLowerCase(); const preanim = this.chatmsg.preanim.toLowerCase(); charSprite.src = `${AO_HOST}characters/${encodeURI(charName)}/${encodeURI(preanim)}.gif`; @@ -1804,6 +1806,7 @@ async changeBackground(position) { if (this.chatmsg.preanimdelay === 0) { shoutSprite.style.opacity = 0; + shoutSprite.style.animation = ""; this.changeBackground(this.chatmsg.side); } -- cgit From 3ff463832f4ffb9accaf4da6629ff48599557a54 Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 26 Apr 2020 19:02:08 +0200 Subject: use class instead of id for log name --- webAO/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index e3fb830..6f99725 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2274,7 +2274,7 @@ window.ReconnectButton = ReconnectButton; function appendICLog(msg, name = "", time = new Date()) { const entry = document.createElement("p"); const nameField = document.createElement("span"); - nameField.id = "iclog_name"; + nameField.className = "iclog_name"; nameField.appendChild(document.createTextNode(name)); entry.appendChild(nameField); entry.appendChild(document.createTextNode(msg)); @@ -2282,7 +2282,7 @@ function appendICLog(msg, name = "", time = new Date()) { // Only put a timestamp if the minute has changed. if (lastICMessageTime.getMinutes() !== time.getMinutes()) { const timeStamp = document.createElement("span"); - timeStamp.id = "iclog_time"; + timeStamp.className = "iclog_time"; timeStamp.innerText = time.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" -- cgit From d1f09330c87415c765c4f6ff1013fd7cf6ad2eef Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 26 Apr 2020 19:26:41 +0200 Subject: add a span for the ic log text --- webAO/client.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 6f99725..58a8c61 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2274,10 +2274,15 @@ window.ReconnectButton = ReconnectButton; function appendICLog(msg, name = "", time = new Date()) { const entry = document.createElement("p"); const nameField = document.createElement("span"); + const textField = document.createElement("span"); nameField.className = "iclog_name"; nameField.appendChild(document.createTextNode(name)); + + textField.className = "iclog_text"; + textField.appendChild(document.createTextNode(msg)); + entry.appendChild(nameField); - entry.appendChild(document.createTextNode(msg)); + entry.appendChild(textField); // Only put a timestamp if the minute has changed. if (lastICMessageTime.getMinutes() !== time.getMinutes()) { -- cgit From 77784e5f09e0c05c5034693d6973a4bfaef0f072 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 28 Apr 2020 22:02:13 +0200 Subject: handle servers not supporting modcall reason --- webAO/client.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 58a8c61..0b06670 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -317,7 +317,11 @@ class Client extends EventEmitter { * @param {string} message to mod */ sendZZ(msg) { - this.sendServer(`ZZ#${msg}#%`); + if (extrafeatures.includes("modcall_reason")) { + this.sendServer(`ZZ#${msg}#%`); + } else { + this.sendServer(`ZZ#%`); + } } /** @@ -2590,7 +2594,10 @@ window.randomCharacterOOC = randomCharacterOOC; * Call mod. */ export function callMod() { - let modcall = prompt("Please enter the reason for the modcall", ""); + let modcall; + if (extrafeatures.includes("modcall_reason")) { + modcall = prompt("Please enter the reason for the modcall", ""); + } if (modcall == null || modcall === "") { // cancel } else { -- cgit From e6da4143cbbda967c9bd57059f0e06e79872d34f Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 28 Apr 2020 22:13:17 +0200 Subject: add dummy 2.7 stuff --- webAO/client.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 0b06670..d35aa5c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -262,12 +262,26 @@ class Client extends EventEmitter { */ sendIC(deskmod, preanim, name, emote, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { let extra_cccc = ``; + let extra_27 = ``; + if (extrafeatures.includes("cccc_ic_support")) { extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; + + if (extrafeatures.includes("looping_sfx")) { + const looping_sfx = 0; + const screenshake = 0; + const frame_screenshake = 0; + const frame_realization = 0; + const frame_sfx = 0; + + extra_27 = `${looping_sfx}#${screenshake}#${frame_screenshake}#${frame_realization}#${frame_sfx}#`; + // looping_sfx, screenshake, frame_screenshake, frame_realization, frame_sfx = args + } } + const serverMessage = `MS#${deskmod}#${preanim}#${name}#${emote}` + `#${escapeChat(encodeChat(message))}#${side}#${sfx_name}#${emote_modifier}` + - `#${this.charID}#${sfx_delay}#${objection_modifier}#${evidence}#${flip}#${realization}#${text_color}#${extra_cccc}%`; + `#${this.charID}#${sfx_delay}#${objection_modifier}#${evidence}#${flip}#${realization}#${text_color}#${extra_cccc}${extra_27}%`; console.log(serverMessage); -- cgit From d29d063edb47b075b4618fd6591ded5297e76958 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 28 Apr 2020 22:23:38 +0200 Subject: the frame indicators are treated as strings in tsuserver --- webAO/client.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d35aa5c..932cba6 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -263,16 +263,16 @@ class Client extends EventEmitter { sendIC(deskmod, preanim, name, emote, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { let extra_cccc = ``; let extra_27 = ``; - + if (extrafeatures.includes("cccc_ic_support")) { extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; if (extrafeatures.includes("looping_sfx")) { const looping_sfx = 0; const screenshake = 0; - const frame_screenshake = 0; - const frame_realization = 0; - const frame_sfx = 0; + const frame_screenshake = ""; + const frame_realization = ""; + const frame_sfx = ""; extra_27 = `${looping_sfx}#${screenshake}#${frame_screenshake}#${frame_realization}#${frame_sfx}#`; // looping_sfx, screenshake, frame_screenshake, frame_realization, frame_sfx = args @@ -1215,6 +1215,9 @@ class Client extends EventEmitter { zoom: Number(emoteinfo[3]) || 0, sfx: esfx.toLowerCase(), sfxdelay: esfxd, + frame_screenshake: "", + frame_realization: "", + frame_sfx: "", button_off: AO_HOST + `characters/${encodeURI(me.name.toLowerCase())}/emotions/button${i}_off.png`, button_on: AO_HOST + `characters/${encodeURI(me.name.toLowerCase())}/emotions/button${i}_on.png` }; -- cgit From 5598f2945b98e88f480fddbd9cbda544dbb461c5 Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 1 May 2020 20:54:23 +0200 Subject: parse 2.7 options --- webAO/client.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 932cba6..4f170b2 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -572,7 +572,7 @@ class Client extends EventEmitter { }; if (extrafeatures.includes("cccc_ic_support")) { - const extra_options = { + const extra_cccc = { showname: safe_tags(args[16]), other_charid: Number(args[17]), other_name: safe_tags(args[18]), @@ -582,7 +582,19 @@ class Client extends EventEmitter { other_flip: Number(args[22]), noninterrupting_preanim: Number(args[23]) }; - chatmsg = Object.assign(extra_options, chatmsg); + chatmsg = Object.assign(extra_cccc, chatmsg); + + if (extrafeatures.includes("looping_sfx")) { + const extra_27 = { + looping_sfx: Number(args[24]), + screenshake: Number(args[25]), + frame_screenshake: safe_tags(args[26]), + frame_realization: safe_tags(args[27]), + frame_sfx: safe_tags(args[28]) + }; + chatmsg = Object.assign(extra_27, chatmsg); + } + if (chatmsg.showname && document.getElementById("showname").checked) { chatmsg.nameplate = chatmsg.showname; } -- cgit From aa3f60fcffa7242fe09e2a539f931775cc7507ab Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 1 May 2020 21:41:44 +0200 Subject: support 2.7 --- webAO/client.js | 159 +++++++++++++++++++++++++++----------------------------- 1 file changed, 76 insertions(+), 83 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 4f170b2..49955c0 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -106,7 +106,6 @@ class Client extends EventEmitter { // Preset some of the variables - this.flip = false; this.presentable = false; this.hp = [0, 0]; @@ -260,7 +259,7 @@ class Client extends EventEmitter { * @param {number} self_offset offset to paired character (optional) * @param {number} noninterrupting_preanim play the full preanim (optional) */ - sendIC(deskmod, preanim, name, emote, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim) { + sendIC(deskmod, preanim, name, emote, message, side, sfx_name, emote_modifier, sfx_delay, objection_modifier, evidence, flip, realization, text_color, showname, other_charid, self_offset, noninterrupting_preanim, looping_sfx, screenshake) { let extra_cccc = ``; let extra_27 = ``; @@ -268,14 +267,11 @@ class Client extends EventEmitter { extra_cccc = `${showname}#${other_charid}#${self_offset}#${noninterrupting_preanim}#`; if (extrafeatures.includes("looping_sfx")) { - const looping_sfx = 0; - const screenshake = 0; const frame_screenshake = ""; const frame_realization = ""; const frame_sfx = ""; extra_27 = `${looping_sfx}#${screenshake}#${frame_screenshake}#${frame_realization}#${frame_sfx}#`; - // looping_sfx, screenshake, frame_screenshake, frame_realization, frame_sfx = args } } @@ -538,12 +534,13 @@ class Client extends EventEmitter { if(this.chars[char_id].name !== char_name) { console.info(this.chars[char_id].name + " is iniediting to " + char_name); - const chargs = (char_name + "&" + "filthy iniedtier").split("&"); + const chargs = (char_name + "&" + "iniediter").split("&"); this.handleCharacterInfo(chargs,char_id); } } catch (e) { msg_nameplate = args[3]; msg_blips = "male"; + char_chatbox = "default"; char_muted = false; console.error("we're still missing some character data"); } @@ -593,11 +590,28 @@ class Client extends EventEmitter { frame_sfx: safe_tags(args[28]) }; chatmsg = Object.assign(extra_27, chatmsg); - } - - if (chatmsg.showname && document.getElementById("showname").checked) { - chatmsg.nameplate = chatmsg.showname; - } + } else { + const extra_27 = { + looping_sfx: 0, + screenshake: 0, + frame_screenshake: "", + frame_realization: "", + frame_sfx: "" + }; + chatmsg = Object.assign(extra_27, chatmsg); + } + } else { + const extra_cccc = { + showname: "", + other_charid: 0, + other_name: "", + other_emote: "", + self_offset: 0, + other_offset: 0, + other_flip: 0, + noninterrupting_preanim: 0 + }; + chatmsg = Object.assign(extra_cccc, chatmsg); } // our own message appeared, reset the buttons @@ -1122,6 +1136,14 @@ class Client extends EventEmitter { document.getElementById("cccc").style.display = ""; document.getElementById("pairing").style.display = ""; } + + if (args.includes("flipping")) { + document.getElementById("button_flip").style.display = ""; + } + + if (args.includes("looping_sfx")) { + document.getElementById("button_shake").style.display = ""; + } } /** @@ -1597,10 +1619,12 @@ async changeBackground(position) { const nameBoxInner = document.getElementById("client_inner_name"); const chatBoxInner = document.getElementById("client_inner_chat"); + const displayname = document.getElementById("showname").checked ? this.chatmsg.showname : this.chatmsg.nameplate; + //Clear out the last message chatBoxInner.innerText = this.textnow; - nameBoxInner.innerText = this.chatmsg.nameplate; - + nameBoxInner.innerText = displayname; + if (this.lastChar !== this.chatmsg.name) { charSprite.style.opacity = 0; charSprite.src = transparentPNG; @@ -1609,7 +1633,7 @@ async changeBackground(position) { } this.lastChar = this.chatmsg.name; - appendICLog(this.chatmsg.content, this.chatmsg.nameplate); + appendICLog(this.chatmsg.content, displayname); // start checking the files try { @@ -1696,13 +1720,10 @@ async changeBackground(position) { charSprite.style.transform = "scaleX(1)"; } - if (extrafeatures.includes("cccc_ic_support")) { - // Flip the pair character - if (this.chatmsg.other_flip === 1) { - pairSprite.style.transform = "scaleX(-1)"; - } else { - pairSprite.style.transform = "scaleX(1)"; - } + if (this.chatmsg.other_flip === 1) { + pairSprite.style.transform = "scaleX(-1)"; + } else { + pairSprite.style.transform = "scaleX(1)"; } this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(this.chatmsg.blips.toLowerCase())}.wav`); @@ -1771,11 +1792,12 @@ async changeBackground(position) { // TODO: preanims sometimes play when they're not supposed to if (this.textTimer >= this.shoutTimer && this.chatmsg.startpreanim) { // Effect stuff - if (this.chatmsg.flash === 2) { + if (this.chatmsg.screenshake === 1) { // Shake screen this.playSFX(AO_HOST + "sounds/general/sfx-stab.wav"); gamewindow.style.animation = "shake 0.2s 1"; - } else if (this.chatmsg.flash === 1) { + } + if (this.chatmsg.flash === 1) { // Flash screen this.playSFX(AO_HOST + "sounds/general/sfx-realization.wav"); document.getElementById("client_fg").style.animation = "flash 0.4s 1"; @@ -1791,19 +1813,16 @@ async changeBackground(position) { charSprite.style.opacity = 1; } - if (extrafeatures.includes("cccc_ic_support")) { - if (this.chatmsg.other_name) { - const pairName = this.chatmsg.other_name.toLowerCase(); - const pairEmote = this.chatmsg.other_emote.toLowerCase(); - pairSprite.style.left = this.chatmsg.other_offset + "%"; - charSprite.style.left = this.chatmsg.self_offset + "%"; - pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; - pairSprite.style.opacity = 1; - } else { - pairSprite.style.opacity = 0; - charSprite.style.left = 0; - } - + if (this.chatmsg.other_name) { + const pairName = this.chatmsg.other_name.toLowerCase(); + const pairEmote = this.chatmsg.other_emote.toLowerCase(); + pairSprite.style.left = this.chatmsg.other_offset + "%"; + charSprite.style.left = this.chatmsg.self_offset + "%"; + pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; + pairSprite.style.opacity = 1; + } else { + pairSprite.style.opacity = 0; + charSprite.style.left = 0; } this.chatmsg.startpreanim = false; @@ -1988,11 +2007,15 @@ export function onEnter(event) { if (event.keyCode === 13) { const mychar = client.character; const myemo = client.emote; - const myevi = client.evidence; - const myflip = ((client.flip) ? 1 : 0); - const mycolor = document.getElementById("textcolor").value; + const evi = client.evidence; + const flip = ((document.getElementById("button_flip").classList.contains("dark")) ? 1 : 0); + const flash = ((document.getElementById("button_flash").classList.contains("dark")) ? 1 : 0); + const screenshake = ((document.getElementById("button_shake").classList.contains("dark")) ? 1 : 0); + const noninterrupting_preanim = ((document.getElementById("check_nonint").checked) ? 1 : 0); + const looping_sfx = ((document.getElementById("check_loopsfx").checked) ? 1 : 0); + const color = document.getElementById("textcolor").value; const showname = document.getElementById("ic_chat_name").value; - const mytext = document.getElementById("client_inputbox").value; + const text = document.getElementById("client_inputbox").value; const pairchar = document.getElementById("pair_select").value; const pairoffset = document.getElementById("pair_offset").value; let sfxname = "0"; @@ -2008,9 +2031,9 @@ export function onEnter(event) { } client.sendIC("chat", preanim, mychar.name, myemo.emote, - mytext, mychar.side, - sfxname, myemo.zoom, sfxdelay, selectedShout, myevi, myflip, - selectedEffect, mycolor, showname, pairchar, pairoffset, 0); + text, mychar.side, + sfxname, myemo.zoom, sfxdelay, selectedShout, evi, flip, + flash, color, showname, pairchar, pairoffset, noninterrupting_preanim, looping_sfx, screenshake); } } window.onEnter = onEnter; @@ -2022,14 +2045,15 @@ window.onEnter = onEnter; */ function resetICParams() { document.getElementById("client_inputbox").value = ""; - if (selectedEffect) { - document.getElementById("button_effect_" + selectedEffect).className = "client_button"; - selectedEffect = 0; - } + document.getElementById("button_flash").className = "client_button"; + document.getElementById("button_shake").className = "client_button"; + + document.getElementById("sendpreanim").checked = false; + if (selectedShout) { document.getElementById("button_" + selectedShout).className = "client_button"; selectedShout = 0; - } + } } /** @@ -2722,46 +2746,15 @@ window.updateBackgroundPreview = updateBackgroundPreview; * If the same effect button is selected, then the effect is canceled. * @param {string} effect the new effect to be selected */ -export function toggleEffect(effect) { - if (effect === selectedEffect) { - document.getElementById("button_effect_" + effect).className = "client_button"; - selectedEffect = 0; +export function toggleEffect(button) { + if (button.classList.contains("dark")) { + button.className = "client_button"; } else { - document.getElementById("button_effect_" + effect).className = "client_button dark"; - if (selectedEffect) { - document.getElementById("button_effect_" + selectedEffect).className = "client_button"; - } - selectedEffect = effect; + button.className = "client_button dark"; } } window.toggleEffect = toggleEffect; -/** - * Toggle flip for in-character chat. - */ -export function toggleFlip() { - if (client.flip) { - document.getElementById("button_flip").className = "client_button"; - } else { - document.getElementById("button_flip").className = "client_button dark"; - } - client.flip = !client.flip; -} -window.toggleFlip = toggleFlip; - -/** - * Toggle presentable for presenting evidence in-character chat. - */ -export function togglePresent() { - if (client.presentable) { - document.getElementById("button_present").className = "client_button"; - } else { - document.getElementById("button_present").className = "client_button dark"; - } - client.presentable = !client.presentable; -} -window.togglePresent = togglePresent; - /** * Highlights and selects a menu. * @param {string} menu the menu to be selected -- cgit From 91a4d67adaf0293146c610f08b47cc3a82923959 Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 3 May 2020 16:46:23 +0200 Subject: fix weird blinkyness on the chatbox --- webAO/client.js | 1 - 1 file changed, 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 49955c0..0925b9f 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1898,7 +1898,6 @@ async changeBackground(position) { chatBoxInner.innerText = this.textnow; if (this.textnow === this.chatmsg.content) { - this.textTimer = 0; this._animating = false; charSprite.src = this.silentSprite; charSprite.style.opacity = 1; -- cgit From 89d4e999aa7aee6bb098f65a062dbc17e501e77c Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 3 May 2020 18:58:52 +0200 Subject: don't show empty shownames --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 0925b9f..9eb3768 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1619,7 +1619,7 @@ async changeBackground(position) { const nameBoxInner = document.getElementById("client_inner_name"); const chatBoxInner = document.getElementById("client_inner_chat"); - const displayname = document.getElementById("showname").checked ? this.chatmsg.showname : this.chatmsg.nameplate; + const displayname = (document.getElementById("showname").checked && this.chatmsg.showname !== "") ? this.chatmsg.showname : this.chatmsg.nameplate; //Clear out the last message chatBoxInner.innerText = this.textnow; -- cgit From 26025b94a23fedcc45005ca6e7367e7b9a2bc1a4 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 5 May 2020 19:44:52 +0200 Subject: evidence got run over in "support 2.7" --- webAO/client.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9eb3768..886f16d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -106,8 +106,6 @@ class Client extends EventEmitter { // Preset some of the variables - this.presentable = false; - this.hp = [0, 0]; this.playerID = 1; @@ -214,10 +212,10 @@ class Client extends EventEmitter { } /** - * Gets the player's currently selected evidence if presentable. + * Gets the current evidence ID unless the player doesn't want to present any evidence */ get evidence() { - return this.presentable ? this.selectedEvidence : 0; + return (document.getElementById("button_present").classList.contains("dark")) ? this.selectedEvidence : 0; } /** -- cgit From 682fec7dd05b233870fc00b3b4b1f6657fcec5ae Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 6 May 2020 23:19:35 +0200 Subject: break out audio detection into seperate function --- webAO/client.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 886f16d..07acdde 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -832,14 +832,19 @@ class Client extends EventEmitter { document.getElementById("areas").innerHTML = ""; } - handleMusicInfo(trackindex,trackname) { - let flagAudio = false; - - if (/\.(?:wav|mp3|mp4|ogg|opus)$/i.test(trackname) || trackname.startsWith("=")) { - flagAudio = true; + isAudio(trackname) { + if (/\.(?:wav|mp3|mp4|ogg|opus)$/i.test(trackname) || // regex for file extenstions + trackname.startsWith("=") || + trackname.startsWith("-")) // category markers + { + return true; + } else { + return false; } + } - if (flagAudio) { + handleMusicInfo(trackindex,trackname) { + if (this.isAudio(trackname)) { // After reached the audio put everything in the music list const newentry = document.createElement("OPTION"); newentry.text = trackname; -- cgit From 2ed6f9a2e837b85382d62ce3f9b6c180dec3d48e Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 9 May 2020 14:33:12 +0200 Subject: allow chatboxes to use centered text all the time --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 07acdde..d2676f9 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1736,7 +1736,7 @@ async changeBackground(position) { chatBoxInner.style.textAlign = "center"; this.chatmsg.content = this.chatmsg.content.substring(2, this.chatmsg.content.length); } else { - chatBoxInner.style.textAlign = "initial"; + chatBoxInner.style.textAlign = "inherit"; } this.tick(); -- cgit From 481198c88421e7c97163edae5861238d620b6730 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 11 May 2020 20:26:05 +0200 Subject: don't load all the chars at once --- webAO/client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d2676f9..8119821 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -761,7 +761,8 @@ class Client extends EventEmitter { if (i % 2 === 0) { document.getElementById("client_loadingtext").innerHTML = `Loading Character ${i}/${this.char_list_length}`; const chargs = args[i].split("&"); - this.handleCharacterInfo(chargs, args[i - 1]); + const charid = args[i - 1]; + setTimeout(() => this.handleCharacterInfo(chargs, charid), charid*10); } } // Request the next pack @@ -778,7 +779,8 @@ class Client extends EventEmitter { for (let i = 1; i < args.length; i++) { document.getElementById("client_loadingtext").innerHTML = `Loading Character ${i}/${this.char_list_length}`; const chargs = args[i].split("&"); - this.handleCharacterInfo(chargs, i - 1); + const charid = i - 1; + setTimeout(() => this.handleCharacterInfo(chargs, charid), charid*10); } // We're done with the characters, request the music this.sendServer("RM#%"); -- cgit From 4002d0426b3fed91ecfa3f6e31b9c05eb4d3776a Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 12 May 2020 18:10:28 +0200 Subject: fix characters above 1000 not working --- webAO/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 8119821..de269be 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2391,11 +2391,11 @@ window.chartable_filter = chartable_filter; * then spectator is chosen instead. */ export function pickChar(ccharacter) { - if (ccharacter < 1000) { - client.sendCharacter(ccharacter); - } else { + if (ccharacter===-1) { // Spectator - document.getElementById("client_charselect").style.display = "none"; + document.getElementById("client_charselect").style.display = "none"; + } else { + client.sendCharacter(ccharacter); } } window.pickChar = pickChar; -- cgit From 031142136fe86e23188e8f799517bad9b8719573 Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 27 May 2020 00:53:34 +0200 Subject: let the user change the viewport size to 16:9 --- webAO/client.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index de269be..ebaa09e 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2197,6 +2197,37 @@ export async function iniedit() { } window.iniedit = iniedit; +/** + * Triggered by the change aspect ratio checkbox + */ +export async function switchAspectRatio() { + const background = document.getElementById("client_background"); + const offsetCheck = document.getElementById("client_hdviewport_offset"); + if(document.getElementById("client_hdviewport").checked) { + background.style.paddingBottom = "56.25%"; + offsetCheck.disabled = false; + } else { + background.style.paddingBottom = "75%"; + offsetCheck.disabled = true; + } +} +window.switchAspectRatio = switchAspectRatio; + +/** + * Triggered by the change aspect ratio checkbox + */ +export async function switchChatOffset() { + const container = document.getElementById("client_chatcontainer"); + if(document.getElementById("client_hdviewport_offset").checked) { + container.style.width = "80%"; + container.style.left = "10%"; + } else { + container.style.width = "100%"; + container.style.left = 0; + } +} +window.switchChatOffset = switchChatOffset; + /** * Triggered when a character icon is clicked in the character selection menu. * @param {MouseEvent} event -- cgit From cdaea55c1b357c042e9f9e8f6223f1fd6db2b616 Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 27 May 2020 22:34:52 +0200 Subject: change chatwaiting back to opacity so i can animate it --- webAO/client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index ebaa09e..da6acb4 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1607,7 +1607,7 @@ async changeBackground(position) { // Reset CSS animation fg.style.animation = ""; gamewindow.style.animation = ""; - waitingBox.innerText = ""; + waitingBox.style.opacity = 0; const eviBox = document.getElementById("client_evi"); @@ -1887,7 +1887,7 @@ async changeBackground(position) { if (this.textnow === this.chatmsg.content) { charSprite.src = this.silentSprite; charSprite.style.opacity = 1; - waitingBox.innerHTML = "►"; + waitingBox.style.opacity = 1; this._animating = false; clearTimeout(this.updater); } @@ -1906,7 +1906,7 @@ async changeBackground(position) { this._animating = false; charSprite.src = this.silentSprite; charSprite.style.opacity = 1; - waitingBox.innerHTML = "►"; + waitingBox.style.opacity = 1; clearTimeout(this.updater); } } -- cgit From 3b591a5d7309b07ff8f47d936e3b145c7c4d8017 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 12:47:28 +0200 Subject: let the user control more of the audio --- webAO/client.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index da6acb4..52b7976 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -414,8 +414,10 @@ class Client extends EventEmitter { document.getElementById("client_musicaudio").volume = getCookie("musicVolume") || 1; changeMusicVolume(); - document.getElementById("client_svolume").value = getCookie("sfxVolume") || 1; + document.getElementById("client_sfxaudio").volume = getCookie("sfxVolume") || 1; changeSFXVolume(); + document.getElementById("client_shoutaudio").volume = getCookie("shoutVolume") || 1; + changeShoutVolume(); document.getElementById("client_bvolume").value = getCookie("blipVolume") || 1; changeBlipVolume(); @@ -1316,13 +1318,16 @@ class Viewport { .forEach(channel => channel.volume = 0.5); this.currentBlipChannel = 0; - this.sfxaudio = new Audio(AO_HOST + "sounds/general/sfx-blipmale.wav"); + this.sfxaudio = document.getElementById("client_sfxaudio"); + this.sfxaudio.src = `${AO_HOST}sounds/general/sfx-realization.wav`; + this.sfxplayed = 0; - this.shoutaudio = new Audio(); + this.shoutaudio = document.getElementById("client_shoutaudio"); + this.shoutaudio.src = `${AO_HOST}misc/default/objection.wav`; this.music = document.getElementById("client_musicaudio"); - this.music.play(); + this.music.src = `${AO_HOST}sounds/music/trial (aa).mp3`; this.updater = null; this.testimonyUpdater = null; @@ -2153,12 +2158,18 @@ window.changeMusicVolume = changeMusicVolume; * Triggered by the sound effect volume slider. */ export function changeSFXVolume() { - viewport.sfxaudio.volume = document.getElementById("client_svolume").value; - viewport.shoutaudio.volume = document.getElementById("client_svolume").value; - setCookie("sfxVolume", document.getElementById("client_svolume").value); + setCookie("sfxVolume", document.getElementById("client_sfxaudio").volume); } window.changeSFXVolume = changeSFXVolume; +/** + * Triggered by the shout volume slider. + */ +export function changeShoutVolume() { + setCookie("shoutVolume", document.getElementById("client_shoutaudio").volume); +} +window.changeShoutVolume = changeShoutVolume; + /** * Triggered by the blip volume slider. */ -- cgit From f98e25772c45ef8d16708b38e7a8d0c88cbd2086 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 12:49:56 +0200 Subject: don't cause an exception if the cookie doesn't exist --- webAO/client.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 52b7976..93d374f 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1971,19 +1971,23 @@ class INI { * @param {String} cname The name of the cookie to return */ function getCookie(cname) { - var name = cname + "="; - var decodedCookie = decodeURIComponent(document.cookie); - var ca = decodedCookie.split(';'); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) === ' ') { - c = c.substring(1); - } - if (c.indexOf(name) === 0) { - return c.substring(name.length, c.length); + try { + const name = cname + "="; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } } + return ""; + } catch (error) { + return ""; } - return ""; } /** -- cgit From 85637212c626b57d352da8746982096b5e97c4b6 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 18:01:56 +0200 Subject: shownames are already done --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 93d374f..49db84b 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -550,7 +550,7 @@ class Client extends EventEmitter { let chatmsg = { deskmod: safe_tags(args[1]).toLowerCase(), preanim: safe_tags(args[2]).toLowerCase(), // get preanim - nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed + nameplate: msg_nameplate, chatbox: char_chatbox, name: char_name, sprite: safe_tags(args[4]).toLowerCase(), -- cgit From 6b52935d7232271f87f3321d6f7df18f9a88a1c8 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 18:02:09 +0200 Subject: initupdate is no more --- webAO/client.js | 1 - 1 file changed, 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 49db84b..1d008c1 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1589,7 +1589,6 @@ async changeBackground(position) { /** * Sets a new emote. - * TODO: merge this and initUpdater * This sets up everything before the tick() loops starts * a lot of things can probably be moved here, like starting the shout animation if there is one * TODO: the preanim logic, on the other hand, should probably be moved to tick() -- cgit From d3444de2e269d193cb36e60644dd2ee4fe0033aa Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 18:05:06 +0200 Subject: flipping was already moved to say --- webAO/client.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 1d008c1..9969278 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1729,6 +1729,7 @@ async changeBackground(position) { charSprite.style.transform = "scaleX(1)"; } + // flip the paired character if (this.chatmsg.other_flip === 1) { pairSprite.style.transform = "scaleX(-1)"; } else { @@ -1753,18 +1754,10 @@ async changeBackground(position) { * * OK, here's the documentation on how this works: * - * 1 flip - * For whatever reason it starts off by checking if the character is flipped, every time this is called - * This is probably a TODO to move this somewhere else - * - * 2 flip - * If the server supports it, the same is done for the paired character - * Both of these should probably be moved to say() - * - * 3 _animating + * 1 _animating * If we're not done with this characters animation, i.e. his text isn't fully there, set a timeout for the next tick/step to happen * - * 5 startpreanim + * 2 startpreanim * If the shout timer is over it starts with the preanim * The first thing it checks for is the shake effect (TODO on client this is handled by the @ symbol and not a flag ) * Then is the flash/realization effect @@ -1772,14 +1765,14 @@ async changeBackground(position) { * and the main characters preanim gif is loaded * If pairing is supported the paired character will just stand around with his idle sprite * - * 6 preanimdelay over + * 3 preanimdelay over * this animates the evidence popup and finally shows the character name and message box * it sets the text color , changes the background (again TODO) and sets the character speaking sprite * - * 7 textnow != content + * 4 textnow != content * this adds a character to the textbox and stops the animations if the entire message is present in the textbox * - * 8 sfx + * 5 sfx * independent of the stuff above, this will play any sound effects specified by the emote the character sent. * happens after the shout delay + an sfx delay that comes with the message packet * -- cgit From 47f7a1b740e2f280cb85b6a1c239d02f57bc5f59 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 18:06:23 +0200 Subject: shout sprite is dealt with in css --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9969278..1b7684d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1761,7 +1761,7 @@ async changeBackground(position) { * If the shout timer is over it starts with the preanim * The first thing it checks for is the shake effect (TODO on client this is handled by the @ symbol and not a flag ) * Then is the flash/realization effect - * After that, the shout image is set to a transparent placeholder gif (TODO just hide it with CSS) + * After that, the shout image set to be transparent * and the main characters preanim gif is loaded * If pairing is supported the paired character will just stand around with his idle sprite * -- cgit From d333a6c3b163d74c62009a36e74f0061416f1862 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 18:20:01 +0200 Subject: redundant bg change --- webAO/client.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 1b7684d..9207a1a 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1767,7 +1767,7 @@ async changeBackground(position) { * * 3 preanimdelay over * this animates the evidence popup and finally shows the character name and message box - * it sets the text color , changes the background (again TODO) and sets the character speaking sprite + * it sets the text color and the character speaking sprite * * 4 textnow != content * this adds a character to the textbox and stops the animations if the entire message is present in the textbox @@ -1861,7 +1861,6 @@ async changeBackground(position) { if (this.chatmsg.preanimdelay === 0) { shoutSprite.style.opacity = 0; shoutSprite.style.animation = ""; - this.changeBackground(this.chatmsg.side); } if (extrafeatures.includes("cccc_ic_support")) { -- cgit From e173042f8c5c8e308a751f1caceec9c10469da29 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 1 Jun 2020 18:35:11 +0200 Subject: autoscroll so long messages aren't cut off --- webAO/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9207a1a..ff1774b 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1789,7 +1789,8 @@ 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"); + const chatBoxInner = document.getElementById("client_inner_chat"); + const chatBox = document.getElementById("client_chat"); // TODO: preanims sometimes play when they're not supposed to if (this.textTimer >= this.shoutTimer && this.chatmsg.startpreanim) { @@ -1898,6 +1899,9 @@ async changeBackground(position) { chatBoxInner.innerText = this.textnow; + // scroll to bottom + chatBox.scrollTop = chatBox.scrollHeight; + if (this.textnow === this.chatmsg.content) { this._animating = false; charSprite.src = this.silentSprite; -- cgit From d4ca2dc1777888749e046408e063a1a855b9663c Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 2 Jun 2020 00:53:54 +0200 Subject: introduce an indicator for the current track --- webAO/client.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index ff1774b..b5cd57b 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -666,6 +666,8 @@ class Client extends EventEmitter { } else { appendICLog(`The music was changed to ${track}`); } + + document.getElementById("client_trackstatus").innerText = track; } /** -- cgit From a4a9bb6febc800f423813eb0772a2ed350b322ad Mon Sep 17 00:00:00 2001 From: sD Date: Wed, 3 Jun 2020 20:45:47 +0200 Subject: trackstatus: set inner text so i have a div to style it around --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index b5cd57b..9925cab 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -667,7 +667,7 @@ class Client extends EventEmitter { appendICLog(`The music was changed to ${track}`); } - document.getElementById("client_trackstatus").innerText = track; + document.getElementById("client_trackstatustext").innerText = track; } /** -- cgit From f3e1694c23bc7e587e2a6a55ca5f49052cce832a Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 6 Jun 2020 17:42:22 +0200 Subject: allow the paired char to be png too --- webAO/client.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 9925cab..8377551 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1667,6 +1667,18 @@ async changeBackground(position) { this.silentSprite = AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif"; } + if (this.chatmsg.other_name) { + try { + const { url: pairUrl } = await this.oneSuccess([ + this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/" + this.chatmsg.sprite + ".png")), + this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif")) + ]); + this.pairSilent = pairUrl ? pairUrl : transparentPNG; + } catch (error) { + this.pairSilent = AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif"; + } + } + // gets which shout shall played const shoutSprite = document.getElementById("client_shout"); const shout = this.shouts[this.chatmsg.objection]; @@ -1823,7 +1835,7 @@ async changeBackground(position) { const pairEmote = this.chatmsg.other_emote.toLowerCase(); pairSprite.style.left = this.chatmsg.other_offset + "%"; charSprite.style.left = this.chatmsg.self_offset + "%"; - pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; + pairSprite.src = this.pairSilent; pairSprite.style.opacity = 1; } else { pairSprite.style.opacity = 0; @@ -1872,7 +1884,7 @@ async changeBackground(position) { const pairEmote = this.chatmsg.other_emote.toLowerCase(); pairSprite.style.left = this.chatmsg.other_offset + "%"; charSprite.style.left = this.chatmsg.self_offset + "%"; - pairSprite.src = `${AO_HOST}characters/${pairName}/(a)${pairEmote}.gif`; + pairSprite.src = this.pairSilent; pairSprite.style.opacity = 1; } else { pairSprite.style.opacity = 0; -- cgit From 865c695be40d4deb9c2a506de167242e69e4f278 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Tue, 7 Jul 2020 16:20:33 -0500 Subject: Change default asset host to CDN and rebuild --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 8377551..7f80280 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -33,7 +33,7 @@ const serverIP = queryDict.ip; let mode = queryDict.mode; // Unless there is an asset URL specified, use the wasabi one -const DEFAULT_HOST = location.hostname ? "https://s3.wasabisys.com/webao/base/" : "base/"; +const DEFAULT_HOST = location.hostname ? "https://webao-full.animatedchatroom.net/base/" : "base/"; const AO_HOST = queryDict.asset || DEFAULT_HOST; const THEME = queryDict.theme || "default"; const MUSIC_HOST = AO_HOST + "sounds/music/"; -- cgit From a680affb025bf469975e429b40d3e660b159f2d2 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 9 Jul 2020 21:03:45 +0200 Subject: use only off sprite --- webAO/client.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 8377551..5892d3a 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1261,11 +1261,10 @@ class Client extends EventEmitter { frame_screenshake: "", frame_realization: "", frame_sfx: "", - button_off: AO_HOST + `characters/${encodeURI(me.name.toLowerCase())}/emotions/button${i}_off.png`, - button_on: AO_HOST + `characters/${encodeURI(me.name.toLowerCase())}/emotions/button${i}_on.png` + button: AO_HOST + `characters/${encodeURI(me.name.toLowerCase())}/emotions/button${i}_off.png` }; emotesList.innerHTML += - `${emotes[i].desc} Date: Fri, 10 Jul 2020 19:53:43 +0200 Subject: round the font size --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 8377551..4ce5fb4 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2620,7 +2620,7 @@ export function resizeChatbox() { const chatContainerBox = document.getElementById("client_chatcontainer"); const gameHeight = document.getElementById("client_background").offsetHeight; - chatContainerBox.style.fontSize = (gameHeight * 0.05) + "px"; + chatContainerBox.style.fontSize = (gameHeight * 0.0521).toFixed(1) + "px"; } window.resizeChatbox = resizeChatbox; -- cgit From b2c17c1e31aaca37340186ad972b5e17de6c0031 Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 12 Jul 2020 19:33:53 +0200 Subject: use paired sprite in exception handler instead of own sprite --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index b0d69bf..f6b4be3 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1674,7 +1674,7 @@ async changeBackground(position) { ]); this.pairSilent = pairUrl ? pairUrl : transparentPNG; } catch (error) { - this.pairSilent = AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif"; + this.pairSilent = AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/(a)" + this.chatmsg.other_emote + ".gif"; } } -- cgit From ba09cd78b07edb9c521d15213d74214519301d1f Mon Sep 17 00:00:00 2001 From: sD Date: Sun, 12 Jul 2020 19:36:12 +0200 Subject: use the paired emote for real!!! --- webAO/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index f6b4be3..938c566 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1669,8 +1669,8 @@ async changeBackground(position) { if (this.chatmsg.other_name) { try { const { url: pairUrl } = await this.oneSuccess([ - this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/" + this.chatmsg.sprite + ".png")), - this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif")) + this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/" + this.chatmsg.other_emote + ".png")), + this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.other_name.toLowerCase()) + "/(a)" + this.chatmsg.other_emote + ".gif")) ]); this.pairSilent = pairUrl ? pairUrl : transparentPNG; } catch (error) { -- cgit From 573b4bc2e82145d0c092daf964711a062d8fba9d Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Jul 2020 18:37:36 +0200 Subject: remember the cookie --- webAO/client.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 938c566..4f3d4fc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -418,6 +418,8 @@ class Client extends EventEmitter { changeSFXVolume(); document.getElementById("client_shoutaudio").volume = getCookie("shoutVolume") || 1; changeShoutVolume(); + document.getElementById("client_testimonyaudio").volume = getCookie("testimonyVolume") || 1; + changeTestimonyVolume(); document.getElementById("client_bvolume").value = getCookie("blipVolume") || 1; changeBlipVolume(); @@ -2182,6 +2184,14 @@ export function changeShoutVolume() { } window.changeShoutVolume = changeShoutVolume; +/** + * Triggered by the testimony volume slider. + */ +export function changeTestimonyVolume() { + setCookie("testimonyVolume", document.getElementById("client_testimonyaudio").volume); +} +window.changeTestimonyVolume = changeTestimonyVolume; + /** * Triggered by the blip volume slider. */ -- cgit From 37134ff18d3b131adc75dbfa1a2a0abbebf5c5e8 Mon Sep 17 00:00:00 2001 From: sD Date: Mon, 13 Jul 2020 18:41:23 +0200 Subject: use the new testimony element --- webAO/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 4f3d4fc..d4365dd 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1329,6 +1329,9 @@ class Viewport { this.shoutaudio = document.getElementById("client_shoutaudio"); this.shoutaudio.src = `${AO_HOST}misc/default/objection.wav`; + this.testimonyAudio = document.getElementById("client_testimonyaudio"); + this.testimonyAudio.src = `${AO_HOST}sounds/general/sfx-notguilty.wav`; + this.music = document.getElementById("client_musicaudio"); this.music.src = `${AO_HOST}sounds/music/trial (aa).mp3`; @@ -1474,7 +1477,8 @@ async changeBackground(position) { return; } - (new Audio(client.resources[testimony].sfx)).play(); + this.testimonyAudio.src = client.resources[testimony].sfx; + this.testimonyAudio.play(); const testimonyOverlay = document.getElementById("client_testimony"); testimonyOverlay.src = client.resources[testimony].src; -- cgit From 71e3a749d7a8de9c982e670f88eb2c08d3091565 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 14 Jul 2020 19:01:04 +0200 Subject: add a callword array and fill it when it's changed --- webAO/client.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 938c566..d4b6bc9 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -121,6 +121,8 @@ class Client extends EventEmitter { this.areas = []; this.musics = []; + this.callwords = []; + this.resources = { "holdit": { "src": AO_HOST + "misc/default/holdit_bubble.png", @@ -2201,6 +2203,14 @@ export function reloadTheme() { } window.reloadTheme = reloadTheme; +/** + * Triggered by a changed callword list + */ +export function changeCallwords() { + client.callwords = document.getElementById("client_callwords").value.split('\n'); +} +window.changeCallwords = changeCallwords; + /** * Triggered by the modcall sfx dropdown */ -- cgit From 98df57731191013688a7f26f736f3d0ecf7cc750 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 14 Jul 2020 19:16:28 +0200 Subject: add function to check the words --- webAO/client.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d4b6bc9..e3f4d95 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1647,6 +1647,8 @@ async changeBackground(position) { appendICLog(this.chatmsg.content, displayname); + checkCallword(this.chatmsg.content); + // start checking the files try { const { url: speakUrl } = await this.oneSuccess([ @@ -2431,6 +2433,26 @@ function appendICLog(msg, name = "", time = new Date()) { lastICMessageTime = new Date(); } +/** + * check if the message contains an entry on our callword list + * @param {String} message + */ +export function checkCallword(message) { + client.callwords.forEach(testCallword); + + function testCallword(item) + { + if(item !== "" && message.includes(item)) + { + viewport.sfxaudio.pause(); + viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; + viewport.sfxaudio.play(); + } + } +} + + + /** * Triggered when the music search bar is changed * @param {MouseEvent} event -- cgit From c08ea7b7ea6c740299425e4325d946907720921e Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 14 Jul 2020 19:18:59 +0200 Subject: case insensitivity --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index e3f4d95..1faca4c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -2442,7 +2442,7 @@ export function checkCallword(message) { function testCallword(item) { - if(item !== "" && message.includes(item)) + if(item !== "" && message.toLowerCase().includes(item.toLowerCase())) { viewport.sfxaudio.pause(); viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; -- cgit From e5f3a22ba242b0921c58290fed7147a9912dceac Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 14 Jul 2020 19:25:19 +0200 Subject: save and load the callwords to a cookie --- webAO/client.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index aad1895..d9acaad 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -427,6 +427,8 @@ class Client extends EventEmitter { document.getElementById("ic_chat_name").value = getCookie("ic_chat_name"); document.getElementById("showname").checked = getCookie("showname"); + + document.getElementById("client_callwords").value = getCookie("callwords"); } /** @@ -2224,6 +2226,7 @@ window.reloadTheme = reloadTheme; */ export function changeCallwords() { client.callwords = document.getElementById("client_callwords").value.split('\n'); + setCookie("callwords",client.callwords); } window.changeCallwords = changeCallwords; -- cgit