From f55d6f7c27db71b7327d4de4ee294bcaf7b82f6b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Jan 2014 18:19:20 +0300 Subject: add support for include in sounds.xml. --- src/resources/db/sounddb.cpp | 15 +++++++++++++-- src/resources/db/sounddb.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/resources/db/sounddb.cpp b/src/resources/db/sounddb.cpp index 639156909..ca7d0d654 100644 --- a/src/resources/db/sounddb.cpp +++ b/src/resources/db/sounddb.cpp @@ -37,8 +37,12 @@ namespace void SoundDB::load() { unload(); + loadXmlFile(paths.getStringValue("soundsFile")); +} - XML::Document *doc = new XML::Document(paths.getStringValue("soundsFile")); +void SoundDB::loadXmlFile(const std::string &fileName) +{ + XML::Document *doc = new XML::Document(fileName); const XmlNodePtr root = doc->rootNode(); if (!root || !xmlNameEqual(root, "sounds")) @@ -49,7 +53,14 @@ void SoundDB::load() for_each_xml_child_node(node, root) { - if (xmlNameEqual(node, "sound")) + if (xmlNameEqual(node, "include")) + { + const std::string name = XML::getProperty(node, "name", ""); + if (!name.empty()) + loadXmlFile(name); + continue; + } + else if (xmlNameEqual(node, "sound")) { const std::string name = XML::getProperty(node, "name", ""); const int id = NotifyManager::getIndexBySound(name); diff --git a/src/resources/db/sounddb.h b/src/resources/db/sounddb.h index 3c421ca62..5d1361088 100644 --- a/src/resources/db/sounddb.h +++ b/src/resources/db/sounddb.h @@ -29,6 +29,8 @@ namespace SoundDB { void load(); + void loadXmlFile(const std::string &fileName); + void unload(); std::string &getSound(const int id); -- cgit v1.2.3-60-g2f50