Browse Source

Add nesting to `SettingsLoader::load`

master
Krisjanis Rijnieks 10 years ago
parent
commit
1b7768de92
  1. 24
      src/Application/SettingsLoader.cpp

24
src/Application/SettingsLoader.cpp

@ -18,6 +18,10 @@ SettingsLoader * SettingsLoader::instance(){
bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, string fileName){
ofxXmlSettings * xmlSettings = new ofxXmlSettings();
string sourceType = "";
string sourceName = "";
BaseSource * source = 0;
if(!xmlSettings->loadFile(fileName)){
ofLogWarning("SettingsLoader::load()") << "Could not load XML settings";
@ -27,19 +31,20 @@ bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, st
if(!xmlSettings->tagExists("surfaces")){
ofLogWarning("SettingsLoader::load()") << "XML settings is empty or has wrong markup";
return false;
}
}else{
xmlSettings->pushTag("surfaces");
int numSurfaces = xmlSettings->getNumTags("surface");
for(int i = 0; i < numSurfaces; i++){
if(xmlSettings->tagExists("surface", i)){
xmlSettings->pushTag("surface", i);
// attempt to load surface source
if(xmlSettings->tagExists("source", 0)){
xmlSettings->pushTag("source");
string sourceType = xmlSettings->getValue("source-type", "");
string sourceName = xmlSettings->getValue("source-name", "");
BaseSource * source = 0;
sourceType = xmlSettings->getValue("source-type", "");
sourceName = xmlSettings->getValue("source-name", "");
if(sourceName != "" && sourceName != "none" && sourceType != ""){
// Load source depending on type
@ -62,6 +67,9 @@ bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, st
}
xmlSettings->popTag(); // source
}
if(xmlSettings->tagExists("vertices", 0)){
xmlSettings->pushTag("vertices");
int vertexCount = xmlSettings->getNumTags("vertex");
@ -79,10 +87,16 @@ bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, st
surfaces.push_back(quadSurface);
}
//xmlSettings->popTag(); // vertices
// this is done in getTriangleSurface and getQuadSurface
}
xmlSettings->popTag(); // surface
}
}
xmlSettings->popTag(); // surfaces
}
return true;
}

Loading…
Cancel
Save