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 d80521f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/async_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,14 @@ bool AsyncHandler::IsFilePending(bool important, bool graphic) {
return false;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/async_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace AsyncHandler {
* Saves the state of the Save filesystem.
* Only works on emscripten, noop on other platforms.
*/
void SaveFilesystem();
void SaveFilesystem(int slotId);
}

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(slotId);

return res;
}
Expand Down

0 comments on commit d80521f

Please sign in to comment.