summaryrefslogtreecommitdiff
path: root/src/gui/windows/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-12-15 22:23:03 +0300
committerAndrei Karas <akaras@inbox.ru>2016-12-15 22:23:03 +0300
commitf39bae9825936b3205396ee32fc50393c48d608f (patch)
treeb10525ff11669bb639a3db751508a4b9942ecc55 /src/gui/windows/skilldialog.cpp
parent1a934c4064abc2675fe199ff906dd08e6fcc0a85 (diff)
downloadmanaplus-f39bae9825936b3205396ee32fc50393c48d608f.tar.gz
manaplus-f39bae9825936b3205396ee32fc50393c48d608f.tar.bz2
manaplus-f39bae9825936b3205396ee32fc50393c48d608f.tar.xz
manaplus-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.cpp77
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();