diff --git a/core/src/MegaMolGraph_Convenience.cpp b/core/src/MegaMolGraph_Convenience.cpp index 54ddf122cc..f6a9a7b46f 100644 --- a/core/src/MegaMolGraph_Convenience.cpp +++ b/core/src/MegaMolGraph_Convenience.cpp @@ -71,19 +71,35 @@ std::string megamol::core::MegaMolGraph_Convenience::SerializeCalls() const { } #include "mmcore/param/ButtonParam.h" +#include "mmcore/param/FilePathParam.h" std::string megamol::core::MegaMolGraph_Convenience::SerializeModuleParameters(std::string const& module_name) const { std::string serParams; + auto parameter_serialization = [](std::string const& name, std::string const& value) { + return "mmSetParamValue(\"" + name + "\",[=[" + value + "]=])\n"; + }; + for (auto& paramSlot : get(m_graph_ptr).EnumerateModuleParameterSlots(module_name)) { - // it seems serialiing button params is illegal + // it seems serializing button params is illegal if (auto* p_ptr = paramSlot->template Param()) { continue; } + auto name = std::string{paramSlot->FullName()}; // as FullName() prepends :: to module names, normalize multiple leading :: in parameter name path name = "::" + name.substr(name.find_first_not_of(':')); + + // file path params hold a file path which might be relative to some project directory + // asking for file_param->ValueString() gives us back an absolute path accomodated for the project directory + // instead we need to explicitly ask to the relative path + if (auto* p_ptr = paramSlot->template Param()) { + auto value = p_ptr->GetRelativePathValueString(); + serParams.append(parameter_serialization(name, value)); + continue; + } + auto value = paramSlot->Parameter()->ValueString(); - serParams.append("mmSetParamValue(\"" + name + "\",[=[" + value + "]=])\n"); + serParams.append(parameter_serialization(name, value)); } return serParams + '\n';