mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 02:46:23 +00:00
Fix screenshot for some cores
This commit is contained in:
parent
f3611a00d6
commit
76c3ea1c0e
2 changed files with 21 additions and 12 deletions
|
@ -175,7 +175,16 @@ class EJS_GameManager {
|
||||||
}
|
}
|
||||||
screenshot() {
|
screenshot() {
|
||||||
this.functions.screenshot();
|
this.functions.screenshot();
|
||||||
return this.FS.readFile('screenshot.png');
|
return new Promise(resolve => async {
|
||||||
|
while (1) {
|
||||||
|
try {
|
||||||
|
FS.stat("/screenshot.png");
|
||||||
|
return resolve(this.FS.readFile("/screenshot.png"));
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
|
await new Promise(res => setTimeout(res, 50));
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
quickSave(slot) {
|
quickSave(slot) {
|
||||||
if (!slot) slot = 1;
|
if (!slot) slot = 1;
|
||||||
|
|
|
@ -661,7 +661,6 @@ class EmulatorJS {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let legacy = (this.supportsWebgl2 ? "" : "-legacy");
|
let legacy = (this.supportsWebgl2 ? "" : "-legacy");
|
||||||
if ("n64" !== this.getCore(true)) legacy = "";
|
|
||||||
let filename = this.getCore()+(this.config.threads ? "-thread" : "")+legacy+"-wasm.data";
|
let filename = this.getCore()+(this.config.threads ? "-thread" : "")+legacy+"-wasm.data";
|
||||||
this.storage.core.get(filename).then((result) => {
|
this.storage.core.get(filename).then((result) => {
|
||||||
if (result && result.version === this.version && !this.debug) {
|
if (result && result.version === this.version && !this.debug) {
|
||||||
|
@ -1320,15 +1319,16 @@ class EmulatorJS {
|
||||||
let screenshotUrl;
|
let screenshotUrl;
|
||||||
const screenshot = addButton("Take Screenshot", false, () => {
|
const screenshot = addButton("Take Screenshot", false, () => {
|
||||||
if (screenshotUrl) URL.revokeObjectURL(screenshotUrl);
|
if (screenshotUrl) URL.revokeObjectURL(screenshotUrl);
|
||||||
const screenshot = this.gameManager.screenshot();
|
this.gameManager.screenshot().then(screenshot => {
|
||||||
const blob = new Blob([screenshot]);
|
const blob = new Blob([screenshot]);
|
||||||
screenshotUrl = URL.createObjectURL(blob);
|
screenshotUrl = URL.createObjectURL(blob);
|
||||||
const a = this.createElement("a");
|
const a = this.createElement("a");
|
||||||
a.href = screenshotUrl;
|
a.href = screenshotUrl;
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
a.download = this.getBaseFileName()+"-"+date.getMonth()+"-"+date.getDate()+"-"+date.getFullYear()+".png";
|
a.download = this.getBaseFileName()+"-"+date.getMonth()+"-"+date.getDate()+"-"+date.getFullYear()+".png";
|
||||||
a.click();
|
a.click();
|
||||||
hideMenu();
|
hideMenu();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let screenMediaRecorder = null;
|
let screenMediaRecorder = null;
|
||||||
|
@ -1709,7 +1709,7 @@ class EmulatorJS {
|
||||||
const saveState = addButton("Save State", '<svg viewBox="0 0 448 512"><path fill="currentColor" d="M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"/></svg>', async () => {
|
const saveState = addButton("Save State", '<svg viewBox="0 0 448 512"><path fill="currentColor" d="M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"/></svg>', async () => {
|
||||||
const state = await this.gameManager.getState();
|
const state = await this.gameManager.getState();
|
||||||
const called = this.callEvent("save", {
|
const called = this.callEvent("save", {
|
||||||
screenshot: this.gameManager.screenshot(),
|
screenshot: await this.gameManager.screenshot(),
|
||||||
state: state
|
state: state
|
||||||
});
|
});
|
||||||
if (called > 0) return;
|
if (called > 0) return;
|
||||||
|
|
Loading…
Reference in a new issue