diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-12-15 22:23:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-12-15 22:23:03 +0300 |
commit | f39bae9825936b3205396ee32fc50393c48d608f (patch) | |
tree | b10525ff11669bb639a3db751508a4b9942ecc55 /src/gui/windows/skilldialog.cpp | |
parent | 1a934c4064abc2675fe199ff906dd08e6fcc0a85 (diff) | |
download | mv-f39bae9825936b3205396ee32fc50393c48d608f.tar.gz mv-f39bae9825936b3205396ee32fc50393c48d608f.tar.bz2 mv-f39bae9825936b3205396ee32fc50393c48d608f.tar.xz mv-f39bae9825936b3205396ee32fc50393c48d608f.zip |
Dont show on start skill tabs without skills.
Diffstat (limited to 'src/gui/windows/skilldialog.cpp')
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 77 |
1 files changed, 48 insertions, 29 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index f1c81e0bb..291836f48 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -93,7 +93,8 @@ SkillDialog::SkillDialog() : mUseButton(new Button(this, _("Use"), "use", this)), // TRANSLATORS: skills dialog button mIncreaseButton(new Button(this, _("Up"), "inc", this)), - mDefaultModel(nullptr) + mDefaultModel(nullptr), + mDefaultTab(nullptr) { setWindowName("Skills"); setCloseButton(true); @@ -333,27 +334,10 @@ void SkillDialog::loadXmlFile(const std::string &fileName, setType = SkillSetType::Rectangle; } + bool alwaysVisible = false; SkillModel *const model = new SkillModel; - if (!mDefaultModel) - mDefaultModel = model; - - for_each_xml_child_node(node, set) - { - if (xmlNameEqual(node, "skill")) - { - SkillInfo *const skill = loadSkill(node, model); - if (skill == nullptr) - continue; - for_each_xml_child_node(levelNode, node) - { - if (!xmlNameEqual(levelNode, "level")) - continue; - loadSkillData(node, skill); - } - } - } - - model->updateVisibilities(); + SkillTab *tab = nullptr; + ScrollArea *scroll = nullptr; switch (setType) { @@ -364,14 +348,12 @@ void SkillDialog::loadXmlFile(const std::string &fileName, model); listbox->setActionEventId("sel"); listbox->addActionListener(this); - ScrollArea *const scroll = new ScrollArea(this, + scroll = new ScrollArea(this, listbox, Opaque_false); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); - SkillTab *const tab = new SkillTab(this, setName, listbox); - mDeleteTabs.push_back(tab); - mTabs->addTab(tab, scroll); + tab = new SkillTab(this, setName, listbox); break; } case SkillSetType::Rectangle: @@ -381,21 +363,54 @@ void SkillDialog::loadXmlFile(const std::string &fileName, model); listbox->setActionEventId("sel"); listbox->addActionListener(this); - ScrollArea *const scroll = new ScrollArea(this, + scroll = new ScrollArea(this, listbox, Opaque_false); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); - SkillTab *const tab = new SkillTab(this, setName, listbox); - mDeleteTabs.push_back(tab); - mTabs->addTab(tab, scroll); + tab = new SkillTab(this, setName, listbox); break; } default: reportAlways("Unsupported skillset type: %s", setTypeStr.c_str()); + return; break; } + if (!mDefaultModel) + { + mDefaultModel = model; + mDefaultTab = tab; + } + + if (alwaysVisible == true) + tab->setVisible(Visible_true); + else + tab->setVisible(Visible_false); + mDeleteTabs.push_back(tab); + mTabs->addTab(tab, scroll); + + for_each_xml_child_node(node, set) + { + if (xmlNameEqual(node, "skill")) + { + SkillInfo *const skill = loadSkill(node, model); + if (skill == nullptr) + continue; + if (skill->alwaysVisible == Visible_true) + alwaysVisible = true; + skill->tab = tab; + for_each_xml_child_node(levelNode, node) + { + if (!xmlNameEqual(levelNode, "level")) + continue; + loadSkillData(node, skill); + } + } + } + + model->updateVisibilities(); + } } } @@ -566,6 +581,8 @@ bool SkillDialog::updateSkill(const int id, info->type = type; info->sp = sp; info->update(); + if (info->tab) + info->tab->setVisible(Visible_true); } return true; } @@ -615,7 +632,9 @@ void SkillDialog::addSkill(const SkillOwner::Type owner, skill->useButton = _("Use"); // TRANSLATORS: skill error message skill->errorText = strprintf(_("Failed skill: %s"), name.c_str()); + skill->tab = mDefaultTab; mDefaultModel->addSkill(skill); + mDefaultTab->setVisible(Visible_true); mSkills[id] = skill; mDefaultModel->updateVisibilities(); |