Permalink
Browse files

atlas: clean up xml schema some

  • Loading branch information...
1 parent d916d0f commit 9546c7cdfbf56a804e4aa0bfefa796a8776b196b theuni committed May 22, 2012
Showing with 19 additions and 10 deletions.
  1. +9 −6 tools/atlas/texture-atlas.cpp
  2. +10 −4 xbmc/guilib/AtlasReader.cpp
@@ -234,10 +234,6 @@ void CImageTree::AddIndex(TiXmlElement *root, std::string filename)
TiXmlElement * texture = new TiXmlElement("texture");
root->LinkEndChild(texture);
- msg = new TiXmlElement("filename");
- msg->LinkEndChild( new TiXmlText(filename.substr(filename.find_last_of('/') +1).c_str()));
- texture->LinkEndChild( msg );
-
msg = new TiXmlElement("texturename");
msg->LinkEndChild( new TiXmlText(name.substr(name.find_last_of('/') +1).c_str()));
texture->LinkEndChild(msg);
@@ -454,6 +450,8 @@ int main(int argc, char *argv[])
}
int count = 0;
+ TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" );
+ doc.LinkEndChild( decl );
TiXmlElement *root = new TiXmlElement("atlasmap");
doc.LinkEndChild(root);
std::string filename;
@@ -464,10 +462,15 @@ int main(int argc, char *argv[])
ss << count;
filename = std::string(argv[1])+"/media-2048-" + ss.str() + ".png";
imageTree->SaveImage(filename);
- printf("texture-atlas: created %s\n",filename.c_str());
- imageTree->AddIndex(root, filename);
+
+ TiXmlElement *msg = new TiXmlElement("atlas");
+ root->LinkEndChild(msg);
+ msg->SetAttribute("filename",filename.substr(filename.find_last_of('/') +1).c_str());
+
+ imageTree->AddIndex(msg, filename);
imageTree->Print();
count++;
+ printf("texture-atlas: created %s\n",filename.c_str());
}
filename=std::string(argv[1])+"/Textures.xml";
doc.SaveFile(filename);
@@ -47,6 +47,7 @@ bool CAtlasReader::IsOpen() const
bool CAtlasReader::LoadXML(CStdString strFile)
{
TiXmlDocument xmlDoc;
+ CStdString strFileName;
if(!xmlDoc.LoadFile(strFile))
{
@@ -63,16 +64,19 @@ bool CAtlasReader::LoadXML(CStdString strFile)
return false;
}
- const TiXmlElement *pChild = pRootElement->FirstChildElement("texture");
- while (pChild)
+ const TiXmlElement *pAtlas = pRootElement->FirstChildElement("atlas");
+ while (pAtlas)
{
+ pAtlas->QueryStringAttribute("filename",&strFileName);
+ const TiXmlElement *pChild = pAtlas->FirstChildElement("texture");
+ while (pChild)
+ {
+
int x = 0, y = 0, width = 0, height = 0;
CXBTFFile file;
CXBTFFrame frame;
- CStdString strFileName;
- XMLUtils::GetString(pChild, "filename", strFileName);
CStdString strTextureName;
XMLUtils::GetString(pChild, "texturename", strTextureName);
@@ -95,6 +99,8 @@ bool CAtlasReader::LoadXML(CStdString strFile)
pChild = pChild->NextSiblingElement("texture");
}
+ pAtlas = pAtlas->NextSiblingElement("atlas");
+ }
return true;
}

0 comments on commit 9546c7c

Please sign in to comment.