Browse Source

Fix confusing `xml->push` in one method and `xml->pop` in another

master
Krisjanis Rijnieks 10 years ago
parent
commit
d1f483899b
  1. 128
      src/Application/SettingsLoader.cpp

128
src/Application/SettingsLoader.cpp

@ -69,26 +69,26 @@ bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, st
xmlSettings->popTag(); // source xmlSettings->popTag(); // source
} }
int vertexCount = 0;
if(xmlSettings->tagExists("vertices", 0)){ if(xmlSettings->tagExists("vertices", 0)){
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
int vertexCount = xmlSettings->getNumTags("vertex"); vertexCount = xmlSettings->getNumTags("vertex");
xmlSettings->popTag(); // vertices
}
if(vertexCount == 3){ if(vertexCount == 3){
BaseSurface * triangleSurface = getTriangleSurface(xmlSettings); BaseSurface * triangleSurface = getTriangleSurface(xmlSettings);
if(sourceName != "none" && source != 0){ if(sourceName != "none" && source != 0){
triangleSurface->setSource(source); triangleSurface->setSource(source);
}
surfaces.push_back(triangleSurface);
}else if(vertexCount == 4){
BaseSurface * quadSurface = getQuadSurface(xmlSettings);
if(sourceName != "none" && source != 0){
quadSurface->setSource(source);
}
surfaces.push_back(quadSurface);
} }
surfaces.push_back(triangleSurface);
//xmlSettings->popTag(); // vertices }else if(vertexCount == 4){
// this is done in getTriangleSurface and getQuadSurface BaseSurface * quadSurface = getQuadSurface(xmlSettings);
if(sourceName != "none" && source != 0){
quadSurface->setSource(source);
}
surfaces.push_back(quadSurface);
} }
xmlSettings->popTag(); // surface xmlSettings->popTag(); // surface
@ -171,28 +171,32 @@ bool SettingsLoader::save(SurfaceStack & surfaces, string fileName){
BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices; vector <ofVec2f> vertices;
if(xmlSettings->tagExists("vertex", 0)){ if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertex", 0); xmlSettings->pushTag("vertices");
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 1)){ if(xmlSettings->tagExists("vertex", 0)){
xmlSettings->pushTag("vertex", 1); xmlSettings->pushTag("vertex", 0);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f))); xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag(); xmlSettings->popTag();
} }
if(xmlSettings->tagExists("vertex", 1)){
xmlSettings->pushTag("vertex", 1);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 2)){ if(xmlSettings->tagExists("vertex", 2)){
xmlSettings->pushTag("vertex", 2); xmlSettings->pushTag("vertex", 2);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 100.0f))); xmlSettings->getValue("y", 100.0f)));
xmlSettings->popTag(); xmlSettings->popTag();
} }
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords; vector <ofVec2f> texCoords;
@ -236,35 +240,39 @@ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices; vector <ofVec2f> vertices;
if(xmlSettings->tagExists("vertex", 0)){ if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertex", 0); xmlSettings->pushTag("vertices");
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f))); if(xmlSettings->tagExists("vertex", 0)){
xmlSettings->popTag(); xmlSettings->pushTag("vertex", 0);
} vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 1)){ if(xmlSettings->tagExists("vertex", 1)){
xmlSettings->pushTag("vertex", 1); xmlSettings->pushTag("vertex", 1);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 0.0f))); xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag(); xmlSettings->popTag();
} }
if(xmlSettings->tagExists("vertex", 2)){ if(xmlSettings->tagExists("vertex", 2)){
xmlSettings->pushTag("vertex", 2); xmlSettings->pushTag("vertex", 2);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 100.0f))); xmlSettings->getValue("y", 100.0f)));
xmlSettings->popTag(); xmlSettings->popTag();
} }
if(xmlSettings->tagExists("vertex", 3)){ if(xmlSettings->tagExists("vertex", 3)){
xmlSettings->pushTag("vertex", 3); xmlSettings->pushTag("vertex", 3);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 100.0f))); xmlSettings->getValue("y", 100.0f)));
xmlSettings->popTag(); xmlSettings->popTag();
} }
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords; vector <ofVec2f> texCoords;

Loading…
Cancel
Save