diff --git a/data/GameManager.js b/data/GameManager.js index 4046c0e..2aa3cd6 100644 --- a/data/GameManager.js +++ b/data/GameManager.js @@ -81,7 +81,14 @@ class EJS_GameManager { this.FS.writeFile('/shader/'+shader, window.EJS_SHADERS[shader]); } } + clearEJSResetTimer() { + if (this.EJS.resetTimeout) { + clearTimeout(this.EJS.resetTimeout); + delete this.EJS.resetTimeout; + } + } restart() { + this.clearEJSResetTimer(); this.functions.restart(); } getState() { @@ -115,6 +122,7 @@ class EJS_GameManager { this.FS.unlink('game.state'); } catch(e){} this.FS.writeFile('/game.state', state); + this.clearEJSResetTimer(); this.functions.loadState("game.state", 0); setTimeout(() => { try { @@ -141,6 +149,7 @@ class EJS_GameManager { if (!slot) slot = 1; (async () => { let name = slot + '-quick.state'; + this.clearEJSResetTimer(); this.functions.loadState(name, 0); })(); } @@ -310,6 +319,7 @@ class EJS_GameManager { return (exists ? FS.readFile(this.getSaveFilePath()) : null); } loadSaveFiles() { + this.clearEJSResetTimer(); this.functions.loadSaveFiles(); } setFastForwardRatio(ratio) { diff --git a/data/emulator.js b/data/emulator.js index 6dc9b54..e90becf 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -1067,6 +1067,11 @@ class EmulatorJS { args.push('/'+this.fileName); if (this.debug) console.log(args); this.Module.callMain(args); + if (typeof this.config.softLoad === "number" && this.config.softLoad > 0) { + this.resetTimeout = setTimeout(() => { + this.gameManager.restart(); + }, this.config.softLoad * 1000); + } this.Module.resumeMainLoop(); this.checkSupportedOpts(); this.setupSettingsMenu(); diff --git a/data/loader.js b/data/loader.js index fee04e7..d87062d 100644 --- a/data/loader.js +++ b/data/loader.js @@ -81,6 +81,7 @@ config.threads = window.EJS_threads; config.disableCue = window.EJS_disableCue; config.startBtnName = window.EJS_startButtonName; + config.softLoad = window.EJS_softLoad; if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") { try {