diff options
Diffstat (limited to 'webAO/viewport/utils')
| -rw-r--r-- | webAO/viewport/utils/handleICSpeaking.ts | 40 | ||||
| -rw-r--r-- | webAO/viewport/utils/setSide.ts | 17 |
2 files changed, 31 insertions, 26 deletions
diff --git a/webAO/viewport/utils/handleICSpeaking.ts b/webAO/viewport/utils/handleICSpeaking.ts index 2cea926..4fe68d3 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 = (<HTMLInputElement>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 = <HTMLImageElement>( 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() @@ -213,13 +213,17 @@ 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 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 +248,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 +297,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 +323,6 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { } client.viewport.getChatmsg().parsed = output; } - + client.viewport.chat_tick(); -};
\ No newline at end of file +}; diff --git a/webAO/viewport/utils/setSide.ts b/webAO/viewport/utils/setSide.ts index 3726e83..77d1744 100644 --- a/webAO/viewport/utils/setSide.ts +++ b/webAO/viewport/utils/setSide.ts @@ -2,7 +2,7 @@ import { positions } from '../constants/positions' import { AO_HOST } from '../../client/aoHost' import { client } from '../../client' import tryUrls from '../../utils/tryUrls'; -import fileExists from '../../utils/fileExists'; +import findImgSrc from '../../utils/findImgSrc'; /** * Changes the viewport background based on a given position. @@ -21,7 +21,7 @@ export const set_side = async ({ }) => { const view = document.getElementById("client_fullview")!; let bench: HTMLImageElement; - if (['def','pro','wit'].includes(position)) { + if (['def', 'pro', 'wit'].includes(position)) { bench = <HTMLImageElement>( document.getElementById(`client_${position}_bench`) ); @@ -57,13 +57,14 @@ export const set_side = async ({ } else { court.src = await tryUrls(client.viewport.getBackgroundFolder() + bg); } - - + if (showDesk === true && desk) { - const deskFilename = (await fileExists(client.viewport.getBackgroundFolder() + desk.ao2)) - ? desk.ao2 - : desk.ao1; - bench.src = client.viewport.getBackgroundFolder() + deskFilename; + const bg_folder = client.viewport.getBackgroundFolder(); + const urls_to_try = [ + bg_folder + desk.ao2, + bg_folder + desk.ao1, + ]; + bench.src = await findImgSrc(urls_to_try); bench.style.opacity = "1"; } else { bench.style.opacity = "0"; |
