From c599fe02347d5dd26a97edc6eedc6cee3d74e3e2 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 23 Nov 2023 19:58:38 +0100 Subject: [PATCH 1/2] Formatting --- webAO/packets/handlers/handleMS.ts | 8 +++--- webAO/viewport/utils/handleICSpeaking.ts | 36 ++++++++++++------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/webAO/packets/handlers/handleMS.ts b/webAO/packets/handlers/handleMS.ts index 84649427..894db3b5 100644 --- a/webAO/packets/handlers/handleMS.ts +++ b/webAO/packets/handlers/handleMS.ts @@ -78,7 +78,7 @@ export const handleMS = (args: string[]) => { speed: UPDATE_INTERVAL, }; - if (args.length>16) { + if (args.length > 16) { const extra_cccc = { showname: prepChat(args[16]), other_charid: Number(args[17]), @@ -91,7 +91,7 @@ export const handleMS = (args: string[]) => { }; chatmsg = Object.assign(extra_cccc, chatmsg); - if (args.length>24) { + if (args.length > 24) { const extra_27 = { looping_sfx: Number(args[24]), screenshake: Number(args[25]), @@ -101,7 +101,7 @@ export const handleMS = (args: string[]) => { }; chatmsg = Object.assign(extra_27, chatmsg); - if (args.length>29) { + if (args.length > 29) { const extra_28 = { additive: Number(args[29]), effects: args[30].split("|"), @@ -169,4 +169,4 @@ export const handleMS = (args: string[]) => { handle_ic_speaking(chatmsg); // no await } } -} \ No newline at end of file +} diff --git a/webAO/viewport/utils/handleICSpeaking.ts b/webAO/viewport/utils/handleICSpeaking.ts index 2cea9260..e2b8a295 100644 --- a/webAO/viewport/utils/handleICSpeaking.ts +++ b/webAO/viewport/utils/handleICSpeaking.ts @@ -15,11 +15,11 @@ import mlConfig from "../../utils/aoml"; const attorneyMarkdown = mlConfig(AO_HOST); export let startFirstTickCheck: boolean; -export const setStartFirstTickCheck = (val: boolean) => {startFirstTickCheck = val} +export const setStartFirstTickCheck = (val: boolean) => { startFirstTickCheck = val } export let startSecondTickCheck: boolean; -export const setStartSecondTickCheck = (val: boolean) => {startSecondTickCheck = val} +export const setStartSecondTickCheck = (val: boolean) => { startSecondTickCheck = val } export let startThirdTickCheck: boolean; -export const setStartThirdTickCheck = (val: boolean) => {startThirdTickCheck = val} +export const setStartThirdTickCheck = (val: boolean) => { startThirdTickCheck = val } /** * Sets a new emote. * This sets up everything before the tick() loops starts @@ -73,7 +73,7 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { const displayname = (document.getElementById("showname")).checked && - client.viewport.getChatmsg().showname !== "" + client.viewport.getChatmsg().showname !== "" ? client.viewport.getChatmsg().showname! : client.viewport.getChatmsg().nameplate!; @@ -91,7 +91,7 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { appendICLog(client.viewport.getChatmsg().content, client.viewport.getChatmsg().showname, client.viewport.getChatmsg().nameplate); checkCallword(client.viewport.getChatmsg().content, client.viewport.getSfxAudio()); - + setEmote( AO_HOST, client, @@ -118,7 +118,7 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { const shoutSprite = ( document.getElementById("client_shout") ); - + const shout = SHOUTS[client.viewport.getChatmsg().objection]; if (shout) { // Hide message box @@ -148,7 +148,7 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { if (client.viewport.getChatmsg().type === 1 && client.viewport.getChatmsg().preanim !== "-") { //we have a preanim chatContainerBox.style.opacity = "0"; - + gifLength = await getAnimLength( `${AO_HOST}characters/${encodeURI( client.viewport.getChatmsg().name!.toLowerCase() @@ -217,9 +217,9 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { if (!skipoffset) { // Flip the character charLayers.style.transform = - client.viewport.getChatmsg().flip === 1 ? "scaleX(-1)" : "scaleX(1)"; + client.viewport.getChatmsg().flip === 1 ? "scaleX(-1)" : "scaleX(1)"; pairLayers.style.transform = - client.viewport.getChatmsg().other_flip === 1 ? "scaleX(-1)" : "scaleX(1)"; + client.viewport.getChatmsg().other_flip === 1 ? "scaleX(-1)" : "scaleX(1)"; // Shift by the horizontal offset switch (client.viewport.getChatmsg().side) { @@ -244,9 +244,9 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { client.viewport.blipChannels.forEach( (channel: HTMLAudioElement) => - (channel.src = `${AO_HOST}sounds/blips/${encodeURI( - client.viewport.getChatmsg().blips.toLowerCase() - )}.opus`) + (channel.src = `${AO_HOST}sounds/blips/${encodeURI( + client.viewport.getChatmsg().blips.toLowerCase() + )}.opus`) ); // process markup @@ -293,20 +293,20 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { fg.src = transparentPng; } - + charLayers.style.opacity = "1"; const soundChecks = ["0", "1", "", undefined]; if (soundChecks.some((check) => client.viewport.getChatmsg().sound === check)) { client.viewport.getChatmsg().sound = client.viewport.getChatmsg().effects[2]; } - + try { client.viewport.getChatmsg().parsed = await attorneyMarkdown.applyMarkdown( client.viewport.getChatmsg().content, - + COLORS[client.viewport.getChatmsg().color] - + ); } catch (error) { console.warn("markdown failed"); @@ -319,6 +319,6 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { } client.viewport.getChatmsg().parsed = output; } - + client.viewport.chat_tick(); -}; \ No newline at end of file +}; From a1b7ec16b3cfb9e4ac0f61ed74269416cd63475a Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 23 Nov 2023 19:58:55 +0100 Subject: [PATCH 2/2] Hide chatbox on blankposts --- webAO/packets/handlers/handleMS.ts | 2 ++ webAO/viewport/utils/handleICSpeaking.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/webAO/packets/handlers/handleMS.ts b/webAO/packets/handlers/handleMS.ts index 894db3b5..1c30d55e 100644 --- a/webAO/packets/handlers/handleMS.ts +++ b/webAO/packets/handlers/handleMS.ts @@ -159,6 +159,8 @@ export const handleMS = (args: string[]) => { if (chatmsg.content.trim() === "") { //blankpost chatmsg.content = ""; + // empty string as chatbox means hide it + chatmsg.chatbox = ""; } // our own message appeared, reset the buttons diff --git a/webAO/viewport/utils/handleICSpeaking.ts b/webAO/viewport/utils/handleICSpeaking.ts index e2b8a295..4fe68d30 100644 --- a/webAO/viewport/utils/handleICSpeaking.ts +++ b/webAO/viewport/utils/handleICSpeaking.ts @@ -213,6 +213,10 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { setChatbox(client.viewport.getChatmsg().chatbox); resizeChatbox(); + if (client.viewport.getChatmsg().chatbox === "") { + // No chatbox means hide it + chatContainerBox.style.opacity = "0"; + } if (!skipoffset) { // Flip the character