summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-06 19:37:27 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-06 19:37:27 +0300
commit6666bf7992292f759f1860465af104d665b12328 (patch)
treeddd2bc0b4639b37228d729008ca73f315a47c85b /src/gui
parentb968fe5e0797ffd9b0df2846f8422e972bc281e7 (diff)
downloadManaVerse-6666bf7992292f759f1860465af104d665b12328.tar.gz
ManaVerse-6666bf7992292f759f1860465af104d665b12328.tar.bz2
ManaVerse-6666bf7992292f759f1860465af104d665b12328.tar.xz
ManaVerse-6666bf7992292f759f1860465af104d665b12328.zip
add support for include in skills.xml, ea-skills.xml.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/skilldialog.cpp36
-rw-r--r--src/gui/windows/skilldialog.h2
2 files changed, 23 insertions, 15 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index a13cff4cb..b11faedf5 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -429,32 +429,39 @@ void SkillDialog::clearSkills()
void SkillDialog::loadSkills()
{
clearSkills();
+ loadXmlFile(paths.getStringValue("skillsFile"));
+ if (mSkills.empty())
+ loadXmlFile(paths.getStringValue("skillsFile2"));
+ update();
+}
+
+void SkillDialog::loadXmlFile(const std::string &fileName)
+{
XML::Document doc(paths.getStringValue("skillsFile"));
- XML::Document doc2(paths.getStringValue("skillsFile2"));
XmlNodePtr root = doc.rootNode();
int setCount = 0;
- std::string setName;
- ScrollArea *scroll;
- SkillListBox *listbox;
- SkillTab *tab;
-
- if (!root || !xmlNameEqual(root, "skills"))
- root = doc2.rootNode();
if (!root || !xmlNameEqual(root, "skills"))
{
- logger->log("Error loading skills");
+ logger->log("Error loading skills: " + fileName);
return;
}
for_each_xml_child_node(set, root)
{
- if (xmlNameEqual(set, "set"))
+ if (xmlNameEqual(set, "include"))
+ {
+ const std::string name = XML::getProperty(set, "name", "");
+ if (!name.empty())
+ loadXmlFile(name);
+ continue;
+ }
+ else if (xmlNameEqual(set, "set"))
{
setCount++;
- setName = XML::getProperty(set, "name",
+ const std::string setName = XML::getProperty(set, "name",
// TRANSLATORS: skills dialog default skill tab
strprintf(_("Skill Set %d"), setCount));
@@ -532,20 +539,19 @@ void SkillDialog::loadSkills()
model->updateVisibilities();
// possible leak listbox, scroll
- listbox = new SkillListBox(this, model);
+ SkillListBox *const listbox = new SkillListBox(this, model);
listbox->setActionEventId("sel");
listbox->addActionListener(this);
- scroll = new ScrollArea(listbox, false);
+ ScrollArea *const scroll = new ScrollArea(listbox, false);
scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
- tab = new SkillTab(this, setName, listbox);
+ SkillTab *const tab = new SkillTab(this, setName, listbox);
mDeleteTabs.push_back(tab);
mTabs->addTab(tab, scroll);
}
}
- update();
}
bool SkillDialog::updateSkill(const int id, const int range,
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index 600ea4d34..4a6182d38 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -69,6 +69,8 @@ class SkillDialog final : public Window, public gcn::ActionListener
*/
void update();
+ void loadXmlFile(const std::string &fileName);
+
void clearSkills();
void loadSkills();