MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / LoadPrefab

Method LoadPrefab

Source/Prefab.cpp:297–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297void 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
331void Prefab::UpdatePrefabName(std::string path)
332{

Callers 1

SpawnModuleOnTheFlyMethod · 0.80

Calls 8

ofToDataPathFunction · 0.85
GetAudioMutexMethod · 0.80
OpenedOkMethod · 0.80
parseMethod · 0.80
LogEventMethod · 0.80
LoadModulesMethod · 0.80
ClearMethod · 0.45
LoadStateMethod · 0.45

Tested by

no test coverage detected