diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-09-03 02:13:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-03 02:13:01 +0200 |
| commit | 20d53ae3a37622805d08e02d3b38175fea0084e2 (patch) | |
| tree | 98bfddeee34500bb98169de405abf4a1cf114f8c /webAO/packets | |
| parent | b87c498ee3e5fb1e6e90084fc093a66abaa311c6 (diff) | |
| parent | 86b493b881bde4a11214929ebe4317289a7f1da3 (diff) | |
Merge pull request #162 from caleb-mabry/last-of-the-handlers
Moved rest of the handlers
Diffstat (limited to 'webAO/packets')
| -rw-r--r-- | webAO/packets/handlers/handleASS.ts | 10 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleCharsCheck.ts | 17 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleJD.ts | 13 | ||||
| -rw-r--r-- | webAO/packets/handlers/handlePV.ts | 82 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleRD.ts | 18 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleRM.ts | 10 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleSP.ts | 9 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleackMS.ts | 8 |
8 files changed, 167 insertions, 0 deletions
diff --git a/webAO/packets/handlers/handleASS.ts b/webAO/packets/handlers/handleASS.ts new file mode 100644 index 0000000..d0dfbd5 --- /dev/null +++ b/webAO/packets/handlers/handleASS.ts @@ -0,0 +1,10 @@ +import { setAOhost } from "../../client"; + + +/** +* new asset url!! +* @param {Array} args packet arguments +*/ +export const handleASS = (args: string[]) => { + setAOhost(args[1]); +} diff --git a/webAO/packets/handlers/handleCharsCheck.ts b/webAO/packets/handlers/handleCharsCheck.ts new file mode 100644 index 0000000..2d891ef --- /dev/null +++ b/webAO/packets/handlers/handleCharsCheck.ts @@ -0,0 +1,17 @@ +import { client } from "../../client"; + +/** + * Handles the list of all used and vacant characters. + * @param {Array} args list of all characters represented as a 0 for free or a -1 for taken + */ +export const handleCharsCheck = (args: string[]) => { + for (let i = 0; i < client.char_list_length; i++) { + const img = document.getElementById(`demo_${i}`)!; + + if (args[i + 1] === "-1") { + img.style.opacity = "0.25"; + } else if (args[i + 1] === "0") { + img.style.opacity = "1"; + } + } +}
\ No newline at end of file diff --git a/webAO/packets/handlers/handleJD.ts b/webAO/packets/handlers/handleJD.ts new file mode 100644 index 0000000..98d7988 --- /dev/null +++ b/webAO/packets/handlers/handleJD.ts @@ -0,0 +1,13 @@ +/** +* show/hide judge controls +* @param {number} show either a 1 or a 0 +*/ +export const handleJD = (args: string[]) => { + if (Number(args[1]) === 1) { + document.getElementById("judge_action")!.style.display = "inline-table"; + document.getElementById("no_action")!.style.display = "none"; + } else { + document.getElementById("judge_action")!.style.display = "none"; + document.getElementById("no_action")!.style.display = "inline-table"; + } +}
\ No newline at end of file diff --git a/webAO/packets/handlers/handlePV.ts b/webAO/packets/handlers/handlePV.ts new file mode 100644 index 0000000..18947c5 --- /dev/null +++ b/webAO/packets/handlers/handlePV.ts @@ -0,0 +1,82 @@ +import { AO_HOST, client, pickEmotion, updateActionCommands } from "../../client"; +import fileExists from "../../utils/fileExists"; + + + /** + * Handles the server's assignment of a character for the player to use. + * PV # playerID (unused) # CID # character ID + * @param {Array} args packet arguments + */ +export const handlePV = async (args: string[]) => { + client.charID = Number(args[3]); + document.getElementById("client_waiting")!.style.display = "none"; + document.getElementById("client_charselect")!.style.display = "none"; + + const me = client.chars[client.charID]; + client.selectedEmote = -1; + const { emotes } = client; + const emotesList = document.getElementById("client_emo")!; + emotesList.style.display = ""; + emotesList.innerHTML = ""; // Clear emote box + const ini = me.inifile; + me.side = ini.options.side; + updateActionCommands(me.side); + if (ini.emotions.number === 0) { + emotesList.innerHTML = `<span + id="emo_0" + alt="unavailable" + class="emote_button">No emotes available</span>`; + } else { + for (let i = 1; i <= ini.emotions.number; i++) { + try { + const emoteinfo = ini.emotions[i].split("#"); + let esfx; + let esfxd; + try { + esfx = ini.soundn[i] || "0"; + esfxd = Number(ini.soundt[i]) || 0; + } catch (e) { + console.warn("ini sound is completly missing"); + esfx = "0"; + esfxd = 0; + } + // Make sure the asset server is case insensitive, or that everything on it is lowercase + + emotes[i] = { + desc: emoteinfo[0].toLowerCase(), + preanim: emoteinfo[1].toLowerCase(), + emote: emoteinfo[2].toLowerCase(), + zoom: Number(emoteinfo[3]) || 0, + deskmod: Number(emoteinfo[4]) || 1, + sfx: esfx.toLowerCase(), + sfxdelay: esfxd, + frame_screenshake: "", + frame_realization: "", + frame_sfx: "", + button: `${AO_HOST}characters/${encodeURI( + me.name.toLowerCase() + )}/emotions/button${i}_off.png`, + }; + emotesList.innerHTML += `<img src=${emotes[i].button} + id="emo_${i}" + alt="${emotes[i].desc}" + class="emote_button" + onclick="pickEmotion(${i})">`; + } catch (e) { + console.error(`missing emote ${i}`); + } + } + pickEmotion(1); + } + + if ( + await fileExists( + `${AO_HOST}characters/${encodeURI(me.name.toLowerCase())}/custom.gif` + ) + ) { + document.getElementById("button_4")!.style.display = ""; + } else { + document.getElementById("button_4")!.style.display = "none"; + } + + } diff --git a/webAO/packets/handlers/handleRD.ts b/webAO/packets/handlers/handleRD.ts new file mode 100644 index 0000000..780b43f --- /dev/null +++ b/webAO/packets/handlers/handleRD.ts @@ -0,0 +1,18 @@ +import { client } from "../../client"; + + +/** + * we are asking ourselves what characters there are + * @param {Array} args packet arguments + */ +export const handleRD = (_args: string[]) => { + client.sendSelf("BN#gs4#%"); + client.sendSelf("DONE#%"); + const ooclog = <HTMLInputElement>document.getElementById("client_ooclog"); + ooclog.value = ""; + ooclog.readOnly = false; + + document.getElementById("client_oocinput")!.style.display = "none"; + document.getElementById("client_replaycontrols")!.style.display = + "inline-block"; +}
\ No newline at end of file diff --git a/webAO/packets/handlers/handleRM.ts b/webAO/packets/handlers/handleRM.ts new file mode 100644 index 0000000..41a78b4 --- /dev/null +++ b/webAO/packets/handlers/handleRM.ts @@ -0,0 +1,10 @@ +import {client} from '../../client' +import vanilla_music_arr from "../../constants/music.js"; + + /** + * we are asking ourselves what characters there are + * @param {Array} args packet arguments + */ +export const handleRM = (_args: string[]) => { + client.sendSelf(`SM#${vanilla_music_arr.join("#")}#%`); + }
\ No newline at end of file diff --git a/webAO/packets/handlers/handleSP.ts b/webAO/packets/handlers/handleSP.ts new file mode 100644 index 0000000..e2cad18 --- /dev/null +++ b/webAO/packets/handlers/handleSP.ts @@ -0,0 +1,9 @@ +import { updateActionCommands } from "../../client"; + +/** +* position change +* @param {string} pos new position +*/ +export const handleSP = (args: string[]) => { + updateActionCommands(args[1]); +}
\ No newline at end of file diff --git a/webAO/packets/handlers/handleackMS.ts b/webAO/packets/handlers/handleackMS.ts new file mode 100644 index 0000000..2b971b0 --- /dev/null +++ b/webAO/packets/handlers/handleackMS.ts @@ -0,0 +1,8 @@ +import { resetICParams } from "../../client"; + +/** +* server got our message +*/ +export const handleackMS = () => { + resetICParams(); +}
\ No newline at end of file |
