Update expansion presets
-
Hello friends,
When using expansions, is there a way to overwrite older presets or add new presets to the UserPresets folder when running an updated .hr file with the same name as the already installed one?
I'm using .installExpansionFromPackage(hr,dir) function to install a .hr encrypted expansion. If the user reinstalls an updated .hr. I want to add or update the presets without the user needing to go to their AppData folder to delete the older expansion.Thanks!
-
I don't think there is a way to do this with the expansion installer. If you're using the default preset browser they can install them through the
More
menu.Overwrite existing presets is not a good idea because the user might have edited them, however I think it would be useful to be able to install additional presets when providing an update via a hr file.
-
@d-healey My idea was to make two folders inside the UserPresets, one called Default-Presets and the other folder called User-Presets. When the user runs the installer containing the .hr files, it only deletes or replaces the Default-presets folder. So when the user loads the updated .hr, it only adds the missing folder containing the updated presets. The problem is you cant run a .hr that has the same name as an already existing .hr. It doesn't do anything
-
@marcLab But what if the user made changes to the default presets?
The problem is you cant run a .hr that has the same name as an already existing .hr. It doesn't do anything
This is a job for @Christoph-Hart. When using the default sample installer (not the expansion one) the popup gives the option to update if newer, this should be the default I think for the expansion installer. It would also be good to get the option to delete the hr files automatically after installation is completed.
-
This post is deleted! -
@d-healey, I would find a way to remove the save preset btn if a preset in the Default-Preset is loaded
-
@d-healey Yeah, that would solve a big part of the problem!
-
Hmm, it's not entirely trivial to come up with a solution that works for most scenarios, so I think we have to divide it into multiple steps:
- A new function to delete an expansion (but it will not delete the user presets).
- A new parameter to
installExpansionFromPackage()
with a function that is executed once the installation is completed (just like anything with the server API). - A function that extracts the user presets from a .hr1 file over existing presets (I think right now the default is doing nothing if a UserPreset folder is present), but it could simply reuse the logic from the Import all presets from Collection context menu which keeps user made presets and just updates the ones from the expansion.
It would also be good to get the option to delete the hr files automatically after installation is completed.
This could be easily implemented by deleting the file in the finished callback. You could even ask the user in a modal window with
Engine.showYesNoWindow()
... -
@Christoph-Hart This implementation looks good to me. Is there a way to make the "factory" preset read-only?
-
So Mr Freedom wants to restrict his users from modifying the factory content
-
@Christoph-Hart Haha not at all. They can use save as, but if they f*** up their factory presets I don't want to deal with support.
-
@Christoph-Hart hahaha!
-
@Christoph-Hart said in Update expansion presets:
).
A function that extracts the user presets from a .hr1 file over existing presetsThat would be much appreciated
-
-
The install callback also seems like a good oppertunity to activate a license on a remote server.
-
Will this work for deleting multi-part hr archives?
-
Is it possible to call rebuildUserPresets() without using the expansion installer?
I'm looking to add a button in my maintenance panel to rebuild expansion presets, but I can't quite get it to work yet.
I'm using an encryped expansion, and my plug already has an expansion handler in place:const var expHandler = Engine.createExpansionHandler();
Then I'm calling the following with a button:
inline function onRebuild_YesControl(component, value) { if(value) { expHandler.rebuildUserPresets(); } }; Content.getComponent("Rebuild_Yes").setControlCallback(onRebuild_YesControl);
But it's doing nothing.
I've tried the example in docs like this:function installCallback(obj) { if(obj.Status == 2 && isDefined(obj.Expansion)) { // make sure the user presets are updated obj.Expansion.rebuildUserPresets(); } };
But that doesn't work either because obj is waiting for an argument (which never happens cause I'm not using the installer).