hi,
I was trying to reproduce the problem of loading a preset from a registered library but can't reproduce it.
I tested it with the last version maybe that's the problem.
Could you tell me witch version are you using ?
or, try this code, does it works ?
Bool InputEvent(const BaseContainer& msg) override
{
// register my own lib
const SDKBrowserURL domain{ "preset://mycolors.lib4d"_s };
const maxon::String libName{ "the library name"_s };
const maxon::String presetName{ "mynewcolors"_s };
const SDKBrowserURL presetUrl = domain + presetName;
Filename presetLibFile{ "D:\\temp\\mycolors\\mycolors.lib4d"_s };
const Int32 bd_index = SDKBrowser::RegisterPresetLibrary(domain, libName, presetLibFile);
AutoAlloc<ColorSwatchData> newColorPreset;
if (newColorPreset == nullptr)
return false;
ColorSwatchGroup* myGroup = newColorPreset->AddGroup();
if (myGroup == nullptr)
return false;
const maxon::ColorA firstColor{ 1.0, 1.0, 1.0, 0 };
const maxon::ColorA secondColor{ 0.4, 1.0, 1.0, 0 };
const maxon::ColorA thirdColor{ 0.1, 0.5, 1.0, 0 };
const maxon::ColorA fourthColor{ 0, 0, 0, 0 };
myGroup->AddColor(firstColor);
myGroup->AddColor(secondColor);
myGroup->AddColor(thirdColor);
myGroup->AddColor(fourthColor);
if (!newColorPreset->SavePreset(presetUrl))
return false;
// normal way of doing it
AutoAlloc<ColorSwatchData> colorPreset;
if (colorPreset == nullptr)
return false;
ColorAlphaArray colorArray;
if (ColorSwatchData::ValidPreset(presetUrl))
{
if (colorPreset->LoadPreset(presetUrl))
{
ColorSwatchGroup* myColorPresetGroup = colorPreset->GetGroupAtIndex(0);
myColorPresetGroup->GetColors(colorArray, false);
for (auto value : colorArray)
ApplicationOutput("color in the array @", value);
return HandleMouseDrag(msg, DRAGTYPE_RGBA_ARRAY, &colorArray, 0);
}
}
return true;
}
Cheers,
Manuel