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

Method getCoreSettings

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

Source from the content-addressed store, hash-verified

4172 return null;
4173 }
4174 getCoreSettings() {
4175 if (!window.localStorage || this.config.disableLocalStorage) {
4176 if (this.config.defaultOptions) {
4177 let rv = "";
4178 for (const k in this.config.defaultOptions) {
4179 let value = isNaN(this.config.defaultOptions[k]) ? `"${this.config.defaultOptions[k]}"` : this.config.defaultOptions[k];
4180 rv += `${k} = ${value}\n`;
4181 }
4182 return rv;
4183 }
4184 return "";
4185 };
4186 let coreSpecific = localStorage.getItem(this.getLocalStorageKey());
4187 if (coreSpecific) {
4188 try {
4189 coreSpecific = JSON.parse(coreSpecific);
4190 if (!(coreSpecific.settings instanceof Object)) throw new Error("Not a JSON object");
4191 let rv = "";
4192 for (const k in coreSpecific.settings) {
4193 let value = isNaN(coreSpecific.settings[k]) ? `"${coreSpecific.settings[k]}"` : coreSpecific.settings[k];
4194 rv += `${k} = ${value}\n`;
4195 }
4196 for (const k in this.config.defaultOptions) {
4197 if (rv.includes(k)) continue;
4198 let value = isNaN(this.config.defaultOptions[k]) ? `"${this.config.defaultOptions[k]}"` : this.config.defaultOptions[k];
4199 rv += `${k} = ${value}\n`;
4200 }
4201 return rv;
4202 } catch(e) {
4203 console.warn("Could not load previous settings", e);
4204 }
4205 }
4206 return "";
4207 }
4208 loadSettings() {
4209 if (!window.localStorage || this.config.disableLocalStorage) return;
4210 this.settingsLoaded = true;

Callers 1

setupPreLoadSettingsMethod · 0.80

Calls 1

getLocalStorageKeyMethod · 0.95

Tested by

no test coverage detected