| 631 | |
| 632 | |
| 633 | Result CtrlrPanel::writeLuaMethod(const File &parentDir, ValueTree *method) |
| 634 | { |
| 635 | if (method == nullptr) |
| 636 | return Result::fail("Method name is missing"); |
| 637 | |
| 638 | const String methodName = method->getProperty(Ids::luaMethodName); |
| 639 | const String methodCode = method->getProperty(Ids::luaMethodCode); |
| 640 | if (methodName.isEmpty()) |
| 641 | return Result::fail("Method name is empty"); |
| 642 | |
| 643 | // Create file |
| 644 | const File methodFile = parentDir.getNonexistentChildFile(methodName,".lua",false); |
| 645 | if (methodFile.replaceWithText(methodCode)) |
| 646 | { |
| 647 | method->setProperty(Ids::luaMethodName, methodFile.getFileNameWithoutExtension(), nullptr); |
| 648 | method->setProperty(Ids::luaMethodSourcePath, methodFile.getRelativePathFrom(getPanelLuaDir()), nullptr); |
| 649 | method->setProperty(Ids::luaMethodSource, (int)CtrlrLuaMethod::codeInFile, nullptr); |
| 650 | method->removeProperty(Ids::luaMethodCode,nullptr); |
| 651 | return Result::ok(); |
| 652 | } |
| 653 | else |
| 654 | { |
| 655 | AlertWindow::showMessageBox(AlertWindow::WarningIcon, "Could not save lua method", "Could not save lua method", "OK"); |
| 656 | return (Result::fail("saveLuaMethod: could not save lua method.")); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | Result CtrlrPanel::writeLuaMethodGroup(const File &parentDir, ValueTree *methodGroup) |
| 661 | { |
nothing calls this directly
no test coverage detected