Skip to content

Commit

Permalink
Add onSaveSlotUploaded to FS.syncFS callback
Browse files Browse the repository at this point in the history
  • Loading branch information
patapancakes committed Feb 27, 2024
1 parent ad13441 commit 0d2e5ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/async_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,22 @@ bool AsyncHandler::IsFilePending(bool important, bool graphic) {
}

void AsyncHandler::SaveFilesystem() {
#ifdef EMSCRIPTEN
// Save changed file system
EM_ASM({
FS.syncfs(function(err) {});
});
#endif
}

void AsyncHandler::SaveFilesystem(int slot_id) {
#ifdef EMSCRIPTEN
// Save changed file system
EM_ASM({
FS.syncfs(function(err) {
onSaveSlotUpdated($0);
});
});
}, slot_id);
#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/async_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ namespace AsyncHandler {
* Only works on emscripten, noop on other platforms.
*/
void SaveFilesystem();
void SaveFilesystem(int slot_id); // for save sync callback
}

using FileRequestBinding = std::shared_ptr<int>;
Expand Down
6 changes: 1 addition & 5 deletions src/scene_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ bool Scene_Save::Save(std::ostream& os, int slot_id, bool prepare_save) {
bool res = lcf::LSD_Reader::Save(os, save, lcf_engine, Player::encoding);

DynRpg::Save(slot_id);
AsyncHandler::SaveFilesystem();

EM_ASM({
onSaveSlotUpdated($0);
}, slot_id);
AsyncHandler::SaveFilesystem(slot_id);

return res;
}
Expand Down

0 comments on commit 0d2e5ee

Please sign in to comment.