From fdd6a8ff123f32090d5c417803fd909558530a15 Mon Sep 17 00:00:00 2001 From: Andrei Karas <akaras@inbox.ru> Date: Thu, 21 Jul 2016 03:08:30 +0300 Subject: Move skill data loading into separate function. --- src/gui/windows/skilldialog.cpp | 106 ++++++++++++++++++++++------------------ src/gui/windows/skilldialog.h | 7 +++ 2 files changed, 65 insertions(+), 48 deletions(-) (limited to 'src/gui/windows') 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; -- cgit v1.2.3-70-g09d2