Duion Posted January 18, 2016 Share Posted January 18, 2016 Can I force update some of the user preferences somehow when a user downloads a new version of the game?I changed it so the user preferences get stored in the users home directory independent from my game, but now I plan to change some of the values, but when someone who had a previous version of the game upgrades to the new version, he keeps the old preferences, so I need to force overwrite them with the new ones somehow.Especially this one for example is annoying: $pref::Video::unavailableTexturePath = "core/art/unavailable";I moved that texture to another directory, but if someone with an old prefs file opens the material editor the game crashes immediately, since he has the old path in his settings. Quote Link to comment Share on other sites More sharing options...
Duion Posted January 18, 2016 Author Share Posted January 18, 2016 I don't really know if those values are relevant, since it worked when I tested recently with wrong values, but I also had crashes because of wrong values for file paths in the prefs. Quote Link to comment Share on other sites More sharing options...
Poponfu Posted February 12, 2016 Share Posted February 12, 2016 Legions does it something like this: There is $Pref::PrefVersion = #. When you need to do something like your case, you add to the updatePrefs function with another check. So in your case where they do not have it yet, you say if $= "", $pref::Video::unavailableTexturePath = then set their $Pref::PrefVersion to 1. Next time you would say if != 2.. change these things, then update their $Pref::PrefVersion to 2 Quote Link to comment Share on other sites More sharing options...
Duion Posted February 12, 2016 Author Share Posted February 12, 2016 So I make a list with pref variables I changed in the current version and hat have to be force updated and then I add a new pref version variable that gets added after I force updated the variables, to make sure the next time it loads the variables to not get force updated again, while checking against the pref version?Sounds like a logic solution, I may try that some time later. Quote Link to comment Share on other sites More sharing options...
Poponfu Posted February 12, 2016 Share Posted February 12, 2016 (edited) You make a new function like this that gets called somewhere early every startup. function updatePrefs() { if($Pref::version $= "") { <change some prefs> } $Pref::version = 1 //so now they are 1 and it knows whatever got changed } Next time you need to update some prefs, you add to the same function. function updatePrefs() { if($Pref::version $= "") { <change some prefs> $Pref::version = 1 } if($Pref::version == 1) { <change some prefs again> } $Pref::version = 2 //so now they are 2 and it knows whatever got changed } Edited February 13, 2016 by Poponfu Quote Link to comment Share on other sites More sharing options...
Duion Posted February 12, 2016 Author Share Posted February 12, 2016 Ah thx, I will try it for my next version, since I will need it then. Quote Link to comment Share on other sites More sharing options...
Duion Posted March 30, 2016 Author Share Posted March 30, 2016 I will use that system now, it seems to work.Another question I have is, if it is possible to also delete the whole entry of a certain pref in total per script? It is just spam prevention, but since I change things a lot, it may be nice to have cleanup functionality. Quote Link to comment Share on other sites More sharing options...
Duion Posted April 3, 2016 Author Share Posted April 3, 2016 Anyone has an idea how to force update certain keybindings in the config as well?I found that the bindings config file generated for the user does not get updated, if new keybindings are added.My solution so far is to just execute a restore defaults, if the pref version is outdated, but this will discard all the changes the user may have made to his bindings. Quote Link to comment Share on other sites More sharing options...
rlranft Posted April 3, 2016 Share Posted April 3, 2016 That's tricky - new keybindings might conflict with user selected bindings.When you say "new keybindings" you mean "I've added a key binding to play a new animation or other new thing," right? I made a quick tool that removes the key constants from the OptionsDlg and puts them in a separate file but you could do that by hand (this file would need to be exec() from the OptionsDlg.cs file, preferably at the top). Then you just replace this file and let the user open and change their keybindings from the options dialog to "import" the added defaults without stomping on their selected preferences.For example:https://github.com/RichardRanft/Project13/blob/master/game/scripts/gui/optionsDlg.cs#L22https://github.com/RichardRanft/Project13/blob/master/game/scripts/gui/keyMap.csSo, user updates to the new version of the game, opens his options dialog and the system should load his settings from the generated config file. Then when he saves his keybindings it should update the config correctly. It's a manual step for the user - worst case is they don't do it and therefore the new keybind is unavailable.The key map modification tool is available here: https://github.com/RichardRanft/T3DKeyMapMod Quote Link to comment Share on other sites More sharing options...
Duion Posted April 3, 2016 Author Share Posted April 3, 2016 No, you cannot expect the user to take a step, the whole point is to making it fully automatic.Many new keybinds I have are new ones that have not been used before, but even though they keys for them are not already bound to something else, they do not get added to the config.The new mappings for vehicle and spectator are instead added automatically to the users config file, they are just appended to the config file, but somehow you cannot append some new configs to the old movemap config.What I had in mind was to simulate a force rebinding of certain keybinds through script as it would happen when the user does it manually, which only happens once the user starts the new version from an old version.In the end I thought just resetting it once would be the easiest option, since a lot has changed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.