Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide chatbox on blankpost #204

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
};
};
Loading