diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-15 19:08:49 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-15 19:08:49 +0000 |
commit | 13f82f10d92816d0239db56b7936fd2403f50897 (patch) | |
tree | 8609c90794dc8bcba1f613c6cac9907e7e58d4e4 /src/gui/skill.cpp | |
parent | 8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1 (diff) | |
download | mana-13f82f10d92816d0239db56b7936fd2403f50897.tar.gz mana-13f82f10d92816d0239db56b7936fd2403f50897.tar.bz2 mana-13f82f10d92816d0239db56b7936fd2403f50897.tar.xz mana-13f82f10d92816d0239db56b7936fd2403f50897.zip |
Fixed upping skills.
Diffstat (limited to 'src/gui/skill.cpp')
-rw-r--r-- | src/gui/skill.cpp | 186 |
1 files changed, 86 insertions, 100 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 65214e4a..4c3feedf 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -28,99 +28,35 @@ #include "../main.h" char *skill_db[] = { - // 0-99 - "", "Basic", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - // 100-199 - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "First aid", "Play as dead", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", + // 0-99 + "", "Basic", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + // 100-199 + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "First aid", "Play as dead", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", }; -SkillListModel::SkillListModel() -{ -} - -SkillListModel::~SkillListModel() -{ - for (int i = skillList.size() - 1; i >= 0; i--) - { - delete skillList[i]; - skillList.pop_back(); - } -} - -int SkillListModel::getNumberOfElements() -{ - return skillList.size(); -} - -std::string SkillListModel::getElementAt(int i) -{ - if (i >= 0 && i < (int)skillList.size()) - { - //return skill_db[skillList[i]->id]; - char tmp[128]; - sprintf(tmp, "%s Lv: %i Sp: %i", - skill_db[skillList[i]->id], - skillList[i]->lv, - skillList[i]->sp); - return tmp; - } - return ""; -} - -bool SkillListModel::hasSkill(int id) -{ - for (unsigned int i = 0; i < skillList.size(); i++) { - if (skillList[i]->id == id) { - return true; - } - } - return false; -} - -void SkillListModel::addSkill(int id, int lv, int sp) -{ - SKILL *tmp = new SKILL; - tmp->id = id; - tmp->lv = lv; - tmp->sp = sp; - skillList.push_back(tmp); -} - -void SkillListModel::setSkill(int id, int lv, int sp) -{ - for (unsigned int i = 0; i < skillList.size(); i++) { - if (skillList[i]->id == id) { - skillList[i]->lv = lv; - skillList[i]->sp = sp; - } - } -} - - SkillDialog::SkillDialog(): Window("Skills") { - skills = new SkillListModel(); - skillListBox = new ListBox(skills); + skillListBox = new ListBox(this); skillScrollArea = new ScrollArea(skillListBox); pointsLabel = new gcn::Label("Skill Points:"); incButton = new Button(" Up "); @@ -154,20 +90,27 @@ SkillDialog::~SkillDialog() delete incButton; delete closeButton; - delete skills; + for (int i = skillList.size() - 1; i >= 0; i--) + { + delete skillList[i]; + skillList.pop_back(); + } } void SkillDialog::action(const std::string& eventId) { if (eventId == "inc") { - //increment skill - //if (char_info->skill_point > 0) { - // WFIFOW(0) = net_w_value(0x0112); - // WFIFOW(2) = net_w_value( - // get_skill_id(skill_list_dialog[3].d1)); - // WFIFOSET(4); - //} + // Increment skill + int selectedSkill = skillListBox->getSelected(); + std::cout << "SkillDialog::action(" << selectedSkill << ")\n"; + if (char_info->skill_point > 0 && selectedSkill >= 0) { + std::cout << "Sending upgrade of id " << skillList[selectedSkill]->id << "\n"; + WFIFOW(0) = net_w_value(0x0112); + WFIFOW(2) = net_w_value( + skillList[selectedSkill]->id); + WFIFOSET(4); + } } else if (eventId == "close") { @@ -175,11 +118,6 @@ void SkillDialog::action(const std::string& eventId) } } -SkillListModel* SkillDialog::getModel() -{ - return skills; -} - void SkillDialog::setPoints(int i) { char tmp[128]; @@ -189,3 +127,51 @@ void SkillDialog::setPoints(int i) } } +int SkillDialog::getNumberOfElements() +{ + return skillList.size(); +} + +std::string SkillDialog::getElementAt(int i) +{ + if (i >= 0 && i < (int)skillList.size()) + { + char tmp[128]; + sprintf(tmp, "%s Lv: %i Sp: %i", + skill_db[skillList[i]->id], + skillList[i]->lv, + skillList[i]->sp); + return tmp; + } + return ""; +} + +bool SkillDialog::hasSkill(int id) +{ + for (unsigned int i = 0; i < skillList.size(); i++) { + if (skillList[i]->id == id) { + return true; + } + } + return false; +} + +void SkillDialog::addSkill(int id, int lv, int sp) +{ + SKILL *tmp = new SKILL(); + tmp->id = id; + tmp->lv = lv; + tmp->sp = sp; + skillList.push_back(tmp); +} + +void SkillDialog::setSkill(int id, int lv, int sp) +{ + for (unsigned int i = 0; i < skillList.size(); i++) { + if (skillList[i]->id == id) { + skillList[i]->lv = lv; + skillList[i]->sp = sp; + } + } +} + |