New callback: onLoaded
-
I cna put all my post -init logic in here? and every widget will have its initalised value?
Yes
How do I fire this function?
It's just a callback function like any other so will fire automatically after
on init
completes as long as itssaveInPreset
property is true.SO my plugin is NOT saving its internal state.
You have to save the default preset in order for it to load with a different initial state. This is the same with Kontakt's widgets too (except Kontakt instruments only have 1 preset), you always get the last saved state when adding a new instance of the plugin.
-
@d-healey OK great.....
"You have to save the default preset in order for it to load with a different initial state. This is the same with Kontakt's widgets too (except Kontakt instruments only have 1 preset), you always get the last saved state when adding a new instance of the plugin."
BUT:
I've tried to do this and it doesnt do it, I overwrite the labels wiht 99,88,77,66 and press a button - and in the buttons callback I say this;
Engine.saveUserPreset("Factory/Xylophone/Init");
-- I am assuming here that I am saving the preset? is this not right? Beacuase when I delete my plugin from the DAW and reload it the numbers are back at 1111,2222,3333,444
When you say "You have to save the default preset " can you show me how you would do that in a script?
-
@Lindon The savePreset function doesn't work - it has been mentioned a few times to @Christoph-Hart - currently it only works via the preset browser. However you can still use the
storeAllControlsAsPreset
function. -
@d-healey Great!
Whats the actual format of this call? (whats all this Automation stuff?)
Is it:
Content.storeAllControlsAsPreset("default",""); <-- well its not this cause I just tried and no change
or perhaps:
Content.storeAllControlsAsPreset("Factory/Xylophone/Init","");
or something I've missed off - the in-line documentation is not at all clear(as usual)
-
Content.storeAllControlsAsPreset("A", false)
Content.restoreAllControlsFromPreset("A")
This is what I used in my A/B comparison attempt.
-
@d-healey Okaaaay...
these look like asynchronous calls? Are they? and if so how do i know when they are complete?
-
@Lindon As far as I can tell they work the same was as the regular save/load presets (I think these functions exist for creating custom preset browsers). So once the load is completed the onControl callbacks are triggered.
-
A simple solution is this:
inline function onLoaded() { // Whatever you do here, it is guaranteed that every control // is initialised correctly. Console.print("onLoaded"); } // Grab a reference to the panel const var onLoadedPanel = Content.getComponent("onLoadedPanel"); // Makes it fire its control callback at user preset loading et al. onLoadedPanel.set("saveInPreset", true); // Nothing to see, move on... onLoadedPanel.set("visible", false); inline function ononLoadedPanelControl(component, value) { // If this control is not the last one in the list, // make sure to leave enough room by deferring the execution. component.startTimer(500); }; onLoadedPanel.setControlCallback(ononLoadedPanelControl); // We use the inbuilt timer functionality for asynchronous execution onLoadedPanel.setTimerCallback(function() { onLoaded(); this.stopTimer(); });
But again, all your problems are coming from hacking the user preset system for your authorisation method, which will have all kinds of weird side effects (eg. if people share your user presets, they bake their authorisation code into the user preset etc). The only proper solution is to use the upcoming and infamous
Engine.saveAppDataFile(jsonObject, "MyFile.js")
andEngine.loadAppDataFile("MyFile.js")
, which I am going to implement now so that you don't have to fish in the dark any longer :) -
please please please make at least the loadAppDataFile return a success/failure code....
-
Your wishes have been heard:
https://github.com/christophhart/HISE/commit/4c8930b123ad49d9a4df697fa7fbf9348789b70e
BTW, I am working on a full example of implementing a copy protection scheme like you described. I'll put it into the tutorial repo in a few minutes.