### Force update certain $pref for users Scripting questions, discussions, etc #### Force update certain$pref for users

Duion
Posts: 806
Joined: Sun Feb 08, 2015 1:51 am

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. #### Re: Force update certain$pref for users

Duion
Posts: 806
Joined: Sun Feb 08, 2015 1:51 am

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.

#### Re: Force update certain $pref for users Duion Posts: 806 Joined: Sun Feb 08, 2015 1:51 am 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. #### Re: Force update certain$pref for users

Poponfu
Posts: 2
Joined: Fri Feb 12, 2016 6:38 pm
You make a new function like this that gets called somewhere early every startup.

Code: Select all

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. Code: Select all 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}
Last edited by Poponfu on Sat Feb 13, 2016 10:25 pm, edited 1 time in total.

#### Re: Force update certain $pref for users Duion Posts: 806 Joined: Sun Feb 08, 2015 1:51 am Ah thx, I will try it for my next version, since I will need it then. #### Re: Force update certain$pref for users

Duion
Posts: 806
Joined: Sun Feb 08, 2015 1:51 am

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.

#### Re: Force update certain $pref for users Duion Posts: 806 Joined: Sun Feb 08, 2015 1:51 am 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. #### Re: Force update certain$pref for users

rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm

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/Project ... Dlg.cs#L22
https://github.com/RichardRanft/Project ... /keyMap.cs

So, 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

#### Re: Force update certain \$pref for users

Duion
Posts: 806
Joined: Sun Feb 08, 2015 1:51 am

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.

#### Who is online

Users browsing this forum: No registered users and 1 guest