Skip to content

Commit

Permalink
Merge pull request #204 from Troid-Tech/hide-chatbox-on-blankpost
Browse files Browse the repository at this point in the history
Hide chatbox on blankpost
  • Loading branch information
stonedDiscord authored Nov 24, 2023
2 parents 0bde198 + a1b7ec1 commit 81f2c7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
10 changes: 6 additions & 4 deletions webAO/packets/handlers/handleMS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand All @@ -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]),
Expand All @@ -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("|"),
Expand Down Expand Up @@ -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
Expand All @@ -169,4 +171,4 @@ export const handleMS = (args: string[]) => {
handle_ic_speaking(chatmsg); // no await
}
}
}
}
40 changes: 22 additions & 18 deletions webAO/viewport/utils/handleICSpeaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!;

Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -319,6 +323,6 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => {
}
client.viewport.getChatmsg().parsed = output;
}

client.viewport.chat_tick();
};
};

0 comments on commit 81f2c7a

Please sign in to comment.