| 1195 | } |
| 1196 | |
| 1197 | void NodeComponent::PopupHelpers::wrapIntoNetwork(NodeBase* node, bool makeCompileable) |
| 1198 | { |
| 1199 | #if USE_BACKEND |
| 1200 | ValueTree nData(PropertyIds::Network); |
| 1201 | |
| 1202 | auto rootTree = node->getRootNetwork()->getValueTree(); |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | // mirror all properties from the parent network; |
| 1207 | for (int i = 0; i < rootTree.getNumProperties(); i++) |
| 1208 | nData.setProperty(rootTree.getPropertyName(i), rootTree.getProperty(rootTree.getPropertyName(i)), nullptr); |
| 1209 | |
| 1210 | nData.setProperty(PropertyIds::ID, node->getId(), nullptr); |
| 1211 | nData.addChild(node->getValueTree().createCopy(), -1, nullptr); |
| 1212 | |
| 1213 | auto ndir = BackendDllManager::getSubFolder(node->getScriptProcessor()->getMainController_(), BackendDllManager::FolderSubType::Networks); |
| 1214 | |
| 1215 | auto tFile = ndir.getChildFile(node->getId()).withFileExtension("xml"); |
| 1216 | |
| 1217 | if (makeCompileable) |
| 1218 | { |
| 1219 | nData.setProperty(PropertyIds::AllowCompilation, makeCompileable, nullptr); |
| 1220 | nData.setProperty(PropertyIds::CompileChannelAmount, node->getCurrentChannelAmount(), nullptr); |
| 1221 | } |
| 1222 | |
| 1223 | if (!tFile.existsAsFile() || PresetHandler::showYesNoWindow("Overwrite file", "Do you want to overwrite the file " + tFile.getFileName())) |
| 1224 | { |
| 1225 | auto xml = nData.createXml(); |
| 1226 | tFile.replaceWithText(xml->createDocument("")); |
| 1227 | |
| 1228 | auto newPath = "project." + node->getId(); |
| 1229 | node->setValueTreeProperty(PropertyIds::FactoryPath, newPath); |
| 1230 | |
| 1231 | PresetHandler::showMessageWindow("Exported chain as new network", "Reload this patch to apply the change"); |
| 1232 | return; |
| 1233 | } |
| 1234 | #endif |
| 1235 | } |
| 1236 | |
| 1237 | void NodeComponent::PopupHelpers::wrapIntoChain(NodeBase* node, MenuActions result, String idToUse) |
| 1238 | { |
nothing calls this directly
no test coverage detected