Expansion UserPreset: Delete Problem.
-
I'm trying to make a UI button to delete an Expansion UserPreset. How do I tell HISE to delete files from the current expansion UserPresets Folder, rather than from the main UserPresets folder?
What I have so far works but only for presets in the main UserPreset Folder.
Could you help me figure out what I'm missing?
// DELETE EXPANSION PRESET (not working) inline function ondeletePresetControl(component, value) { if (value) { // Define User Preset Folder: (incomplete) reg usrPreFolder = FileSystem.getFolder(FileSystem.UserPresets); // Check if folder is directory: Console.print(usrPreFolder.isDirectory()); // Current Preset Name: reg currentPreset = Engine.getCurrentUserPresetName(); // Define File to be Deleted: reg toDelete = usrPreFolder.getChildFile(currentPreset + ".preset"); // Check if it is a File: Console.print(toDelete.isFile()); // Yes or no window: Engine.showYesNoWindow("Delete", "Are you sure you want to delete preset: " + currentPreset + " ?", function(response) { // Import file name: reg f = toDelete; // IF Delete Confirmed: if (response) { // Delete File: f.deleteFileOrDirectory(); // Load next preset: Engine.loadNextUserPreset(true); } }); } }; Content.getComponent("deletePreset").setControlCallback(ondeletePresetControl);
-
@RastaChess Only declare
local
variables inside inline functions, no var, const, or reg.You can get the user presets folder for an expansion like so:
const dir = FileSystem.getFolder(FileSystem.AppData).getChildFile("Expansions").getChildFile("Expansion Name").getChildFile("User Presets");
-
@d-healey Thank you So Very Much.
I was able to get to the expansion UserPreset folder.
A copule follow up questions if I may.
1 .- How do I get the current expansion name as a string to be inserted in the dir formula?
2.- I made my dir point to the UserPreset Folder from inside my project folder/expansions, rather than the AppData one as you suggested, only cuz that is where I have the presets. Does that matter for when I export the plug in? should I change to the AppData folder before exporting?
const dir = FileSystem.getFolder(FileSystem.Expansions).getChildFile("Expansion Name").getChildFile("UserPresets");
-
@RastaChess said in Expansion UserPreset: Delete Problem.:
- Using
getProperties()
: https://youtu.be/VsQTOxOOd9s?t=593 - You can put a link file in your project's expansions folder to redirect it to the one in appdata.
- Using
-
@d-healey Thanks for sharing. I had looked at that video.
I still can't find a straight forward way to get the actual current expansion name as a string.
Or a way to directly get to the UserPreset Folder of the active Expansion without manually feeding HISE the active expansion name. I need it to change automatically when the user changes expansions. -
@RastaChess said in Expansion UserPreset: Delete Problem.:
I still can't find a straight forward way to get the actual current expansion name as a string
local e = expHandler.getCurrentExpansion(); local expName = e.getProperties().Name;
-
And I just remembered a shortcut to get the preset folder for an expansion.
e.getRootFolder().getChildFile("User Presets");
-
@d-healey oh man! thank you again. works perfectly.