signus-game / signus

Signus: The Artefact Wars. Czech turn-based strategy game similar to Battle Isle series
GNU General Public License v2.0
66 stars 11 forks source link

Portable version #17

Closed skodapetr closed 2 years ago

skodapetr commented 2 years ago

As of now (release v1.96.0) "user home directory" is used as folder where Signus' data are saved - saved games, _crashguard_savedstate and signus.ini. It would be nice to have an option that would allow to store this data in the signus directory - making it "portable". It would also make it easier for users to find and share _crashguard_savedstate .

Tony763 commented 2 years ago

Perhaps add arg with path to save directory? Something like './signus --save-dir ./savedir'?

skodapetr commented 2 years ago

I would go with higher level, like --data-dir as it is not only saves, but the signus.ini file and the _crashguard_savedstate .

skodapetr commented 2 years ago

Perhaps an alternative, easier for implementation, would be to add another env. variable. Then it can be just read before the env. variable for home. The user comfort in that case can be provided by a bat/sh file that will set the current directory to this new env. variable.

We can actually do this right now by changing the APPDATA property, for Win, example bat file:

set APPDATA=./data/
signus.exe

the only drawback is, that there is data/signus directory, but it fulfills the purpose and requires no change of code.

With that said it should be fine to close the issue as there is a way how to get the desired output.

kukenc commented 2 years ago

Game already use env var, this is better way IMHO. But not sure, if APPDATA or --data-dir is not confusing. Signus have many data build from folder signus-data and installed to /usr/share/signus/1.96/ at linux (dont know how it works on windows).

skodapetr commented 2 years ago

APPDATA is used on Windows for the user home app-directory, so it is standard way. I've just abuse it to get the job done.

On Win you just download it as an archive and unpack. Then thanks to using the APPDATA all the files mentioned in the first post are saved correctly to the user-home/app-data/...... directory. For most users this is how it should be done - although there are now new folders (Saved Games, some games use Documents, ...).

I my case I was fine, although curious, until I've encountered bug in mission 5 and need to manually remove the crash file. I also like to keep my save files together with my games, especially the older ones that are not automatically synced to cloud. So in case of re-install of the OS I do not lose them.

nextghost commented 2 years ago

I'll add a message box asking whether to load crashguard save or ignore it and open main menu as usual. That'll solve the problem of infinite crash loops without the need to delete it manually.

However, a portable version where the executable, game data, configs and saved games are all stored in the same directory is not a priority for me. If anybody wants to send a patch, the best option is to use conditional compilation, build separate executables with different hardcoded paths and make a new portable ZIP archive which will bundle executables for all supported platforms. Juggling different paths via command line arguments or env variables will just confuse users who accidentaly run the executable directly instead of the special BAT file or shell script.

The path detection code is in signus/src/unix.cpp and signus/src/windows.cpp, respectively.