diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-09-10 14:12:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-10 14:12:53 +0200 |
| commit | abba7630e13f7e5269c14c2c43b66b03559ddfe3 (patch) | |
| tree | 4770a2375d594ef080aa4ad8262aa2df42831c26 /webAO/client/loadResources.ts | |
| parent | 09a23ea9d7ee37d8e2dfb036786c41ce37496c51 (diff) | |
| parent | 93979636fb5d1c60f0da3290e80eb3ca9ead992f (diff) | |
Merge pull request #173 from caleb-mabry/trying-to-minimize
Client at 297 lines
Diffstat (limited to 'webAO/client/loadResources.ts')
| -rw-r--r-- | webAO/client/loadResources.ts | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/webAO/client/loadResources.ts b/webAO/client/loadResources.ts new file mode 100644 index 0000000..7039333 --- /dev/null +++ b/webAO/client/loadResources.ts @@ -0,0 +1,79 @@ +import getCookie from "../utils/getCookie"; +import vanilla_evidence_arr from "../constants/evidence.js"; +import vanilla_background_arr from "../constants/backgrounds.js"; +import { client } from "../client"; +import { setChatbox } from "../dom/setChatbox"; +import { changeSFXVolume, changeShoutVolume, changeTestimonyVolume } from "../dom/changeVolume"; +import { showname_click } from "../dom/showNameClick"; + +const version = process.env.npm_package_version; +/** + * Load game resources and stored settings. + */ +export const loadResources = () => { + document.getElementById("client_version")!.innerText = `version ${version}`; + // Load background array to select + const background_select = <HTMLSelectElement>( + document.getElementById("bg_select") + ); + background_select.add(new Option("Custom", "0")); + vanilla_background_arr.forEach((background) => { + background_select.add(new Option(background)); + }); + + // Load evidence array to select + const evidence_select = <HTMLSelectElement>( + document.getElementById("evi_select") + ); + evidence_select.add(new Option("Custom", "0")); + vanilla_evidence_arr.forEach((evidence) => { + evidence_select.add(new Option(evidence)); + }); + + // Read cookies and set the UI to its values + (<HTMLInputElement>document.getElementById("OOC_name")).value = + getCookie("OOC_name") || + `web${String(Math.round(Math.random() * 100 + 10))}`; + + // Read cookies and set the UI to its values + const cookietheme = getCookie("theme") || "default"; + + (<HTMLOptionElement>( + document.querySelector(`#client_themeselect [value="${cookietheme}"]`) + )).selected = true; + client.viewport.reloadTheme(); + + const cookiechatbox = getCookie("chatbox") || "dynamic"; + + (<HTMLOptionElement>( + document.querySelector(`#client_chatboxselect [value="${cookiechatbox}"]`) + )).selected = true; + setChatbox(cookiechatbox); + + (<HTMLInputElement>document.getElementById("client_mvolume")).value = + getCookie("musicVolume") || "1"; + client.viewport.changeMusicVolume(); + (<HTMLAudioElement>document.getElementById("client_sfxaudio")).volume = + Number(getCookie("sfxVolume")) || 1; + changeSFXVolume(); + (<HTMLAudioElement>document.getElementById("client_shoutaudio")).volume = + Number(getCookie("shoutVolume")) || 1; + changeShoutVolume(); + (<HTMLAudioElement>( + document.getElementById("client_testimonyaudio") + )).volume = Number(getCookie("testimonyVolume")) || 1; + changeTestimonyVolume(); + (<HTMLInputElement>document.getElementById("client_bvolume")).value = + getCookie("blipVolume") || "1"; + client.viewport.changeBlipVolume(); + + (<HTMLInputElement>document.getElementById("ic_chat_name")).value = + getCookie("ic_chat_name"); + (<HTMLInputElement>document.getElementById("showname")).checked = Boolean( + getCookie("showname") + ); + showname_click(null); + + (<HTMLInputElement>document.getElementById("client_callwords")).value = + getCookie("callwords"); +}
\ No newline at end of file |
