MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / loadSettings

Method loadSettings

data/src/emulator.js:4208–4251  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4206 return "";
4207 }
4208 loadSettings() {
4209 if (!window.localStorage || this.config.disableLocalStorage) return;
4210 this.settingsLoaded = true;
4211 let ejs_settings = localStorage.getItem("ejs-settings");
4212 let coreSpecific = localStorage.getItem(this.getLocalStorageKey());
4213 if (coreSpecific) {
4214 try {
4215 coreSpecific = JSON.parse(coreSpecific);
4216 if (!(coreSpecific.controlSettings instanceof Object) || !(coreSpecific.settings instanceof Object) || !Array.isArray(coreSpecific.cheats)) return;
4217 this.controls = coreSpecific.controlSettings;
4218 this.checkGamepadInputs();
4219 for (const k in coreSpecific.settings) {
4220 this.changeSettingOption(k, coreSpecific.settings[k]);
4221 }
4222 for (let i = 0; i < coreSpecific.cheats.length; i++) {
4223 const cheat = coreSpecific.cheats[i];
4224 let includes = false;
4225 for (let j = 0; j < this.cheats.length; j++) {
4226 if (this.cheats[j].desc === cheat.desc && this.cheats[j].code === cheat.code) {
4227 this.cheats[j].checked = cheat.checked;
4228 includes = true;
4229 break;
4230 }
4231 }
4232 if (includes) continue;
4233 this.cheats.push(cheat);
4234 }
4235
4236 } catch(e) {
4237 console.warn("Could not load previous settings", e);
4238 }
4239 }
4240 if (ejs_settings) {
4241 try {
4242 ejs_settings = JSON.parse(ejs_settings);
4243 if (typeof ejs_settings.volume !== "number" || typeof ejs_settings.muted !== "boolean") return;
4244 this.volume = ejs_settings.volume;
4245 this.muted = ejs_settings.muted;
4246 this.setVolume(this.muted ? 0 : this.volume);
4247 } catch(e) {
4248 console.warn("Could not load previous settings", e);
4249 }
4250 }
4251 }
4252 handleSpecialOptions(option, value) {
4253 if (option === "shader") {
4254 this.enableShader(value);

Callers 2

startGameErrorMethod · 0.95
startGameMethod · 0.95

Calls 1

getLocalStorageKeyMethod · 0.95

Tested by

no test coverage detected