thewierdnut / endless-mobile

Space exploration, trading, and combat game.
https://endless-sky.github.io/
GNU General Public License v3.0
93 stars 7 forks source link

Accessible save games #6

Closed thewierdnut closed 1 year ago

thewierdnut commented 1 year ago

Problem Description

The user is unable to import or export save games. This may be needed to port games between devices, or to a desktop install.

Related Issue Links

n/a

Desired Solution

Some way to import or export save games

Alternative Approaches

or... just store the saves somewhere accessible on the device, where the user can pull them manually without root.

Additional Context

If you uninstall the game from the phone, then it will also wipe out your save games, which may not be a desired outcome.

samrocketman commented 1 year ago

Maybe use SDL_AndroidGetExternalStoragePath() in source/Files.cpp instead of SDL_GetPrefPath()?

samrocketman commented 1 year ago

Not all androids will have SD card so may want a null check fallback to internal storage.

thewierdnut commented 1 year ago

Nowadays, android will fake it even if you don't have an SD card.

I'm not sure what I think about having direct access to the preferences path though, as there is a lot of opportunity to break things. If I read the documentation right, I think it also says that it will delete external paths as well on uninstalls.

At the moment, I'm playing with using import/export save game buttons using intents, which I think will serve the desired purpose of being able to transfer save games. I'm open to counterarguments though, and I can always fail to make it work the way I want (I'm not a competent java programmer)

thewierdnut commented 1 year ago

So at this point, I've prototyped both solutions, and they have their pros and cons:

External storage path: Naively changing the api still doesn't create user-visible files due to permissions issues. I'll have to modify those permissions when the file gets written, which includes the parent folders. It also loses access to old games previously created, unless I put some sort of backwards compatible import in place.

Import/Export buttons, using intents: These seem like they would integrate better, and would remain backwards compatible, but would require some gui modifications.

At this point, I think the maintenance cost and implementation effort will be the same either way. Is there any preference @larrydewey?

thewierdnut commented 1 year ago

I've implemented the import/export buttons and merged them with build 26

larrydewey commented 1 year ago

@thewierdnut The Import/Export option would have been my suggestion. I had a crazy weekend, so I didn't get a chance to respond until now. I tested the feature, and I haven't had any issues. I was able to both import and export a save file, which was very handy, because I am using nextcloud to keep my saved game synced between my computer and phone. Thank you for putting this feature in, it adds very needed support to make this port complete!