diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/skill.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index dd7c3a4e..11db25ce 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -40,11 +40,14 @@ static const char *SKILLS_FILE = _("skills.xml"); -struct SkillInfo { +struct SkillInfo +{ std::string name; bool modifiable; }; +static const SkillInfo fakeSkillInfo = { _("???"), false }; + std::vector<SkillInfo> skill_db; static void initSkillinfo(void); @@ -80,8 +83,6 @@ public: virtual void update(void) { - static const SkillInfo fakeSkillInfo = { _("???"), false }; - mEntriesNr = mDialog->getSkills().size(); resize(); @@ -172,10 +173,18 @@ void SkillDialog::action(const gcn::ActionEvent &event) if (selectedSkill >= 0) player_node->raiseSkill(mSkillList[selectedSkill]->id); } - else if (event.getId() == "skill") + else if (event.getId() == "skill" && mTable->getSelectedRow() > -1) { - mIncButton->setEnabled(mTable->getSelectedRow() > -1 && - player_node->mSkillPoint > 0); + SKILL *skill = mSkillList[mTable->getSelectedRow()]; + SkillInfo const *info; + + if (skill->id >= 0 && (unsigned int) skill->id < skill_db.size()) + info = &skill_db[skill->id]; + else + info = &fakeSkillInfo; + + mIncButton->setEnabled(player_node->mSkillPoint > 0 && + info->modifiable); } else if (event.getId() == "close") setVisible(false); |