aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-08-27 18:51:20 +0200
committerstonedDiscord <Tukz@gmx.de>2022-08-27 18:51:20 +0200
commit4bfa34dc950e30650e9525126448bf74dd243096 (patch)
treeec7696fa4f3930b96e9a727cf46ec9885093e489
parent2a79fa570e6e144e4124f3038214f6f49d2acac0 (diff)
parent21170e1935e34f36d2fd4268468414e8caf84627 (diff)
Merge branch 'master' into newclock
-rw-r--r--public/client.html3
-rw-r--r--webAO/client.ts199
-rw-r--r--webAO/client/setEmote.ts6
-rw-r--r--webAO/packets/handlers/handleMS.ts162
-rw-r--r--webAO/utils/queryParser.ts22
5 files changed, 203 insertions, 189 deletions
diff --git a/public/client.html b/public/client.html
index 731c063..11b637e 100644
--- a/public/client.html
+++ b/public/client.html
@@ -34,12 +34,11 @@
<link rel="stylesheet" type="text/css" href="styles/default.css?v=1.0.1" id="client_theme">
<link rel="stylesheet" type="text/css" href="styles/chatbox/aa.css?v=1.0.1" id="chatbox_theme">
<link rel="stylesheet" type="text/css" href="styles/nameplates.css" id="nameplate_setting">
+ <link rel="stylesheet" type="text/css" href="" id="effect_css">
<link type="text/css" rel="stylesheet" href="golden/css/goldenlayout.css" />
<link type="text/css" rel="stylesheet"
href="https://golden-layout.com/files/latest/css/goldenlayout-dark-theme.css" />
-
-
<script src="lib/jdataview.min.js"></script>
</head>
diff --git a/webAO/client.ts b/webAO/client.ts
index 5cee9bf..c0ea5a0 100644
--- a/webAO/client.ts
+++ b/webAO/client.ts
@@ -8,7 +8,6 @@ import FingerprintJS from "@fingerprintjs/fingerprintjs";
import { EventEmitter } from "events";
import tryUrls from "./utils/tryUrls";
import { escapeChat, prepChat, safeTags, unescapeChat } from "./encoding";
-import mlConfig from "./utils/aoml";
// Load some defaults for the background and evidence dropdowns
import vanilla_character_arr from "./constants/characters.js";
import vanilla_music_arr from "./constants/music.js";
@@ -25,38 +24,23 @@ import {
changeSFXVolume,
changeTestimonyVolume,
} from "./dom/changeVolume.js";
-import setEmote from "./client/setEmote.js";
import fileExists from "./utils/fileExists.js";
import queryParser from "./utils/queryParser.js";
-import getAnimLength from "./utils/getAnimLength.js";
import getResources from "./utils/getResources.js";
import transparentPng from "./constants/transparentPng";
import downloadFile from "./services/downloadFile";
import { getFilenameFromPath } from "./utils/paths";
const version = process.env.npm_package_version;
import masterViewport, { Viewport } from "./viewport";
+import { handleMS } from './packets/handlers/handleMS';
-interface Testimony {
- [key: number]: string;
-}
-
-// Get the arguments from the URL bar
-interface QueryParams {
- ip: string;
- serverIP: string;
- mode: string;
- asset: string;
- theme: string;
-}
-let { ip: serverIP, mode, asset, theme } = queryParser() as QueryParams;
+let { ip: serverIP, mode, asset, theme } = queryParser() ;
// Unless there is an asset URL specified, use the wasabi one
const DEFAULT_HOST = "http://attorneyoffline.de/base/";
export let AO_HOST = asset || DEFAULT_HOST;
const THEME = theme || "default";
-let client: Client;
-
-const attorneyMarkdown = mlConfig(AO_HOST);
+export let client: Client;
export const UPDATE_INTERVAL = 60;
@@ -71,7 +55,7 @@ let oldLoading = false;
let selectedMenu = 1;
let selectedShout = 0;
-let extrafeatures: string[] = [];
+export let extrafeatures: string[] = [];
let banned: boolean = false;
let hdid: string;
@@ -220,14 +204,14 @@ class Client extends EventEmitter {
this.selectedEmote = -1;
this.selectedEvidence = 0;
-
+
this.checkUpdater = null;
this.viewport = masterViewport(this);
/**
* Assign handlers for all commands
* If you implement a new command, you need to add it here
*/
- this.on("MS", this.handleMS.bind(this));
+ this.on("MS", handleMS);
this.on("CT", this.handleCT.bind(this));
this.on("MC", this.handleMC.bind(this));
this.on("RMC", this.handleRMC.bind(this));
@@ -516,9 +500,7 @@ class Client extends EventEmitter {
* @param {string} testimony type
*/
sendRT(testimony: string) {
- if (this.chars[this.charID].side === "jud") {
- this.sendServer(`RT#${testimony}#%`);
- }
+ this.sendServer(`RT#${testimony}#%`);
}
/**
@@ -756,163 +738,7 @@ class Client extends EventEmitter {
(<HTMLInputElement>document.getElementById("client_inputbox")).value = "";
};
- /**
- * Handles an in-character chat message.
- * @param {*} args packet arguments
- */
- handleMS(args: string[]) {
- // TODO: this if-statement might be a bug.
- if (args[4] !== this.viewport.chatmsg.content) {
- document.getElementById("client_inner_chat").innerHTML = "";
-
- const char_id = Number(args[9]);
- const char_name = safeTags(args[3]);
-
- let msg_nameplate = args[3];
- let msg_blips = "male";
- let char_chatbox = "default";
- let char_muted = false;
-
- if (this.chars[char_id].name !== char_name) {
- console.info(
- `${this.chars[char_id].name} is iniediting to ${char_name}`
- );
- const chargs = (`${char_name}&` + "iniediter").split("&");
- this.handleCharacterInfo(chargs, char_id);
- }
-
- try {
- msg_nameplate = this.chars[char_id].showname;
- } catch (e) {
- msg_nameplate = args[3];
- }
-
- try {
- msg_blips = this.chars[char_id].blips;
- } catch (e) {}
-
- try {
- char_chatbox = this.chars[char_id].chat;
- } catch (e) {
- char_chatbox = "default";
- }
-
- try {
- char_muted = this.chars[char_id].muted;
- } catch (e) {
- char_muted = false;
- console.error("we're still missing some character data");
- }
-
- if (char_muted === false) {
- let chatmsg = {
- deskmod: safeTags(args[1]).toLowerCase(),
- preanim: safeTags(args[2]).toLowerCase(), // get preanim
- nameplate: msg_nameplate,
- chatbox: char_chatbox,
- name: char_name,
- sprite: safeTags(args[4]).toLowerCase(),
- content: prepChat(args[5]), // Escape HTML tags
- side: args[6].toLowerCase(),
- sound: safeTags(args[7]).toLowerCase(),
- blips: safeTags(msg_blips),
- type: Number(args[8]),
- charid: char_id,
- snddelay: Number(args[10]),
- objection: Number(args[11]),
- evidence: safeTags(args[12]),
- flip: Number(args[13]),
- flash: Number(args[14]),
- color: Number(args[15]),
- speed: UPDATE_INTERVAL,
- };
-
- if (extrafeatures.includes("cccc_ic_support")) {
- const extra_cccc = {
- showname: safeTags(args[16]),
- other_charid: Number(args[17]),
- other_name: safeTags(args[18]),
- other_emote: safeTags(args[19]),
- self_offset: args[20].split("<and>"), // HACK: here as well, client is fucked and uses this instead of &
- other_offset: args[21].split("<and>"),
- other_flip: Number(args[22]),
- noninterrupting_preanim: Number(args[23]),
- };
- 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: safeTags(args[26]),
- frame_realization: safeTags(args[27]),
- frame_sfx: safeTags(args[28]),
- };
- chatmsg = Object.assign(extra_27, chatmsg);
-
- if (extrafeatures.includes("effects")) {
- const extra_28 = {
- additive: Number(args[29]),
- effects: args[30].split("|"),
- };
- chatmsg = Object.assign(extra_28, chatmsg);
- } else {
- const extra_28 = {
- additive: 0,
- effects: ["", "", ""],
- };
- chatmsg = Object.assign(extra_28, chatmsg);
- }
- } else {
- const extra_27 = {
- looping_sfx: 0,
- screenshake: 0,
- frame_screenshake: "",
- frame_realization: "",
- frame_sfx: "",
- };
- chatmsg = Object.assign(extra_27, chatmsg);
- const extra_28 = {
- additive: 0,
- effects: ["", "", ""],
- };
- chatmsg = Object.assign(extra_28, chatmsg);
- }
- } else {
- const extra_cccc = {
- showname: "",
- other_charid: 0,
- other_name: "",
- other_emote: "",
- self_offset: [0, 0],
- other_offset: [0, 0],
- other_flip: 0,
- noninterrupting_preanim: 0,
- };
- chatmsg = Object.assign(extra_cccc, chatmsg);
- const extra_27 = {
- looping_sfx: 0,
- screenshake: 0,
- frame_screenshake: "",
- frame_realization: "",
- frame_sfx: "",
- };
- chatmsg = Object.assign(extra_27, chatmsg);
- const extra_28 = {
- additive: 0,
- effects: ["", "", ""],
- };
- chatmsg = Object.assign(extra_28, chatmsg);
- }
- // our own message appeared, reset the buttons
- if (chatmsg.charid === this.charID) {
- resetICParams();
- }
- this.viewport.handle_ic_speaking(chatmsg); // no await
- }
- }
- }
/**
* Handles an out-of-character chat message.
@@ -1996,16 +1822,16 @@ class Client extends EventEmitter {
* position change
* @param {string} pos new position
*/
- handleSP(pos: string) {
- updateActionCommands(pos);
+ handleSP(args: string[]) {
+ updateActionCommands(args[1]);
}
/**
* show/hide judge controls
* @param {number} show either a 1 or a 0
*/
- handleJD(show: number) {
- if (show === 1) {
+ handleJD(args: string[]) {
+ if (Number(args[1]) === 1) {
document.getElementById("judge_action").style.display = "inline-table";
document.getElementById("no_action").style.display = "none";
} else {
@@ -2176,7 +2002,7 @@ window.onEnter = onEnter;
* This should only be called when the player's previous chat message
* was successfully sent/presented.
*/
-function resetICParams() {
+export function resetICParams() {
(<HTMLInputElement>document.getElementById("client_inputbox")).value = "";
document.getElementById("button_flash").className = "client_button";
document.getElementById("button_shake").className = "client_button";
@@ -3010,4 +2836,5 @@ export function toggleShout(shout: number) {
}
}
window.toggleShout = toggleShout;
+
export default Client;
diff --git a/webAO/client/setEmote.ts b/webAO/client/setEmote.ts
index 1f0de07..161eb51 100644
--- a/webAO/client/setEmote.ts
+++ b/webAO/client/setEmote.ts
@@ -23,7 +23,7 @@ const setEmote = async (
const emoteSelector = document.getElementById(
`client_${position}${pairID}_img`
) as HTMLImageElement;
- const extensionsMap = [".gif", ".png", ".apng", ".webp"];
+ const extensionsMap = [".gif", ".png", ".apng", ".webp", ".webp.static"];
for (const extension of extensionsMap) {
// Hides all sprites before creating a new sprite
@@ -36,6 +36,10 @@ const setEmote = async (
url = `${characterFolder}${encodeURI(charactername)}/${encodeURI(
emotename
)}${extension}`;
+ } else if (extension === ".webp.static") {
+ url = `${characterFolder}${encodeURI(charactername)}/${encodeURI(
+ emotename
+ )}.webp`;
} else {
url = `${characterFolder}${encodeURI(charactername)}/${encodeURI(
prefix
diff --git a/webAO/packets/handlers/handleMS.ts b/webAO/packets/handlers/handleMS.ts
new file mode 100644
index 0000000..0aad19a
--- /dev/null
+++ b/webAO/packets/handlers/handleMS.ts
@@ -0,0 +1,162 @@
+import { client, extrafeatures, resetICParams, UPDATE_INTERVAL } from "../../client";
+import { prepChat, safeTags } from "../../encoding";
+
+/**
+ * Handles an in-character chat message.
+ * @param {*} args packet arguments
+ */
+export const handleMS = (args: string[]) => {
+ // TODO: this if-statement might be a bug.
+ if (args[4] !== client.viewport.chatmsg.content) {
+ document.getElementById("client_inner_chat")!.innerHTML = "";
+
+ const char_id = Number(args[9]);
+ const char_name = safeTags(args[3]);
+
+ let msg_nameplate = args[3];
+ let msg_blips = "male";
+ let char_chatbox = "default";
+ let char_muted = false;
+
+ if (char_id < client.char_list_length && char_id >= 0) {
+ if(client.chars[char_id].name !== char_name) {
+ console.info(
+ `${client.chars[char_id].name} is iniediting to ${char_name}`
+ );
+ const chargs = (`${char_name}&` + "iniediter").split("&");
+ client.handleCharacterInfo(chargs, char_id);
+ }
+ }
+
+ try {
+ msg_nameplate = client.chars[char_id].showname;
+ } catch (e) {
+ msg_nameplate = args[3];
+ }
+
+ try {
+ msg_blips = client.chars[char_id].blips;
+ } catch (e) {}
+
+ try {
+ char_chatbox = client.chars[char_id].chat;
+ } catch (e) {
+ char_chatbox = "default";
+ }
+
+ try {
+ char_muted = client.chars[char_id].muted;
+ } catch (e) {
+ char_muted = false;
+ console.error("we're still missing some character data");
+ }
+
+ if (char_muted === false) {
+ let chatmsg = {
+ deskmod: safeTags(args[1]).toLowerCase(),
+ preanim: safeTags(args[2]).toLowerCase(), // get preanim
+ nameplate: msg_nameplate,
+ chatbox: char_chatbox,
+ name: char_name,
+ sprite: safeTags(args[4]).toLowerCase(),
+ content: prepChat(args[5]), // Escape HTML tags
+ side: args[6].toLowerCase(),
+ sound: safeTags(args[7]).toLowerCase(),
+ blips: safeTags(msg_blips),
+ type: Number(args[8]),
+ charid: char_id,
+ snddelay: Number(args[10]),
+ objection: Number(args[11]),
+ evidence: safeTags(args[12]),
+ flip: Number(args[13]),
+ flash: Number(args[14]),
+ color: Number(args[15]),
+ speed: UPDATE_INTERVAL,
+ };
+
+ if (extrafeatures.includes("cccc_ic_support")) {
+ const extra_cccc = {
+ showname: safeTags(args[16]),
+ other_charid: Number(args[17]),
+ other_name: safeTags(args[18]),
+ other_emote: safeTags(args[19]),
+ self_offset: args[20].split("<and>"), // HACK: here as well, client is fucked and uses this instead of &
+ other_offset: args[21].split("<and>"),
+ other_flip: Number(args[22]),
+ noninterrupting_preanim: Number(args[23]),
+ };
+ 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: safeTags(args[26]),
+ frame_realization: safeTags(args[27]),
+ frame_sfx: safeTags(args[28]),
+ };
+ chatmsg = Object.assign(extra_27, chatmsg);
+
+ if (extrafeatures.includes("effects")) {
+ const extra_28 = {
+ additive: Number(args[29]),
+ effects: args[30].split("|"),
+ };
+ chatmsg = Object.assign(extra_28, chatmsg);
+ } else {
+ const extra_28 = {
+ additive: 0,
+ effects: ["", "", ""],
+ };
+ chatmsg = Object.assign(extra_28, chatmsg);
+ }
+ } else {
+ const extra_27 = {
+ looping_sfx: 0,
+ screenshake: 0,
+ frame_screenshake: "",
+ frame_realization: "",
+ frame_sfx: "",
+ };
+ chatmsg = Object.assign(extra_27, chatmsg);
+ const extra_28 = {
+ additive: 0,
+ effects: ["", "", ""],
+ };
+ chatmsg = Object.assign(extra_28, chatmsg);
+ }
+ } else {
+ const extra_cccc = {
+ showname: "",
+ other_charid: 0,
+ other_name: "",
+ other_emote: "",
+ self_offset: [0, 0],
+ other_offset: [0, 0],
+ other_flip: 0,
+ noninterrupting_preanim: 0,
+ };
+ chatmsg = Object.assign(extra_cccc, chatmsg);
+ const extra_27 = {
+ looping_sfx: 0,
+ screenshake: 0,
+ frame_screenshake: "",
+ frame_realization: "",
+ frame_sfx: "",
+ };
+ chatmsg = Object.assign(extra_27, chatmsg);
+ const extra_28 = {
+ additive: 0,
+ effects: ["", "", ""],
+ };
+ chatmsg = Object.assign(extra_28, chatmsg);
+ }
+
+ // our own message appeared, reset the buttons
+ if (chatmsg.charid === client.charID) {
+ resetICParams();
+ }
+ client.viewport.handle_ic_speaking(chatmsg); // no await
+ }
+ }
+ } \ No newline at end of file
diff --git a/webAO/utils/queryParser.ts b/webAO/utils/queryParser.ts
new file mode 100644
index 0000000..3110c14
--- /dev/null
+++ b/webAO/utils/queryParser.ts
@@ -0,0 +1,22 @@
+interface QueryParams {
+ ip: string;
+ serverIP: string;
+ mode: string;
+ asset: string;
+ theme: string;
+}
+interface StringMap {
+ [key: string]: any;
+}
+
+const queryParser = (): QueryParams => {
+ const queryDict: StringMap = {};
+ location.search
+ .substr(1)
+ .split("&")
+ .forEach((item) => {
+ queryDict[item.split("=")[0]] = item.split("=")[1];
+ });
+ return queryDict as QueryParams;
+};
+export default queryParser;