diff --git a/.gitignore b/.gitignore
index 435a7c3..96090a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ roms/
data/emulator.min.js
data/emulator.min.css
data/cores
+.DS_Store
diff --git a/data/emulator.js b/data/emulator.js
index e3b79fa..3700ede 100644
--- a/data/emulator.js
+++ b/data/emulator.js
@@ -1719,7 +1719,7 @@ class EmulatorJS {
let stateUrl;
const saveState = addButton("Save State", '', async () => {
const state = this.gameManager.getState();
- const called = this.callEvent("save", {
+ const called = this.callEvent("saveState", {
screenshot: await this.gameManager.screenshot(),
state: state
});
@@ -1738,7 +1738,7 @@ class EmulatorJS {
}
});
const loadState = addButton("Load State", '', async () => {
- const called = this.callEvent("load");
+ const called = this.callEvent("loadState");
if (called > 0) return;
if (this.settings['save-state-location'] === "browser" && this.saveInBrowserSupported()) {
this.storage.states.get(this.getBaseFileName()+".state").then(e => {
@@ -1767,6 +1767,11 @@ class EmulatorJS {
const saveSavFiles = addButton("Export Save File", '', async () => {
const file = await this.gameManager.getSaveFile();
+ const called = this.callEvent("saveSave", {
+ screenshot: await this.gameManager.screenshot(),
+ save: file
+ });
+ if (called > 0) return;
const blob = new Blob([file]);
savUrl = URL.createObjectURL(blob);
const a = this.createElement("a");
@@ -1775,6 +1780,8 @@ class EmulatorJS {
a.click();
});
const loadSavFiles = addButton("Import Save File", '', async () => {
+ const called = this.callEvent("loadSave");
+ if (called > 0) return;
const file = await this.selectFile();
const sav = new Uint8Array(await file.arrayBuffer());
const path = this.gameManager.getSaveFilePath();
diff --git a/data/loader.js b/data/loader.js
index e5ec4ae..72aa02c 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -136,9 +136,15 @@
window.EJS_emulator.on("start", window.EJS_onGameStart);
}
if (typeof window.EJS_onLoadState === "function") {
- window.EJS_emulator.on("load", window.EJS_onLoadState);
+ window.EJS_emulator.on("loadState", window.EJS_onLoadState);
}
if (typeof window.EJS_onSaveState === "function") {
- window.EJS_emulator.on("save", window.EJS_onSaveState);
+ window.EJS_emulator.on("saveState", window.EJS_onSaveState);
+ }
+ if (typeof window.EJS_onLoadSave === "function") {
+ window.EJS_emulator.on("loadSave", window.EJS_onLoadSave);
+ }
+ if (typeof window.EJS_onSaveSave === "function") {
+ window.EJS_emulator.on("saveSave", window.EJS_onSaveSave);
}
})();