| 2566 | } |
| 2567 | |
| 2568 | IDrawableModule* ModularSynth::CreateModule(const ofxJSONElement& moduleInfo) |
| 2569 | { |
| 2570 | IDrawableModule* module = nullptr; |
| 2571 | |
| 2572 | try |
| 2573 | { |
| 2574 | if (moduleInfo["comment_out"].asBool()) //hack since json doesn't allow comments |
| 2575 | return nullptr; |
| 2576 | |
| 2577 | std::string type = moduleInfo["type"].asString(); |
| 2578 | type = ModuleFactory::FixUpTypeName(type); |
| 2579 | |
| 2580 | try |
| 2581 | { |
| 2582 | if (type == "transport") |
| 2583 | module = TheTransport; |
| 2584 | else if (type == "scale") |
| 2585 | module = TheScale; |
| 2586 | else |
| 2587 | module = mModuleFactory.MakeModule(type); |
| 2588 | |
| 2589 | if (module == nullptr) |
| 2590 | { |
| 2591 | LogEvent("Couldn't create unknown module type \"" + type + "\"", kLogEventType_Error); |
| 2592 | return nullptr; |
| 2593 | } |
| 2594 | |
| 2595 | if (module->IsSingleton() == false) |
| 2596 | module->CreateUIControls(); |
| 2597 | module->LoadBasics(moduleInfo, type); |
| 2598 | assert(strlen(module->Name()) > 0); |
| 2599 | } |
| 2600 | catch (UnknownModuleException& e) |
| 2601 | { |
| 2602 | LogEvent("Couldn't find referenced module \"" + e.mSearchName + "\" when loading \"" + moduleInfo["name"].asString() + "\"", kLogEventType_Error); |
| 2603 | } |
| 2604 | } |
| 2605 | catch (Json::LogicError& e) |
| 2606 | { |
| 2607 | TheSynth->LogEvent(__PRETTY_FUNCTION__ + std::string(" json error: ") + e.what(), kLogEventType_Error); |
| 2608 | } |
| 2609 | |
| 2610 | return module; |
| 2611 | } |
| 2612 | |
| 2613 | void ModularSynth::SetUpModule(IDrawableModule* module, const ofxJSONElement& moduleInfo) |
| 2614 | { |
no test coverage detected