HISE Logo Forum
    • Categories
    • Register
    • Login

    Expansion UserPreset: Delete Problem.

    Scheduled Pinned Locked Moved General Questions
    8 Posts 2 Posters 210 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CyberGenC
      CyberGen
      last edited by

      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);
      	
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @CyberGen
        last edited by

        @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");

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        CyberGenC 1 Reply Last reply Reply Quote 0
        • CyberGenC
          CyberGen @d.healey
          last edited by CyberGen

          @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");
          
          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @CyberGen
            last edited by

            @RastaChess said in Expansion UserPreset: Delete Problem.:

            1. Using getProperties(): https://youtu.be/VsQTOxOOd9s?t=593
            2. You can put a link file in your project's expansions folder to redirect it to the one in appdata.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            CyberGenC 1 Reply Last reply Reply Quote 0
            • CyberGenC
              CyberGen @d.healey
              last edited by

              @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.

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @CyberGen
                last edited by

                @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;
                

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                1 Reply Last reply Reply Quote 1
                • d.healeyD
                  d.healey
                  last edited by

                  And I just remembered a shortcut to get the preset folder for an expansion.

                  e.getRootFolder().getChildFile("User Presets");

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  CyberGenC 1 Reply Last reply Reply Quote 1
                  • CyberGenC
                    CyberGen @d.healey
                    last edited by

                    @d-healey oh man! thank you again. works perfectly.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post

                    19

                    Online

                    1.7k

                    Users

                    11.8k

                    Topics

                    102.5k

                    Posts