-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overwrite config.json with player configuration #138
base: master
Are you sure you want to change the base?
Conversation
Hi there! Thanks for looking into this. However, this script is still set to operate in a region of the system which is not under the user's control. So, in order to run, it still needs superuser privileges. As so:
As with vegastrike.config, would it not make more sense to have the engine check for a config.json in the same places and hierarchy as with vegastrike.config? If a config.json is found in the user's home directory, then just use the config.json in the user's home directory rather than the one in the system. This solves a couple of problems:
If you want to be fancy about it, you can put a version number inside the config.json, so that when the items in the config.json changes it would be possible to warn the user that the config file is of an older version and needs to be merged with the newer version from /usr/share/vegastrike. If you want to be really, really fancy about it, the game engine can check for the existence of ~/.vegastrike/config.json, and if not present, create it from /usr/share/vegastrike/config.json. With the versioning method mentioned before, if the version in ~/.vegastrike is out of date, merge in the newer configuration options and save that. Also, post a message to the console to state that it was updated. |
OK. This is somewhat more complicated than I bargained for. If this solves the issue for you, let's merge this and revisit the issue again in a few weeks. |
Hmm, for me it is easier to just have a copy of the config.json somewhere else and just sudo cp it back into position. |
It is now. But in a month or two, you'll have multiple changes to a much larger file. Don't forget, config.json is supposed to grow rapidly in size. |
For now, I'll just copy over the file manually. If it changes significantly, I'll copy the new one and make the changes needed in my copy. |
if isinstance(config_bak[key], dict) or isinstance(config_bak[key], list): | ||
recursive_overwrite(config_json[key], config_bak[key]) | ||
else: | ||
config_json[key] = config_bak[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be able to use a Python dict merge here:
dict_a = {}
dict_b = {}
a.update(b)
We are currently in the process of migrating vegastrike.config (old, XML) to config.json (new, JSON).
As a result, the structure of the new file changes regularly and overwrites whatever changes the player has introduced.
As the first thing we ported was the graphics (resolution, monitor),
this requires the player to manually edit the file after every relevant pull.
Solution
There is a script, conveniently named overwrite_config_defaults, to do this automatically.
Copy all your changes to config.bak, preserving the relevant structure.
Code Changes:
Issues:
Does not fix Engine/issues/921