1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-15 03:52:40 +01:00

Resolve issues with save before load/quit prompt

This commit is contained in:
Ethan O'Brien
2025-08-10 14:30:26 -05:00
parent 1eff246b1a
commit a784fe46fe
3 changed files with 10 additions and 9 deletions

View File

@@ -21,14 +21,13 @@ var EmscriptenDeps = {
return data; return data;
} }
}, },
EmscriptenSaveGame: async (isTrackDesign, isAutosave, isSaveAs, type) => { EmscriptenSaveGame: async (isTrackDesign, isAutosave, type) => {
isTrackDesign = isTrackDesign === 1; isTrackDesign = isTrackDesign === 1;
isAutosave = isAutosave === 1; isAutosave = isAutosave === 1;
isSaveAs = isSaveAs === 1;
const data = SAVE.readFileData(isTrackDesign); const data = SAVE.readFileData(isTrackDesign);
try { try {
if (window.showSaveFilePicker) { if (window.showSaveFilePicker) {
if (SAVE.filehandle === null || isSaveAs) { if (SAVE.filehandle === null) {
SAVE.filehandle = null; SAVE.filehandle = null;
const file = await showSaveFilePicker({ const file = await showSaveFilePicker({
id: "OpenRCT2-" + type, id: "OpenRCT2-" + type,
@@ -75,7 +74,6 @@ var EmscriptenDeps = {
EmscriptenLoadGame: async (type) => { EmscriptenLoadGame: async (type) => {
try { try {
if (window.showOpenFilePicker) { if (window.showOpenFilePicker) {
SAVE.filehandle = null;
const [file] = await showOpenFilePicker({ const [file] = await showOpenFilePicker({
id: "OpenRCT2-" + type, id: "OpenRCT2-" + type,
types: [ types: [

View File

@@ -31,7 +31,7 @@
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
extern "C" { extern "C" {
extern void EmscriptenLoadGame(LoadSaveType type); extern void EmscriptenLoadGame(LoadSaveType type);
extern void EmscriptenSaveGame(bool isTrackDesign, bool isAutosave, bool saveAs, LoadSaveType type); extern void EmscriptenSaveGame(bool isTrackDesign, bool isAutosave, LoadSaveType type);
} }
#endif #endif
@@ -48,7 +48,7 @@ namespace OpenRCT2::Ui::FileBrowser
if (action == LoadSaveAction::save) if (action == LoadSaveAction::save)
{ {
Select("/save.park", action, type, trackDesign); Select("/save.park", action, type, trackDesign);
EmscriptenSaveGame(type == LoadSaveType::track, false, true, type); EmscriptenSaveGame(type == LoadSaveType::track, false, type);
} }
else else
{ {

View File

@@ -78,7 +78,7 @@
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
extern "C" { extern "C" {
extern void EmscriptenSaveGame(bool isTrackDesign, bool isAutosave, bool saveAs, LoadSaveType type); extern void EmscriptenSaveGame(bool isTrackDesign, bool isAutosave, LoadSaveType type);
extern void EmscriptenResetAutosave(); extern void EmscriptenResetAutosave();
} }
#endif #endif
@@ -468,7 +468,7 @@ void SaveGame()
#else #else
const auto savePath = Path::WithExtension("save", ".park"); const auto savePath = Path::WithExtension("save", ".park");
SaveGameWithName(savePath); SaveGameWithName(savePath);
EmscriptenSaveGame(false, false, false, LoadSaveType::park); EmscriptenSaveGame(false, false, LoadSaveType::park);
#endif #endif
} }
else else
@@ -521,6 +521,9 @@ std::unique_ptr<Intent> CreateSaveGameAsIntent()
void SaveGameAs() void SaveGameAs()
{ {
#ifdef __EMSCRIPTEN__
EmscriptenResetAutosave();
#endif
auto intent = CreateSaveGameAsIntent(); auto intent = CreateSaveGameAsIntent();
ContextOpenIntent(intent.get()); ContextOpenIntent(intent.get());
} }
@@ -632,7 +635,7 @@ void GameAutosave()
{ {
const auto savePath = Path::WithExtension("save", ".park"); const auto savePath = Path::WithExtension("save", ".park");
SaveGameWithName(savePath); SaveGameWithName(savePath);
EmscriptenSaveGame(false, true, false, LoadSaveType::park); EmscriptenSaveGame(false, true, LoadSaveType::park);
} }
#endif // __EMSCRIPTEN__ #endif // __EMSCRIPTEN__