summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-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();