Correct Persistent spelling

This commit is contained in:
Ethan O'Brien 2025-01-17 09:33:05 -06:00
parent b4d72427ff
commit f7ca73c6eb
3 changed files with 44 additions and 16 deletions

View file

@ -7,7 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
var EmscriptenDeps = {
ExportPersistantData: () =>
ExportPersistentData: () =>
{
if (!window.JSZip)
{
@ -40,7 +40,7 @@ var EmscriptenDeps = {
processFolder(folder);
return zip;
}
const zip = zipFolder("/persistant/");
const zip = zipFolder("/persistent/");
zip.generateAsync({type: "blob"}).then(blob => {
const a = document.createElement("a");
@ -50,13 +50,41 @@ var EmscriptenDeps = {
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
})
},
ImportPersistantData: () =>
ImportPersistentData: () =>
{
if (!window.JSZip)
{
alert("JSZip library not found. Aborting");
return;
}
const clearDatabase = async function(dir) => {
await new Promise(res => Module.FS.syncfs(false, res));
const processFolder = (path) => {
let contents;
try {
contents = Module.FS.readdir(path);
} catch(e) {
return;
}
contents.forEach((entry) => {
if ([".", ".."].includes(entry)) return;
try {
Module.FS.readFile(path + entry);
Module.FS.unlink(path + entry);
} catch(e) {
processFolder(path + entry + "/");
}
})
if (path === dir) return;
try {
Module.FS.rmdir(path, {recursive: true});
} catch(e) {
console.log("Could not remove:", path);
}
}
processFolder(dir);
await new Promise(res => Module.FS.syncfs(false, res));
};
if (!confirm("Are you sure? This will wipe all current data.")) return;
alert("Select a zip file");
const input = document.createElement("input");
@ -69,7 +97,7 @@ var EmscriptenDeps = {
alert("Not a zip file!");
return;
}
await clearDatabase("/persistant/");
await clearDatabase("/persistent/");
for (const k in zip.files) {
const entry = zip.files[k];
if (entry.dir) {

View file

@ -42,8 +42,8 @@
}
});
Module.FS.mkdir("/persistant");
Module.FS.mount(Module.FS.filesystems.IDBFS, {autoPersist: true}, '/persistant');
Module.FS.mkdir("/persistent");
Module.FS.mount(Module.FS.filesystems.IDBFS, {autoPersist: true}, '/persistent');
Module.FS.mkdir("/RCT");
Module.FS.mount(Module.FS.filesystems.IDBFS, {autoPersist: true}, '/RCT');
@ -53,10 +53,10 @@
await new Promise(res => Module.FS.syncfs(true, res));
let configExists = fileExists("/persistant/config.ini");
let configExists = fileExists("/persistent/config.ini");
if (!configExists)
{
Module.FS.writeFile("/persistant/config.ini", `
Module.FS.writeFile("/persistent/config.ini", `
[general]
game_path = "/RCT"
uncap_fps = true
@ -69,11 +69,11 @@ window_scale = 1.750000
Module.FS.writeFile("/OpenRCT2/changelog.txt", `EMSCRIPTEN --- README
Since we're running in the web browser, we don't have direct access to the file system.
All save data is saved under the directory /persistant.
All save data is saved under the directory /persistent.
ALWAYS be sure to save to /persistant/saves when saving a game! Otherwise it will be wiped!
ALWAYS be sure to save to /persistent/saves when saving a game! Otherwise it will be wiped!
You can import/export the /persistant folder in the options menu.`);
You can import/export the /persistent folder in the options menu.`);
document.getElementById("loadingWebassembly").remove();
let filesFound = fileExists("/RCT/Data/ch.dat");
@ -110,7 +110,7 @@ You can import/export the /persistant folder in the options menu.`);
});
}
Module.canvas.style.display = "";
Module.callMain(["--user-data-path=/persistant/", "--openrct2-data-path=/OpenRCT2/"]);
Module.callMain(["--user-data-path=/persistent/", "--openrct2-data-path=/OpenRCT2/"]);
})();
async function updateAssets() {

View file

@ -49,8 +49,8 @@
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
extern "C" {
extern void ExportPersistantData();
extern void ImportPersistantData();
extern void ExportPersistentData();
extern void ImportPersistentData();
}
#endif
@ -1991,10 +1991,10 @@ namespace OpenRCT2::Ui::Windows
break;
#ifdef __EMSCRIPTEN__
case WIDX_EXPORT_EMSCRIPTEN_DATA:
ExportPersistantData();
ExportPersistentData();
break;
case WIDX_IMPORT_EMSCRIPTEN_DATA:
ImportPersistantData();
ImportPersistentData();
break;
#endif
}