gameManager.getState returns a Uint8Array, not a Promise

This commit is contained in:
Ethan O'Brien 2024-02-06 14:54:18 -06:00
parent bc102c8716
commit 390605d2ab
2 changed files with 4 additions and 6 deletions

View file

@ -134,10 +134,8 @@ class EJS_GameManager {
this.functions.restart(); this.functions.restart();
} }
getState() { getState() {
return new Promise(async (resolve, reject) => { this.functions.saveStateInfo();
this.functions.saveStateInfo(); return this.FS.readFile("/current.state");
resolve(this.FS.readFile("/current.state"));
})
} }
loadState(state) { loadState(state) {
try { try {

View file

@ -1715,7 +1715,7 @@ class EmulatorJS {
let stateUrl; let stateUrl;
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 = this.gameManager.getState();
const called = this.callEvent("save", { const called = this.callEvent("save", {
screenshot: await this.gameManager.screenshot(), screenshot: await this.gameManager.screenshot(),
state: state state: state
@ -4598,7 +4598,7 @@ class EmulatorJS {
syncing = true; syncing = true;
if (this.debug) console.log("sync") if (this.debug) console.log("sync")
this.netplay.ready = 0; this.netplay.ready = 0;
const state = await this.gameManager.getState(); const state = this.gameManager.getState();
this.netplay.sendMessage({ this.netplay.sendMessage({
state: state state: state
}); });