diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-21 03:08:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-21 03:08:30 +0300 |
commit | fdd6a8ff123f32090d5c417803fd909558530a15 (patch) | |
tree | 1166617e9ed39c05e1d74e45865d917c5a2d702e /src/gui/windows/skilldialog.cpp | |
parent | 646abbe93193cc2c3cf0903df0a25a6dcc752ccc (diff) | |
download | plus-fdd6a8ff123f32090d5c417803fd909558530a15.tar.gz plus-fdd6a8ff123f32090d5c417803fd909558530a15.tar.bz2 plus-fdd6a8ff123f32090d5c417803fd909558530a15.tar.xz plus-fdd6a8ff123f32090d5c417803fd909558530a15.zip |
Move skill data loading into separate function.
Diffstat (limited to 'src/gui/windows/skilldialog.cpp')
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 106 |
1 files changed, 58 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); |