| 295 | } |
| 296 | |
| 297 | void Prefab::LoadPrefab(std::string loadPath) |
| 298 | { |
| 299 | sLoadingPrefab = true; |
| 300 | |
| 301 | ScopedMutex mutex(TheSynth->GetAudioMutex(), "LoadPrefab()"); |
| 302 | std::lock_guard<std::recursive_mutex> renderLock(TheSynth->GetRenderLock()); |
| 303 | |
| 304 | mModuleContainer.Clear(); |
| 305 | |
| 306 | FileStreamIn in(ofToDataPath(loadPath)); |
| 307 | |
| 308 | assert(in.OpenedOk()); |
| 309 | |
| 310 | std::string jsonString; |
| 311 | in >> jsonString; |
| 312 | ofxJSONElement root; |
| 313 | bool loaded = root.parse(jsonString); |
| 314 | |
| 315 | if (!loaded) |
| 316 | { |
| 317 | TheSynth->LogEvent("Couldn't load, error parsing " + loadPath, kLogEventType_Error); |
| 318 | TheSynth->LogEvent("Try loading it up in a json validator", kLogEventType_Error); |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | UpdatePrefabName(loadPath); |
| 323 | |
| 324 | mModuleContainer.LoadModules(root["modules"]); |
| 325 | |
| 326 | mModuleContainer.LoadState(in); |
| 327 | |
| 328 | sLoadingPrefab = false; |
| 329 | } |
| 330 | |
| 331 | void Prefab::UpdatePrefabName(std::string path) |
| 332 | { |
no test coverage detected