Compare commits

..

2 commits

Author SHA1 Message Date
f7fa56757b Remove usage of replaceAll
Some checks failed
Make Latest Folder On EmulatorJS CDN / run (push) Has been cancelled
2024-07-28 21:40:49 -05:00
605a271299 Pull core report file to get time last built 2024-07-27 15:23:40 -05:00

View file

@ -1,5 +1,4 @@
class EmulatorJS { class EmulatorJS {
version = 13; //Increase by 1 when cores are updated
getCore(generic) { getCore(generic) {
const core = this.config.system; const core = this.config.system;
if (generic) { if (generic) {
@ -597,7 +596,7 @@ class EmulatorJS {
} }
} }
versionAsInt(ver) { versionAsInt(ver) {
return parseInt(ver.replaceAll(".", "")); return parseInt(ver.split(".").join(""));
} }
checkCoreCompatibility(version) { checkCoreCompatibility(version) {
// Leave commented until next release - this is ready to go. // Leave commented until next release - this is ready to go.
@ -643,47 +642,53 @@ class EmulatorJS {
this.initGameCore(js, wasm, thread); this.initGameCore(js, wasm, thread);
}); });
} }
let legacy = (this.supportsWebgl2 && this.webgl2Enabled ? "" : "-legacy"); const report = "cores/reports/" + this.getCore() + ".json";
let filename = this.getCore()+(this.config.threads ? "-thread" : "")+legacy+"-wasm.data"; this.downloadFile(report, (rep) => {
this.storage.core.get(filename).then((result) => { if (rep === -1) {
if (result && result.version === this.version && !this.debug) { rep = {buildStart: Math.random() * 100};
}
let legacy = (this.supportsWebgl2 && this.webgl2Enabled ? "" : "-legacy");
let filename = this.getCore()+(this.config.threads ? "-thread" : "")+legacy+"-wasm.data";
this.storage.core.get(filename).then((result) => {
if (result && result.version === rep.buildStart && !this.debug) {
gotCore(result.data); gotCore(result.data);
return; return;
} }
let corePath = 'cores/'+filename; const corePath = 'cores/'+filename;
this.downloadFile(corePath, (res) => { this.downloadFile(corePath, (res) => {
if (res === -1) { if (res === -1) {
console.log("File not found, attemping to fetch from emulatorjs cdn"); console.log("File not found, attemping to fetch from emulatorjs cdn");
this.downloadFile("https://cdn.emulatorjs.org/stable/data/"+corePath, (res) => { this.downloadFile("https://cdn.emulatorjs.org/stable/data/"+corePath, (res) => {
if (res === -1) { if (res === -1) {
if (!this.supportsWebgl2) { if (!this.supportsWebgl2) {
this.textElem.innerText = this.localization('Outdated graphics driver'); this.textElem.innerText = this.localization('Outdated graphics driver');
} else { } else {
this.textElem.innerText = this.localization('Network Error'); this.textElem.innerText = this.localization('Network Error');
}
this.textElem.style.color = "red";
return;
} }
this.textElem.style.color = "red"; console.warn("File was not found locally, but was found on the emulatorjs cdn.\nIt is recommended to download the latest release from here: https://cdn.emulatorjs.org/releases/");
return; gotCore(res.data);
} this.storage.core.put(filename, {
console.warn("File was not found locally, but was found on the emulatorjs cdn.\nIt is recommended to download the latest release from here: https://cdn.emulatorjs.org/releases/"); version: rep.buildStart,
gotCore(res.data); data: res.data
this.storage.core.put(filename, { });
version: this.version, }, (progress) => {
data: res.data this.textElem.innerText = this.localization("Download Game Core") + progress;
}); }, true, {responseType: "arraybuffer", method: "GET"})
}, (progress) => { return;
this.textElem.innerText = this.localization("Download Game Core") + progress; }
}, true, {responseType: "arraybuffer", method: "GET"}) gotCore(res.data);
return; this.storage.core.put(filename, {
} version: rep.buildStart,
gotCore(res.data); data: res.data
this.storage.core.put(filename, { });
version: this.version, }, (progress) => {
data: res.data this.textElem.innerText = this.localization("Download Game Core") + progress;
}); }, false, {responseType: "arraybuffer", method: "GET"});
}, (progress) => { })
this.textElem.innerText = this.localization("Download Game Core") + progress; }, null, false, {responseType: "text", method: "GET"});
}, false, {responseType: "arraybuffer", method: "GET"});
})
} }
initGameCore(js, wasm, thread) { initGameCore(js, wasm, thread) {
this.initModule(wasm, thread); this.initModule(wasm, thread);
@ -3442,7 +3447,7 @@ class EmulatorJS {
const leftHandedMode = false; const leftHandedMode = false;
const blockCSS = 'height:31px;text-align:center;border:1px solid #ccc;border-radius:5px;line-height:31px;'; const blockCSS = 'height:31px;text-align:center;border:1px solid #ccc;border-radius:5px;line-height:31px;';
const controlSchemeCls = `cs_${this.getControlScheme()}`.replaceAll(/\s/g, '_'); const controlSchemeCls = `cs_${this.getControlScheme()}`.split(/\s/g).join('_');
for (let i=0; i<info.length; i++) { for (let i=0; i<info.length; i++) {
if (info[i].type !== 'button') continue; if (info[i].type !== 'button') continue;