Product Versioning...and presets...
-
OK so....
I have a Product - released and out in the wild - with its own set of FACTORY presets
Now I want to do version 1.1 of it, but.......
I want to change the name of a widget, lets say from mySpecificPurposeGain to myGeneralPurposeGain.
mySpecificPurposeGain is "saveInPreset" = true...
So I have a set of FACTORY presets that all need changing one way or another - I can simply run a little python replace script that changes the name in all FACTORY presets....and these would be OK - I think - but a supplemental question on this later...
But.. what about all those end-user presets - they would now be broken....and clearly I have no way to fix them....
How does every one approach this "problem situation"?
Clearly the simplest answer is NEVER go changing the name of a widget...but beyond that?
Also (supplementary q now..) I assume when people upgrade the plugin - the first time it reinstalls the presets?
-
There is a
rebuildUserPresets
function, but this only works for expansions, might be good if this could be triggered for non-expansion instruments if it detects a difference between preset versions - not sure how that would work.Another option is the
setEnableUserPresetPreprocessing
I have no idea what it does but I feel it should be useful in this situation.I think the approach most people have used up to now is to include a post-install script that handles UserPreset updates for presests that are already installed on the user's system.
-
I haven't got around writing the docs for this class, but like @d-healey said, the UserPresetHandler is tailored to exactly this task.
You can register a function with this method that will then convert every user preset to a JSON object which you can manipulate before loading the preset. In this case it would be something like
const var up = Engine.createUserPresetHandler(); up.setEnableUserPresetPreProcessing(function(data) { for(d in data.Content) { if(d.name == "mySpecificPurposeGain") d.name = "myGeneralPurposeGain"; } }, false);
I typed this out of my head, so there will be typos, but this is all you need to do for your use case and will cover factory presets as well as user made ones (since this operation is being executed everytime a preset is being loaded).
-
@christoph-hart Does this function overwrite the preset on the user's system? Does the function need to return the
data
object or is it passed by reference and edited in place? -
@d-healey No, it will not override the files, but just process the data that is being loaded (think of it as a non-destructive processing step).
The data object is passed by reference and converted back to the XML format. Writing a XML->JSON converter is less trivial than you might think...