diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-01-19 17:16:42 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-01-19 17:16:42 +0200 |
commit | 2db104b657d0403f1b8ce2eb2dc8ada4ee9d7f73 (patch) | |
tree | 949e1ad112f95b686a03c39d7697b2ea2b9d4ca3 /src | |
parent | 31dda9ab4d1559749a0f8f181ce1f7948e482813 (diff) | |
download | plus-2db104b657d0403f1b8ce2eb2dc8ada4ee9d7f73.tar.gz plus-2db104b657d0403f1b8ce2eb2dc8ada4ee9d7f73.tar.bz2 plus-2db104b657d0403f1b8ce2eb2dc8ada4ee9d7f73.tar.xz plus-2db104b657d0403f1b8ce2eb2dc8ada4ee9d7f73.zip |
Add unknown skills to first skill tab. (in tmw Basic).
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/skilldialog.cpp | 31 | ||||
-rw-r--r-- | src/gui/skilldialog.h | 6 | ||||
-rw-r--r-- | src/net/tmwa/specialhandler.cpp | 10 |
3 files changed, 43 insertions, 4 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index fa4d5bdb2..b80f4b335 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -236,6 +236,7 @@ SkillDialog::SkillDialog(): mTabs = new TabbedArea(); mPointsLabel = new Label("0"); mIncreaseButton = new Button(_("Up"), "inc", this); + mDefaultModel = 0; place(0, 0, mTabs, 5, 5); place(0, 5, mPointsLabel, 4); @@ -336,6 +337,9 @@ void SkillDialog::loadSkills(const std::string &file) if (Net::getNetworkType() == ServerInfo::TMWATHENA) { SkillModel *model = new SkillModel(); + if (!mDefaultModel) + mDefaultModel = model; + SkillInfo *skill = new SkillInfo; skill->id = 1; skill->name = "basic"; @@ -374,6 +378,8 @@ void SkillDialog::loadSkills(const std::string &file) strprintf(_("Skill Set %d"), setCount)); SkillModel *model = new SkillModel(); + if (!mDefaultModel) + mDefaultModel = model; for_each_xml_child_node(node, set) { @@ -416,7 +422,7 @@ void SkillDialog::loadSkills(const std::string &file) update(); } -void SkillDialog::setModifiable(int id, bool modifiable) +bool SkillDialog::setModifiable(int id, bool modifiable) { SkillMap::iterator it = mSkills.find(id); @@ -428,6 +434,29 @@ void SkillDialog::setModifiable(int id, bool modifiable) info->modifiable = modifiable; info->update(); } + return true; + } + return false; +} + +void SkillDialog::addSkill(int id, int level, bool modifiable) +{ + if (mDefaultModel) + { + SkillInfo *skill = new SkillInfo; + skill->id = static_cast<short unsigned>(id); + skill->name = "Unknown skill Id: " + toString(id); + skill->setIcon(""); + skill->modifiable = modifiable; + skill->visible = false; + skill->model = mDefaultModel; + skill->skillLevel = level; + skill->update(); + + mDefaultModel->addSkill(skill); + + mSkills[id] = skill; + mDefaultModel->updateVisibilities(); } } diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 4ba4afe8e..188cf76d5 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -37,6 +37,7 @@ class Button; //class Image; class Label; class ScrollArea; +class SkillModel; class Tab; class TabbedArea; @@ -71,7 +72,9 @@ class SkillDialog : public Window, public gcn::ActionListener void loadSkills(const std::string &file); - void setModifiable(int id, bool modifiable); + bool setModifiable(int id, bool modifiable); + + void addSkill(int id, int level, bool modifiable); SkillInfo* getSkill(int id); @@ -84,6 +87,7 @@ class SkillDialog : public Window, public gcn::ActionListener TabbedArea *mTabs; Label *mPointsLabel; Button *mIncreaseButton; + SkillModel *mDefaultModel; }; extern SkillDialog *skillDialog; diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index d502cc85f..95478d5bf 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -110,7 +110,10 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg) PlayerInfo::setStatBase(skillId, level); if (skillDialog) - skillDialog->setModifiable(skillId, up); + { + if (!skillDialog->setModifiable(skillId, up)) + skillDialog->addSkill(skillId, level, up); + } } break; } @@ -124,7 +127,10 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg) PlayerInfo::setStatBase(skillId, level); if (skillDialog) - skillDialog->setModifiable(skillId, up); + { + if (!skillDialog->setModifiable(skillId, up)) + skillDialog->addSkill(skillId, level, up); + } } break; |