diff --git a/.gitignore b/.gitignore index e8c826a..8e06e59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/node_modules/ data/minify/package-lock.json *.db +roms/ diff --git a/data/GameManager.js b/data/GameManager.js index 6d3ae48..d4d2d7b 100644 --- a/data/GameManager.js +++ b/data/GameManager.js @@ -55,7 +55,7 @@ class EJS_GameManager { } getRetroArchCfg() { return "autosave_interval = 60\n" + - "screenshot_directory = /\n" + + "screenshot_directory = \"/\"\n" + "block_sram_overwrite = false\n" + "video_gpu_screenshot = false\n" + "audio_latency = 64\n" + @@ -169,7 +169,7 @@ class EJS_GameManager { try { if (fileNames.length > 1) { fileNames = fileNames.filter((item) => { - return ["toc", "ccd", "exe", "pbp", "chd", "img", "bin"].includes(item.split(".").pop().toLowerCase()); + return ["toc", "ccd", "exe", "pbp", "chd", "img", "bin", "iso"].includes(item.split(".").pop().toLowerCase()); }) fileNames = fileNames.sort((a, b) => { if (isNaN(a.charAt()) || isNaN(b.charAt())) throw new Error("Incorrect file name format"); diff --git a/data/emulator.js b/data/emulator.js index e738060..79bdeba 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -359,7 +359,7 @@ class EmulatorJS { } return text; } - checkCompression(data, msg) { + checkCompression(data, msg, fileCbFunc) { if (msg) { this.textElem.innerText = msg; } @@ -404,7 +404,12 @@ class EmulatorJS { this.textElem.innerText = msg + progress; } if (data.data.t === 2) { - files[data.data.file] = data.data.data; + if (typeof fileCbFunc === "function") { + fileCbFunc(data.data.file, data.data.data); + files[data.data.file] = true; + } else { + files[data.data.file] = data.data.data; + } } if (data.data.t === 1) { resolve(files); @@ -432,7 +437,12 @@ class EmulatorJS { this.textElem.innerText = msg + progress; } if (data.data.t === 2) { - files[data.data.file] = data.data.data; + if (typeof fileCbFunc === "function") { + fileCbFunc(data.data.file, data.data.data); + files[data.data.file] = true; + } else { + files[data.data.file] = data.data.data; + } } if (data.data.t === 1) { resolve(files); @@ -475,7 +485,12 @@ class EmulatorJS { this.textElem.innerText = msg + progress; } if (data.data.t === 2) { - files[data.data.file] = data.data.data; + if (typeof fileCbFunc === "function") { + fileCbFunc(data.data.file, data.data.data); + files[data.data.file] = true; + } else { + files[data.data.file] = data.data.data; + } } if (data.data.t === 1) { resolve(files); @@ -499,7 +514,12 @@ class EmulatorJS { return decompressRar(data); } } else { - return new Promise(resolve => resolve({"!!notCompressedData": data})); + if (typeof fileCbFunc === "function") { + fileCbFunc("!!notCompressedData", data); + return new Promise(resolve => resolve({"!!notCompressedData": true})); + } else { + return new Promise(resolve => resolve({"!!notCompressedData": data})); + } } } @@ -757,11 +777,41 @@ class EmulatorJS { resolve(); return; } - this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Data")).then((data) => { - const altName = this.config.gameUrl.startsWith("blob:") ? this.config.gameName || "game" : this.config.gameUrl.split('/').pop().split("#")[0].split("?")[0]; + + let resData = {}; + const altName = this.config.gameUrl.startsWith("blob:") ? this.config.gameName || "game" : this.config.gameUrl.split('/').pop().split("#")[0].split("?")[0]; + this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Data"), (fileName, fileData) => { + console.log(fileName); + if (fileName.includes("/")) { + const paths = fileName.split("/"); + let cp = ""; + for (let i=0; i { const fileNames = (() => { let rv = []; - for (const k in data) rv.push(k); + for (const k in resData) rv.push(k); return rv; })(); if (fileNames.length === 1) fileNames[0] = altName; @@ -769,39 +819,25 @@ class EmulatorJS { if (this.getCore(true) === "psx") { execFile = this.gameManager.createCueFile(fileNames); } - for (const k in data) { + + for (const k in resData) { if (k === "!!notCompressedData") { - if (this.getCore(true) === "psx" && execFile !== null) { this.fileName = execFile; } else { this.fileName = altName; } - FS.writeFile(altName, data[k]); break; } - if (k.endsWith('/')) { - FS.mkdir(k); - continue; - } if (!this.fileName || ((this.extensions[this.getCore()] || []).includes(k.split(".").pop()) && //always prefer m3u files for psx cores !(this.getCore(true) === "psx" && ["m3u", "ccd"].includes(this.fileName.split(".").pop())))) { this.fileName = k; } - if (k.includes("/")) { - const paths = k.split("/"); - let cp = ""; - for (let i=0; i { if (res === -1) { this.textElem.innerText = this.localization('Network Error');