Jump to content

Force update certain $pref for users


Duion

Recommended Posts

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.

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Poponfu
Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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#L22

https://github.com/RichardRanft/Project13/blob/master/game/scripts/gui/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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...