diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2014-03-18 14:58:50 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:12:54 +0300 |
commit | a2b5bb80468f80100caa80ee54c56669c8cddda3 (patch) | |
tree | e323b2f12780dbb3339da33b9df3d4d9d50893eb /skin_generator | |
parent | 774abd356b7e8a965d6f57886785916f1d3e4c21 (diff) |
[drape] new structure skn file
Diffstat (limited to 'skin_generator')
-rw-r--r-- | skin_generator/main.cpp | 12 | ||||
-rw-r--r-- | skin_generator/skin_generator.cpp | 43 | ||||
-rw-r--r-- | skin_generator/skin_generator.hpp | 1 |
3 files changed, 48 insertions, 8 deletions
diff --git a/skin_generator/main.cpp b/skin_generator/main.cpp index e065691538..fd1f68621c 100644 --- a/skin_generator/main.cpp +++ b/skin_generator/main.cpp @@ -1,6 +1,7 @@ #include "skin_generator.hpp" #include <QtCore/QFile> +#include <QtCore/QString> #include <QApplication> #include <QtXml/QXmlSimpleReader> @@ -35,19 +36,14 @@ int main(int argc, char *argv[]) std::vector<std::string> suffixes; suffixes.push_back(FLAGS_skinSuffix); - /* - gen.processSearchIcons(FLAGS_searchIconsSrcPath, - FLAGS_searchCategories, - FLAGS_searchIconsOutPath, - FLAGS_searchIconWidth, - FLAGS_searchIconHeight); - */ - gen.processSymbols(FLAGS_symbolsDir, FLAGS_skinName, symbolSizes, suffixes); gen.renderPages(); gen.writeToFile(FLAGS_skinName + FLAGS_skinSuffix); + QString newSkin(FLAGS_skinName.c_str()); + newSkin.replace("basic", "symbols"); + gen.writeToFileNewStyle(newSkin.toStdString() + FLAGS_skinSuffix); return 0; } diff --git a/skin_generator/skin_generator.cpp b/skin_generator/skin_generator.cpp index fa27d1f45f..77c2e0ddb6 100644 --- a/skin_generator/skin_generator.cpp +++ b/skin_generator/skin_generator.cpp @@ -309,4 +309,47 @@ namespace tools return true; } + + void SkinGenerator::writeToFileNewStyle(const string & skinName) + { + QDomDocument doc = QDomDocument("skin"); + QDomElement rootElem = doc.createElement("root"); + doc.appendChild(rootElem); + + for (vector<SkinPageInfo>::const_iterator pageIt = m_pages.begin(); pageIt != m_pages.end(); ++pageIt) + { + QDomElement fileNode = doc.createElement("file"); + fileNode.setAttribute("width", pageIt->m_width); + fileNode.setAttribute("height", pageIt->m_height); + rootElem.appendChild(fileNode); + + for (vector<SymbolInfo>::const_iterator symbolIt = pageIt->m_symbols.begin(); + symbolIt != pageIt->m_symbols.end(); ++symbolIt) + { + m2::RectU r = pageIt->m_packer.find(symbolIt->m_handle).second; + QDomElement symbol = doc.createElement("symbol"); + symbol.setAttribute("minX", r.minX()); + symbol.setAttribute("minY", r.minY()); + symbol.setAttribute("maxX", r.maxX()); + symbol.setAttribute("maxY", r.maxY()); + symbol.setAttribute("name", symbolIt->m_symbolID.toLower()); + fileNode.appendChild(symbol); + } + } + string extName = ".sdf"; + QFile::remove(QString((skinName + extName).c_str())); + + if (QFile::exists((skinName + extName).c_str())) + throw std::exception(); + + QFile file(QString((skinName + extName).c_str())); + + LOG(LINFO, ("writing skin into ", skinName + extName)); + + if (!file.open(QIODevice::ReadWrite)) + throw std::exception(); + QTextStream ts(&file); + ts.setCodec("UTF-8"); + ts << doc.toString(); + } } diff --git a/skin_generator/skin_generator.hpp b/skin_generator/skin_generator.hpp index d0ad8eaace..7484231441 100644 --- a/skin_generator/skin_generator.hpp +++ b/skin_generator/skin_generator.hpp @@ -79,5 +79,6 @@ namespace tools vector<string> const & suffix); void renderPages(); bool writeToFile(string const & skinName); + void writeToFileNewStyle(string const & skinName); }; } // namespace tools |