summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-18 18:10:34 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-18 18:12:01 +0300
commitcc16bd52b4bfd5b542deddfcb131f0a1ca15b2e0 (patch)
treeedb2a4a75e478cefd282909d1708dfc2d04816a5 /src/gui/windows
parent9d18345d84b0c294b0fe7743cb263259f8cc9447 (diff)
downloadmv-cc16bd52b4bfd5b542deddfcb131f0a1ca15b2e0.tar.gz
mv-cc16bd52b4bfd5b542deddfcb131f0a1ca15b2e0.tar.bz2
mv-cc16bd52b4bfd5b542deddfcb131f0a1ca15b2e0.tar.xz
mv-cc16bd52b4bfd5b542deddfcb131f0a1ca15b2e0.zip
Draw cool down bar in skills window.
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/skilldialog.cpp40
-rw-r--r--src/gui/windows/skilldialog.h5
2 files changed, 44 insertions, 1 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 073cf11bd..ee82445f7 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -62,6 +62,7 @@ SkillDialog::SkillDialog() :
Window(_("Skills"), false, nullptr, "skills.xml"),
ActionListener(),
mSkills(),
+ mDurations(),
mTabs(new TabbedArea(this)),
mDeleteTabs(),
mPointsLabel(new Label(this, "0")),
@@ -197,6 +198,7 @@ void SkillDialog::clearSkills()
delete_all(mSkills);
mSkills.clear();
+ mDurations.clear();
}
void SkillDialog::hideSkills()
@@ -433,8 +435,9 @@ void SkillDialog::setSkillDuration(const int id, const int duration)
SkillInfo *const info = (*it).second;
if (info)
{
- info->duration = duration / 10;
+ info->duration = duration;
info->durationTime = tick_time;
+ addSkillDuration(info);
}
}
}
@@ -542,3 +545,38 @@ void SkillDialog::useSkill(const SkillInfo *const info)
}
}
}
+
+void SkillDialog::addSkillDuration(SkillInfo *const skill)
+{
+ FOR_EACH (std::vector<SkillInfo*>::const_iterator, it, mDurations)
+ {
+ if ((*it)->id == skill->id)
+ return;
+ }
+ mDurations.push_back(skill);
+}
+
+void SkillDialog::slowLogic()
+{
+ FOR_EACH (std::vector<SkillInfo*>::const_iterator, it, mDurations)
+ {
+ SkillInfo *const skill = *it;
+ if (skill)
+ {
+ const int time = get_elapsed_time(skill->durationTime);
+ if (time >= skill->duration)
+ {
+ it = mDurations.erase(it);
+ skill->cooldown = 0;
+ skill->duration = 0;
+ skill->durationTime = 0;
+ if (it != mDurations.begin())
+ -- it;
+ }
+ else if (time)
+ {
+ skill->cooldown = skill->duration * 100 / time;
+ }
+ }
+ }
+}
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index b01adcabd..fd9bca7c2 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -110,11 +110,16 @@ class SkillDialog final : public Window,
void playUpdateEffect(const int id) const;
+ void slowLogic();
+
static void useSkill(const SkillInfo *const info);
private:
+ void addSkillDuration(SkillInfo *const skill);
+
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
+ std::vector<SkillInfo*> mDurations;
TabbedArea *mTabs;
std::list<Tab*> mDeleteTabs;
Label *mPointsLabel;