Presets and JSON



  • OK so a couple of requests - uncovered whilst building my own tag based preset system :

    Can we have an async version of the load and dumpJSON ?

    so sort of:

    Engine.loadFromJSON(data,location, function());
    Engine.dumpAsJSON(location, function());
    

    and can we have a delete for presets:

    Engine.deleteUserPreset(presetname);
    

    but perhaps this works:

    File.deleteFileOrDirectory()
    

    ..but no I cant load presets as Files...or at least know what I've loaded if I do...

    and finally is there a way to turn OFF the dialog warning about overwriting presets?



  • @Lindon -- Ok In case anyone is interested I got the preset delete to work...

    inline function onButton1Control(component, value)
    {
    	var myDir = FileSystem.getFolder(FileSystem.AppData);
    	var myFiles = FileSystem.findFiles(myDir, "*.preset", true);
    	var myString;
    	if(value)
        {
            for(f in myFiles)
            {
                myString = f.toString(3); 
                Console.print(myString);
                if(f.toString(3) == "yourpresetnamehere.preset")
                    f.deleteFileOrDirectory();
            };
        };
    };
    


  • One suggestion, never use var in an inline function. Use local. Otherwise the variable is not scoped to the function.

    Content.makeFrontInterface(600, 500);
    
    inline function myFunction()
    {
        var myVariable = 10;
        return myVariable;
    }
    
    myFunction();
    
    Console.print(myVariable); // 10
    


  • @d-healey yes - thanks I know this - this is just an example - I was just being lazy.



  • @Lindon as an aside -- this (lazy) example above is also an example of how not allowing AppData to resolve to the project dir in development is massively inconvenient.

    In development I can create as many presets as I like - and they are held in the project dir and I can load and save them. But the only way to delete them is to use the above code - which resolves to the compiled plug-ins App Data structure- where these presets are not yet saved.

    Worse I can even (conceptually) get around the "dialog warning about overwriting presets" by deleting a preset (before saving it) and then saving anew with my new meta data, but of course it saves on one spot(project dir) and deletes in another(compiled plugin dir)...

    So let me ask for another "Special Location" in:

    FileSystem.getFolder(var locationType)
    
    • can we please add project folder, which would resolve to - {PROJECT_FOLDER} as an option?

Log in to reply
 

20
Online

1.1k
Users

3.8k
Topics

33.4k
Posts