summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-06 17:06:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-06 17:06:22 +0300
commitdc17affd65b8be94ad24fe440925602475186118 (patch)
tree11953729aeb80edac13f1cfe0de47ed7ffe92346 /src/resources/db
parenta3fdbe3f382d11fcb83d7f3c342b676837478821 (diff)
downloadmv-dc17affd65b8be94ad24fe440925602475186118.tar.gz
mv-dc17affd65b8be94ad24fe440925602475186118.tar.bz2
mv-dc17affd65b8be94ad24fe440925602475186118.tar.xz
mv-dc17affd65b8be94ad24fe440925602475186118.zip
add support for include in emotes.xml.
Diffstat (limited to 'src/resources/db')
-rw-r--r--src/resources/db/emotedb.cpp46
-rw-r--r--src/resources/db/emotedb.h4
2 files changed, 40 insertions, 10 deletions
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
index 7b1bb1ce2..3086ff4c5 100644
--- a/src/resources/db/emotedb.cpp
+++ b/src/resources/db/emotedb.cpp
@@ -43,8 +43,6 @@ void EmoteDB::load()
if (mLoaded)
unload();
- mLastEmote = 0;
-
EmoteSprite *const unknownSprite = new EmoteSprite;
unknownSprite->sprite = AnimatedSprite::load(
paths.getStringValue("spriteErrorFile"));
@@ -53,21 +51,39 @@ void EmoteDB::load()
logger->log1("Initializing emote database...");
- XML::Document doc(paths.getStringValue("emotesFile"));
+ mLastEmote = 0;
+ loadXmlFile(paths.getStringValue("emotesFile"));
+ loadSpecialXmlFile("graphics/sprites/manaplus_emotes.xml");
+
+ mLoaded = true;
+}
+
+void EmoteDB::loadXmlFile(const std::string &fileName)
+{
+ XML::Document doc(fileName);
XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "emotes"))
{
logger->log("Emote Database: Error while loading %s!",
- paths.getStringValue("emotesFile").c_str());
+ fileName.c_str());
return;
}
// iterate <emote>s
for_each_xml_child_node(emoteNode, rootNode)
{
- if (!xmlNameEqual(emoteNode, "emote"))
+ if (xmlNameEqual(emoteNode, "include"))
+ {
+ const std::string name = XML::getProperty(emoteNode, "name", "");
+ if (!name.empty())
+ loadXmlFile(name);
+ continue;
+ }
+ else if (!xmlNameEqual(emoteNode, "emote"))
+ {
continue;
+ }
const int id = XML::getProperty(emoteNode, "id", -1);
// skip hight images
@@ -111,9 +127,12 @@ void EmoteDB::load()
if (id > mLastEmote)
mLastEmote = id;
}
+}
- XML::Document doc2("graphics/sprites/manaplus_emotes.xml");
- rootNode = doc2.rootNode();
+void EmoteDB::loadSpecialXmlFile(const std::string &fileName)
+{
+ XML::Document doc(fileName);
+ XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "emotes"))
{
@@ -125,8 +144,17 @@ void EmoteDB::load()
// iterate <emote>s
for_each_xml_child_node(emoteNode, rootNode)
{
- if (!xmlNameEqual(emoteNode, "emote"))
+ if (xmlNameEqual(emoteNode, "include"))
+ {
+ const std::string name = XML::getProperty(emoteNode, "name", "");
+ if (!name.empty())
+ loadSpecialXmlFile(name);
continue;
+ }
+ else if (!xmlNameEqual(emoteNode, "emote"))
+ {
+ continue;
+ }
const int id = XML::getProperty(emoteNode, "id", -1);
if (id == -1)
@@ -170,8 +198,6 @@ void EmoteDB::load()
if (id > mLastEmote)
mLastEmote = id;
}
-
- mLoaded = true;
}
void EmoteDB::unload()
diff --git a/src/resources/db/emotedb.h b/src/resources/db/emotedb.h
index a7dc40422..f00bfbb47 100644
--- a/src/resources/db/emotedb.h
+++ b/src/resources/db/emotedb.h
@@ -69,6 +69,10 @@ namespace EmoteDB
{
void load();
+ void loadXmlFile(const std::string &fileName);
+
+ void loadSpecialXmlFile(const std::string &fileName);
+
void unload();
const EmoteInfo *get(const int id,