User Preference System
-
What It Is
This is a user data file snippet that is separate from HISE's preset system, with an emphasis on reliability. A common use would be user preferences.
EDIT: Amended with bug fix.
EDIT: HISE experts, please improve my code, so it can become a HISE snippet, and help newer HISE developers learn and implement a preferences and automatic update system for their plugins.
How It Works
A global JSON record is created to hold to the user data. In this example, the data is the plugin version, the date of the last update check, and the values of several components (including one for automatic update checks). At startup, the code checks for the user file. If it doesn't exist, it's created, with default values written to it.
The user has four buttons, which write the user's preferences, restore the user's preferences, reset everything to system defaults, and to accept (but not write) the preferences on the screen.
For update-checking: If the option is active, then whenever the code runs, it checks a server to see if a newer version is available. It also writes the date and time this occurred, so update checks are only done automatically (if selected) once per day. The user can also check manually, also by selecting the automatic update option.
If the server cannot be reached, and the user file cannot be written, the code continues operating. In that event, hard-coded values are used for the user data.
There is a section for callbacks when the user selects on-screen user-data parameters (e.g. buttons), and a second set of callbacks for when the user data is read in. Likewise, the on-screen component values are restored.
Extricating the snippet from my plugin required removal of most of the error-checking functionality, though the skeletons remain to plugin them in.
The Snippet Version
I've extracted a version of the User Data File code from my plugin, and tried to preserve as much functionality as possible. I have not fully-tested this snippet—if something doesn't work, the code and comments should be clear enough to provide solutions. (Or just ask.)
User Data File
Online JSON Update Record
Snippet UI
Snippet Code
HiseSnippet 5226.3oc68rsbaijcTyXN6PlcSsas4g7XGVoFSkQl51bUZ8LlhWr3XIRsjT1qKWtX0jnoHVCBvfFPxrlUU4uk7v9creD4CH07Ej2yCaNmta.zfDjhTWroSDevV.n6y4zceNm9bCMNw0oGiycbSsV11iGwRs1uNcqw1dCJMfZZmpV4Tq8YoaOvjm5fwinbNyH0Zq8oOEe1ZYdPJwu+6e7.pE0tGK5VoR8bGydriLGZ5Ec2SdxyLsrpRMXsMGp05u5I054XWxwxwGniOM8VoFQ68F5Yr5TrYeR5TGR4CRs1+VZ5t6Zz+a9lu66M58Ue81eee52Zzq6te+WyL14q1k88LCiucWit86CTcECSOG2VdTOFO0ZO3.GiwsF3bgsDAO2ja10hgW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qWS8vsCdXpgzdtNc5IsNB+PA94h6.zjs3ipXlzGiWS1NkvhI844glFlc50KNnlpi6bc63tW2N9UW2N90W2N9MW2N9sW2N9cWcGwySuhphIGDaRk53SpHL2bs0pXiIUUvsl5+UFpof.
-
@clevername27 Looks Epic! Thanks for sharing!
-
This post is deleted! -
@orange
;( -
@udalilprofile I've fixed that, thanks for pointing it out. (The veritable
makeFrontInterface()
went missing.)