dialogic-godot / dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!
https://dialogic.pro
MIT License
3.42k stars 206 forks source link

Manual save data export/import #228

Closed mscharley closed 3 years ago

mscharley commented 3 years ago

Fixes #224.

This is my proposal for manual save management. This allows developers to manually handle save data management if they need something more complicated that the autosave provides. This also allows for multiple save states using whatever save mechanism the developer is using already.

Example usage:

# Disable the normal autosave mechanism.
Dialogic.set_autosave(false)
# To save your game, call this and serialise the results however you like.
var dialogic_data = Dialogic.export()
# To load a game, call this with the unserialised value from #export() above.
Dialogic.import(dialogic_data);

Changes to existing behaviour

Dialogic should continue to work the same way unless set_autosave(false) is called with one exception:

  1. Dialogic will no long pre-emptively create files and folders in user://dialogic, instead waiting to create them just in time as it saves state for the first time.
mscharley commented 3 years ago

Converting this back to a draft for now - it seems a little buggy. I originally wrote this against the 1.0 release but the latest main branch has changed a few things.

coppolaemilio commented 3 years ago

Thanks for the contribution, I will be able to test today or tomorrow, but in the mean time. Have you tested it with exported projects? From previous experiences there are some differences between testing Godot projects "running them" from the editor and running exported games. If you haven't please give it a go and confirm that things are working as expected. Just in case 😅

mscharley commented 3 years ago

I've only tested the new manual workflow, I haven't tested the old workflow much. I hadn't tested with an exported project but I just did that and I didn't see any issues. user://dialogic was still not created, and the import/export functionality worked with my saved game system.

mscharley commented 3 years ago

Something that might be nice to do that I only just noticed was possible would be to have a setting in res://dialogic/settings.cfg that controls the default value for autoload. For now though, setting it to false in an _ready in a singleton works well.

coppolaemilio commented 3 years ago

@arnaudvergnet can you test this one as well since you made the original saving?

arnaudvergnet commented 3 years ago

@coppolaemilio I saw you merged it, do you still need me to test it?

coppolaemilio commented 3 years ago

@arnaudvergnet yes, since you did the other part of it I believe you would be better fit to test it properly. I did some tests and it seems to run fine but if you could take an extra look I would really appreciate it 🙇🏻

arnaudvergnet commented 3 years ago

I tried it a bit and this is a breaking change. Nothing gets saved on my own project even after setting autosave to true, I'll investigate a bit more to see what changed

arnaudvergnet commented 3 years ago

Never mind this is working as expected, I forgot I edited my project so it wasn't working with the last version either