()
| 522 | this.failedToStart = true; |
| 523 | } |
| 524 | downloadGameCore() { |
| 525 | this.textElem.innerText = this.localization("Download Game Core"); |
| 526 | if (!this.config.threads && this.requiresThreads(this.getCore())) { |
| 527 | this.startGameError(this.localization("Error for site owner") + "\n" + this.localization("Check console")); |
| 528 | console.warn("This core requires threads, but EJS_threads is not set!"); |
| 529 | return; |
| 530 | } |
| 531 | if (!this.supportsWebgl2 && this.requiresWebGL2(this.getCore())) { |
| 532 | this.startGameError(this.localization("Outdated graphics driver")); |
| 533 | return; |
| 534 | } |
| 535 | if (this.config.threads && typeof window.SharedArrayBuffer !== "function") { |
| 536 | this.startGameError(this.localization("Error for site owner") + "\n" + this.localization("Check console")); |
| 537 | console.warn("Threads is set to true, but the SharedArrayBuffer function is not exposed. Threads requires 2 headers to be set when sending you html page. See https://stackoverflow.com/a/68630724"); |
| 538 | return; |
| 539 | } |
| 540 | const gotCore = (data) => { |
| 541 | this.defaultCoreOpts = {}; |
| 542 | this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Core")).then((data) => { |
| 543 | let js, thread, wasm; |
| 544 | for (let k in data) { |
| 545 | if (k.endsWith(".wasm")) { |
| 546 | wasm = data[k]; |
| 547 | } else if (k.endsWith(".worker.js")) { |
| 548 | thread = data[k]; |
| 549 | } else if (k.endsWith(".js")) { |
| 550 | js = data[k]; |
| 551 | } else if (k === "build.json") { |
| 552 | this.checkCoreCompatibility(JSON.parse(new TextDecoder().decode(data[k]))); |
| 553 | } else if (k === "core.json") { |
| 554 | let core = JSON.parse(new TextDecoder().decode(data[k])); |
| 555 | this.extensions = core.extensions; |
| 556 | this.coreName = core.name; |
| 557 | this.repository = core.repo; |
| 558 | this.defaultCoreOpts = core.options; |
| 559 | this.enableMouseLock = core.options.supportsMouse; |
| 560 | this.retroarchOpts = core.retroarchOpts; |
| 561 | this.saveFileExt = core.save; |
| 562 | } else if (k === "license.txt") { |
| 563 | this.license = new TextDecoder().decode(data[k]); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | if (this.saveFileExt === false) { |
| 568 | this.elements.bottomBar.saveSavFiles[0].style.display = "none"; |
| 569 | this.elements.bottomBar.loadSavFiles[0].style.display = "none"; |
| 570 | } |
| 571 | |
| 572 | this.initGameCore(js, wasm, thread); |
| 573 | }); |
| 574 | } |
| 575 | const report = "cores/reports/" + this.getCore() + ".json"; |
| 576 | this.downloadFile(report, null, false, { responseType: "text", method: "GET" }).then(async rep => { |
| 577 | if (rep === -1 || typeof rep === "string" || typeof rep.data === "string") { |
| 578 | rep = {}; |
| 579 | } else { |
| 580 | rep = rep.data; |
| 581 | } |
no test coverage detected