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

Loading…
Cancel
Save