Parse getUserPresetList() output into 2d array
-
@Morphoice said in Parse getUserPresetList() output into 2d array:
Engine.loadUserPreset(Engine.getUserPresetList()[value - 1]+".preset");
This is only going to work in the combo box's callback. In a label's callback the value will be the label's text.
-
@d-healey exactly, hence my question how I can get to load it in the label :) don't I need to do that there instead of in the combo? Or am I missing the point?
-
@Morphoice If I'm understanding correctly you have the preset name in the label's text/value, so what about
Engine.loadUserPreset(value);
-
@d-healey just the preset name, not the full path to the preset, it needs the full path to load
-
@Morphoice Isn't it a hidden label and meant to store the full path?
-
@d-healey if I understood lindon's approach correctly, the combo box is what's hidden, the label displays the name, at least that's what I got from his snippet
-
@Morphoice Then I defer to Lindon.
-
@Lindon @d-healey I guess the text label could also be invisible and the combobox visible so I get the full path in the label callback
but if I call loadUserPreset there it just runs into a loop loading the preset and outputting hundreds of console messages until HISE crashes after a minute or so
const var Presets = Content.getComponent("Presets"); // The Combobox const var CurrentPreset = Content.getComponent("CurrentPreset"); // The Label inline function onPresetsControl(component, value) { if (!value) return; local presetPath = Engine.getUserPresetList()[value - 1]; CurrentPreset.set("text", presetPath); CurrentPreset.changed(); } Presets.setControlCallback(onPresetsControl); inline function onCurrentPresetControl(component, value) { Engine.loadUserPreset(value+".preset"); Console.print(value); }; CurrentPreset.setControlCallback(onCurrentPresetControl);
if I put the loadUserPreset into the combobox callback it hangs compiling and crashes after a while too
-
@Morphoice You need to disable saveInPreset for the component that is loading the preset, otherwise you get an infinite loop.
-
@Morphoice so in your combobox callback that is setting the label -, you need a switch that says "hey time to load a preset", that the label (which is saveInPreset) reads and ONLY loads if this == true,