| 1042 | } |
| 1043 | |
| 1044 | void setState(const char* const key, const char* const value) override |
| 1045 | { |
| 1046 | #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS |
| 1047 | if (std::strcmp(key, "param") == 0) |
| 1048 | { |
| 1049 | long long moduleId = 0; |
| 1050 | int paramId = 0; |
| 1051 | float paramValue = 0.f; |
| 1052 | { |
| 1053 | const ScopedSafeLocale cssl; |
| 1054 | std::sscanf(value, "%lld:%d:%f", &moduleId, ¶mId, ¶mValue); |
| 1055 | } |
| 1056 | |
| 1057 | rack::engine::Module* const module = context->engine->getModule(moduleId); |
| 1058 | DISTRHO_SAFE_ASSERT_RETURN(module != nullptr,); |
| 1059 | |
| 1060 | context->engine->setParamValue(module, paramId, paramValue); |
| 1061 | return; |
| 1062 | } |
| 1063 | #endif |
| 1064 | |
| 1065 | #if CARDINAL_VARIANT_MINI || !defined(HEADLESS) |
| 1066 | if (std::strcmp(key, "windowSize") == 0) |
| 1067 | { |
| 1068 | fState.windowSize = value; |
| 1069 | return; |
| 1070 | } |
| 1071 | #endif |
| 1072 | |
| 1073 | if (std::strcmp(key, "comment") == 0) |
| 1074 | { |
| 1075 | fState.comment = value; |
| 1076 | return; |
| 1077 | } |
| 1078 | |
| 1079 | if (std::strcmp(key, "screenshot") == 0) |
| 1080 | { |
| 1081 | fState.screenshot = value; |
| 1082 | return; |
| 1083 | } |
| 1084 | |
| 1085 | if (std::strcmp(key, "patch") != 0) |
| 1086 | return; |
| 1087 | if (fAutosavePath.empty()) |
| 1088 | return; |
| 1089 | |
| 1090 | #if CARDINAL_VARIANT_MINI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS |
| 1091 | rack::system::removeRecursively(fAutosavePath); |
| 1092 | rack::system::createDirectories(fAutosavePath); |
| 1093 | |
| 1094 | FILE* const f = std::fopen(rack::system::join(fAutosavePath, "patch.json").c_str(), "w"); |
| 1095 | DISTRHO_SAFE_ASSERT_RETURN(f != nullptr,); |
| 1096 | |
| 1097 | std::fwrite(value, std::strlen(value), 1, f); |
| 1098 | std::fclose(f); |
| 1099 | #else |
| 1100 | const std::vector<uint8_t> data(d_getChunkFromBase64String(value)); |
| 1101 | |