diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-26 22:47:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-26 22:47:45 +0300 |
commit | 83981f76348655507d225aca220893e668b09bdc (patch) | |
tree | a86b9a28bb584bed5a6f397bc0b47aba908d0f82 /src/resources/db | |
parent | 8f3d5cce14912a4c955a02f50a13130ca15b585e (diff) | |
download | manaplus-83981f76348655507d225aca220893e668b09bdc.tar.gz manaplus-83981f76348655507d225aca220893e668b09bdc.tar.bz2 manaplus-83981f76348655507d225aca220893e668b09bdc.tar.xz manaplus-83981f76348655507d225aca220893e668b09bdc.zip |
Add support for loading stats pages from stats.xml
Diffstat (limited to 'src/resources/db')
-rw-r--r-- | src/resources/db/statdb.cpp | 16 | ||||
-rw-r--r-- | src/resources/db/statdb.h | 4 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp index b68ee9576..0e7175310 100644 --- a/src/resources/db/statdb.cpp +++ b/src/resources/db/statdb.cpp @@ -35,6 +35,7 @@ namespace bool mLoaded = false; static std::vector<BasicStat> mBasicStats; static std::map<std::string, std::vector<BasicStat> > mStats; + static std::vector<std::string> mPages; } // namespace void StatDb::addDefaultStats() @@ -70,9 +71,14 @@ const std::vector<BasicStat> &StatDb::getBasicStats() return mBasicStats; } -const std::vector<BasicStat> &StatDb::getExtendedStats() +const std::vector<BasicStat> &StatDb::getStats(const std::string &page) { - return mStats["extended"]; + return mStats[page]; +} + +const std::vector<std::string> &StatDb::getPages() +{ + return mPages; } void StatDb::load() @@ -116,6 +122,7 @@ static void loadStats(const XmlNodePtr rootNode, { const int maxAttr = static_cast<int>(Attributes::MAX_ATTRIBUTE); std::vector<BasicStat> &stats = mStats[page]; + mPages.push_back(page); for_each_xml_child_node(node, rootNode) { if (xmlNameEqual(node, "stat")) @@ -167,11 +174,12 @@ void StatDb::loadXmlFile(const std::string &fileName, } else if (xmlNameEqual(node, "extended")) { - loadStats(node, "extended"); + // TRANSLATORS: stats page name + loadStats(node, _("Extended")); } else if (xmlNameEqual(node, "page")) { - std::string page = XML::getProperty(node, "name", ""); + std::string page = XML::langProperty(node, "name", ""); if (page.empty()) { reportAlways("Page without name in stats.xml"); diff --git a/src/resources/db/statdb.h b/src/resources/db/statdb.h index 96392d06f..f98eac111 100644 --- a/src/resources/db/statdb.h +++ b/src/resources/db/statdb.h @@ -42,7 +42,9 @@ namespace StatDb const std::vector<BasicStat> &getBasicStats(); - const std::vector<BasicStat> &getExtendedStats(); + const std::vector<BasicStat> &getStats(const std::string &page); + + const std::vector<std::string> &getPages(); } // namespace StatDb #endif // RESOURCES_DB_STATDB_H |