How to save GUI properties



  • After making a change in the Interface Property Editor I press compile and get a pop that says - There are some properties that are not saved, press ok to discard them or cancel to abort compiling - but how do I save them? I figure this must be a recent addition because I don't recall this problem before.


  • administrators

    This is a glitch that appears when it can't find the JSON properties in the onInit callback. Can you post some example code that shows this behaviour?



  • Well this is the script I'm currently working on where I've noticed the problem - there is no JSON in it.

    /**
     * Title: Preset Hander v1.0.0.js
     * Author: David Healey
     * Date: 02/07/2017
     * Modified: 03/07/2017
     * License: GPLv3 - https://www.gnu.org/licenses/gpl-3.0.en.html
    */
    
    //INIT
    Content.makeFrontInterface(600, 100);
    
    // Create a storage panel, hide it, and save it in the preset
    const var storagePanel = Content.addPanel("storagePanel", 0, 0);
    storagePanel.set("visible", false);
    storagePanel.set("saveInPreset", true);
    
    // Create object that will hold the preset values all modules.
    global userPresetData = {};
    
    // Set the global storage as widget value for the hidden panel.
    // Important: this will not clone the object, but share a reference!
    storagePanel.setValue(userPresetData);
    
    const var samplerIds = Synth.getIdList("Sampler");
    const var effectIds = Synth.getIdList("Effect");
    const var modulatorIds = Synth.getIdList("Modulator");
    const var midiProcessorIds = Synth.getIdList("Script Processor");
    
    const var samplers = [];
    const var effects = [];
    const var modulators = [];
    const var midiProcessors = [];
    
    for (s in samplerIds)
    {
    	samplers.push(Synth.getChildSynth(s));
    }
    
    for (e in effectIds)
    {
    	effects.push(Synth.getEffect(e));
    }
    
    for (m in modulatorIds)
    {
    	modulators.push(Synth.getModulator(m));
    }
    
    for (mp in midiProcessorIds)
    {
    	if (Engine.matchesRegex(mp, "(?=.*reset)(?=.*andler)")) continue; //Skip this processor
    	midiProcessors.push(Synth.getMidiProcessor(mp));
    }
    
    //GUI
    const var bank = Content.addLabel("Preset Bank", 0, 10);
    bank.set("editable", true);
    
    const var category = Content.addLabel("Preset Category", 150, 10);
    category.set("editable", true);
    
    const var name = Content.addLabel("Preset Name", 300, 10);
    name.set("editable", true);
    
    const var save = Content.addButton("Save", 450, 0);
    save.set("saveInPreset", false);
    
    
    //FUNCTIONS
    function savePreset()
    {
    	for (i = 0; i < samplers.length; i++)
    	{
    		if (userPresetData.samplers == void) userPresetData.samplers = [];
    		userPresetData.samplers[i] = samplers[i].exportState();
    	}
    
    	for (i = 0; i < effects.length; i++)
    	{
    		if (userPresetData.effects == void) userPresetData.effects = [];
    		userPresetData.effects[i] = effects[i].exportState();
    	}
    
    	for (i = 0; i < modulators.length; i++)
    	{
    		if (userPresetData.modulators == void) userPresetData.modulators = [];
    		userPresetData.modulators[i] = modulators[i].exportState();
    	}
    
    	for (i = 0; i < midiProcessors.length; i++)
    	{
    		if (userPresetData.midiProcessors == void) userPresetData.midiProcessors = [];
    		userPresetData.midiProcessors[i] = midiProcessors[i].exportState();
    	}
    
    	Content.storeAllControlsAsPreset(bank + "/" + category + "/" + name.getValue() + ".preset");
    }
    
    function restorePreset()
    {
    	userPresetData = storagePanel.getValue(); //Restore from panel
    
    	if (userPresetData.samplers.length > 0)
    	{
    		for (i = 0; i < samplers.length; i++)
    		{
    			samplers[i].restoreState(userPresetData.samplers[i]);
    		}
    	}
    
    	if (userPresetData.effects.length > 0)
    	{
    		for (i = 0; i < effects.length; i++)
    		{
    			effects[i].restoreState(userPresetData.effects[i]);
    		}
    	}
    
    	if (userPresetData.modulators.length > 0)
    	{
    		for (i = 0; i < modulators.length; i++)
    		{
    			modulators[i].restoreState(userPresetData.modulators[i]);
    		}
    	}
    
    	if (userPresetData.midiProcessors.length > 0)
    	{
    		for (i = 0; i < midiProcessors.length; i++)
    		{
    			midiProcessors[i].restoreState(userPresetData.midiProcessors[i]);
    		}
    	}
    }
    
    //CALLBACKS
    function onNoteOn()
    {
    	
    }
    function onNoteOff()
    {
    	
    }
    function onController()
    {
    	
    }
    function onTimer()
    {
    	
    }
    function onControl(number, value)
    {
    	switch(number)
    	{
    		case storagePanel:
    			restorePreset();
    		break;
    
    		case bank: case category: case name:
    			number.setValue("");
    		break;
    
    		case save:
    			savePreset();
    			save.setValue(0);
    		break;
    	}
    }
    

  • administrators

    Well, the variable name and the widget IDs don't match. This is not the end of the world, but the Interface Designer is looking for a line with the structure:

    const var Xxx = Content.addSomething("Xxx", x, y);
    

    and if it doesn't find this line, it won't insert anything into the code. When you compile, it compares the code with the intermediate state that the current widget has (if you eg. move it around, it won't get recompiled, but the internal property gets changed). A mismatch between those two states cause this error message.

    Long story short: Use the same variable name 🙂



  • Oh yeah, I never use the JSON and had completely forgotten about that. I'm just using the property editor to get the correct colour codes 🙂


Log in to reply
 

2
Online

339
Users

1.0k
Topics

7.1k
Posts

Looks like your connection to Forum was lost, please wait while we try to reconnect.