diff options
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 106 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 7 |
2 files changed, 65 insertions, 48 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 7596e3e34..995ebe822 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -367,56 +367,9 @@ void SkillDialog::loadXmlFile(const std::string &fileName, mSkills[id] = skill; } - std::string icon = XML::getProperty(node, "icon", ""); const int level = (skill->alwaysVisible == Visible_true) ? 0 : XML::getProperty(node, "level", 0); - SkillData *data = skill->getData(level); - if (!data) - data = new SkillData; - - data->name = name; - data->setIcon(icon); - if (skill->id < SKILL_VAR_MIN_ID) - { - data->dispName = strprintf("%s, %u", - name.c_str(), skill->id); - } - else - { - data->dispName = strprintf("%s, (%u)", - name.c_str(), skill->id - SKILL_VAR_MIN_ID); - } - data->shortName = XML::langProperty(node, - "shortName", name.substr(0, 3)); - data->description = XML::langProperty( - node, "description", ""); - data->particle = XML::getProperty( - node, "particle", ""); - data->castingAnimation = XML::getProperty( - node, - "castingAnimation", - paths.getStringValue("skillCastingAnimation")); - - data->soundHit.sound = XML::getProperty( - node, "soundHit", ""); - data->soundHit.delay = XML::getProperty( - node, "soundHitDelay", 0); - data->soundMiss.sound = XML::getProperty( - node, "soundMiss", ""); - data->soundMiss.delay = XML::getProperty( - node, "soundMissDelay", 0); - data->invokeCmd = XML::getProperty( - node, "invokeCmd", ""); - data->updateEffectId = XML::getProperty( - node, "levelUpEffectId", -1); - data->removeEffectId = XML::getProperty( - node, "removeEffectId", -1); - data->hitEffectId = XML::getProperty( - node, "hitEffectId", -1); - data->missEffectId = XML::getProperty( - node, "missEffectId", -1); - - skill->addData(level, data); + loadSkillData(node, name, skill, level); } } @@ -438,6 +391,63 @@ void SkillDialog::loadXmlFile(const std::string &fileName, } } +void SkillDialog::loadSkillData(XmlNodePtr node, + const std::string &name, + SkillInfo *const skill, + const int level) +{ + SkillData *data = skill->getData(level); + if (!data) + data = new SkillData; + + data->name = name; + const std::string icon = XML::getProperty(node, "icon", ""); + data->setIcon(icon); + if (skill->id < SKILL_VAR_MIN_ID) + { + data->dispName = strprintf("%s, %u", + name.c_str(), + skill->id); + } + else + { + data->dispName = strprintf("%s, (%u)", + name.c_str(), + skill->id - SKILL_VAR_MIN_ID); + } + data->shortName = XML::langProperty(node, + "shortName", name.substr(0, 3)); + data->description = XML::langProperty( + node, "description", ""); + data->particle = XML::getProperty( + node, "particle", ""); + data->castingAnimation = XML::getProperty( + node, + "castingAnimation", + paths.getStringValue("skillCastingAnimation")); + + data->soundHit.sound = XML::getProperty( + node, "soundHit", ""); + data->soundHit.delay = XML::getProperty( + node, "soundHitDelay", 0); + data->soundMiss.sound = XML::getProperty( + node, "soundMiss", ""); + data->soundMiss.delay = XML::getProperty( + node, "soundMissDelay", 0); + data->invokeCmd = XML::getProperty( + node, "invokeCmd", ""); + data->updateEffectId = XML::getProperty( + node, "levelUpEffectId", -1); + data->removeEffectId = XML::getProperty( + node, "removeEffectId", -1); + data->hitEffectId = XML::getProperty( + node, "hitEffectId", -1); + data->missEffectId = XML::getProperty( + node, "missEffectId", -1); + + skill->addData(level, data); +} + void SkillDialog::removeSkill(const int id) { const SkillMap::const_iterator it = mSkills.find(id); diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index fe3e31c80..2b5e4f070 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -34,6 +34,8 @@ #include "listeners/actionlistener.h" +#include "utils/xml.h" + class Being; class Button; class Label; @@ -165,6 +167,11 @@ class SkillDialog final : public Window, private: void addSkillDuration(SkillInfo *const skill); + void loadSkillData(XmlNodePtr node, + const std::string &name, + SkillInfo *const skill, + const int level); + typedef std::map<int, SkillInfo*> SkillMap; SkillMap mSkills; std::vector<SkillInfo*> mDurations; |