diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-08-30 23:42:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-30 23:42:08 +0200 |
| commit | fd76aa9ea07c937e92d5f9f65b58c6f16957ce55 (patch) | |
| tree | 2e53b0401f8c52a0f4dfd0604f4d11ed97b3a87f /webAO/packets/handlers | |
| parent | f07d77c3d40b2ebf5da0f3399e31f6741c60024e (diff) | |
| parent | c95c943938b2254bdb9581fc4b00e72d15e91436 (diff) | |
Merge pull request #158 from caleb-mabry/another-another
More packets moved
Diffstat (limited to 'webAO/packets/handlers')
| -rw-r--r-- | webAO/packets/handlers/handleFA.ts | 14 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleFL.ts | 88 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleFM.ts | 16 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleSM.ts | 36 |
4 files changed, 110 insertions, 44 deletions
diff --git a/webAO/packets/handlers/handleFA.ts b/webAO/packets/handlers/handleFA.ts new file mode 100644 index 0000000..ccfe923 --- /dev/null +++ b/webAO/packets/handlers/handleFA.ts @@ -0,0 +1,14 @@ +import { client } from '../../client' +import { safeTags } from '../../encoding'; + +/** + * Handles updated area list + * @param {Array} args packet arguments + */ +export const handleFA = (args: string[]) => { + client.resetAreaList(); + + for (let i = 1; i < args.length - 1; i++) { + client.createArea(i - 1, safeTags(args[i])); + } +} diff --git a/webAO/packets/handlers/handleFL.ts b/webAO/packets/handlers/handleFL.ts index d9e67e5..378d5a9 100644 --- a/webAO/packets/handlers/handleFL.ts +++ b/webAO/packets/handlers/handleFL.ts @@ -1,48 +1,48 @@ import { setExtraFeatures } from "../../client"; - - /** - * With this the server tells us which features it supports - * @param {Array} args list of features - */ + +/** + * With this the server tells us which features it supports + * @param {Array} args list of features + */ export const handleFL = (args: string[]) => { - console.info("Server-supported features:"); - console.info(args); - setExtraFeatures(args); - - if (args.includes("yellowtext")) { - const colorselect = <HTMLSelectElement>( - document.getElementById("textcolor") - ); - - colorselect.options[colorselect.options.length] = new Option( - "Yellow", - "5" - ); - colorselect.options[colorselect.options.length] = new Option("Grey", "6"); - colorselect.options[colorselect.options.length] = new Option("Pink", "7"); - colorselect.options[colorselect.options.length] = new Option("Cyan", "8"); - } - - if (args.includes("cccc_ic_support")) { - document.getElementById("cccc")!.style.display = ""; - document.getElementById("pairing")!.style.display = ""; - } - - if (args.includes("flipping")) { - document.getElementById("button_flip")!.style.display = ""; - } - - if (args.includes("looping_sfx")) { - document.getElementById("button_shake")!.style.display = ""; - document.getElementById("2.7")!.style.display = ""; - } - - if (args.includes("effects")) { - document.getElementById("2.8")!.style.display = ""; - } - - if (args.includes("y_offset")) { - document.getElementById("y_offset")!.style.display = ""; - } + console.info("Server-supported features:"); + console.info(args); + setExtraFeatures(args); + + if (args.includes("yellowtext")) { + const colorselect = <HTMLSelectElement>( + document.getElementById("textcolor") + ); + + colorselect.options[colorselect.options.length] = new Option( + "Yellow", + "5" + ); + colorselect.options[colorselect.options.length] = new Option("Grey", "6"); + colorselect.options[colorselect.options.length] = new Option("Pink", "7"); + colorselect.options[colorselect.options.length] = new Option("Cyan", "8"); + } + + if (args.includes("cccc_ic_support")) { + document.getElementById("cccc")!.style.display = ""; + document.getElementById("pairing")!.style.display = ""; + } + + if (args.includes("flipping")) { + document.getElementById("button_flip")!.style.display = ""; + } + + if (args.includes("looping_sfx")) { + document.getElementById("button_shake")!.style.display = ""; + document.getElementById("2.7")!.style.display = ""; + } + + if (args.includes("effects")) { + document.getElementById("2.8")!.style.display = ""; + } + + if (args.includes("y_offset")) { + document.getElementById("y_offset")!.style.display = ""; } +} diff --git a/webAO/packets/handlers/handleFM.ts b/webAO/packets/handlers/handleFM.ts new file mode 100644 index 0000000..630477b --- /dev/null +++ b/webAO/packets/handlers/handleFM.ts @@ -0,0 +1,16 @@ +import { client } from "../../client"; +import { safeTags } from "../../encoding"; + + +/** + * Handles updated music list + * @param {Array} args packet arguments + */ +export const handleFM = (args: string[]) => { + client.resetMusicList(); + + for (let i = 1; i < args.length - 1; i++) { + // Check when found the song for the first time + client.addTrack(safeTags(args[i])); + } +} diff --git a/webAO/packets/handlers/handleSM.ts b/webAO/packets/handlers/handleSM.ts new file mode 100644 index 0000000..5dab83e --- /dev/null +++ b/webAO/packets/handlers/handleSM.ts @@ -0,0 +1,36 @@ +import { client } from '../../client' +/** + * Handles incoming music information, containing all music in one packet. + * @param {Array} args packet arguments + */ +export const handleSM = (args: string[]) => { + document.getElementById("client_loadingtext")!.innerHTML = "Loading Music "; + client.resetMusicList(); + client.resetAreaList(); + + client.musics_time = false; + + for (let i = 1; i < args.length - 1; i++) { + // Check when found the song for the first time + const trackname = args[i]; + const trackindex = i - 1; + document.getElementById( + "client_loadingtext" + )!.innerHTML = `Loading Music ${i}/${client.music_list_length}`; + (<HTMLProgressElement>( + document.getElementById("client_loadingbar") + )).value = client.char_list_length + client.evidence_list_length + i; + if (client.musics_time) { + client.addTrack(trackname); + } else if (client.isAudio(trackname)) { + client.musics_time = true; + client.fix_last_area(); + client.addTrack(trackname); + } else { + client.createArea(trackindex, trackname); + } + } + + // Music done, carry on + client.sendServer("RD#%"); +} |
