diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-03 20:36:26 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-03 20:36:26 +0000 |
commit | ee5830a18757f5b34890a27a239e6a9214f8ac62 (patch) | |
tree | 7061779ec307ecdf9d10ad8ebda55b16a3aa68c7 /src/gui/skill.cpp | |
parent | b047811ba2e0fd8ced277f9b3f7bc35d6c274e09 (diff) | |
download | mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.tar.gz mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.tar.bz2 mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.tar.xz mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.zip |
Skill gui beautifications by roderic.
Diffstat (limited to 'src/gui/skill.cpp')
-rw-r--r-- | src/gui/skill.cpp | 135 |
1 files changed, 99 insertions, 36 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 9ce451b8..f2ed9638 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -33,6 +33,7 @@ #include "scrollarea.h" #include "windowcontainer.h" #include "progressbar.h" +#include "tabbedcontainer.h" #include "../localplayer.h" @@ -41,37 +42,30 @@ #include "../utils/gettext.h" SkillDialog::SkillDialog(): - Window("Skills") + Window(_("Skills")) { setCloseButton(true); - setDefaultSize(windowContainer->getWidth() - 255, 25, 300, 300); - setMinWidth(300); - setMinHeight(300); - - mSkillNameLabels.resize(CHAR_SKILL_NB); - mSkillLevelLabels.resize(CHAR_SKILL_NB); - mSkillExpLabels.resize(CHAR_SKILL_NB); - mSkillProgress.resize(CHAR_SKILL_NB); - - for (int a=0; a < CHAR_SKILL_NB; a++) - { - mSkillNameLabels.at(a) = new gcn::Label(""); - mSkillNameLabels.at(a)->setPosition(1, a*20); - add(mSkillNameLabels.at(a)); - - mSkillProgress.at(a) = new ProgressBar(0.0f, 80, 15, 150, 150, 150); - mSkillProgress.at(a)->setPosition(75, a*20); - add(mSkillProgress.at(a)); - - mSkillExpLabels.at(a) = new gcn::Label(""); - mSkillExpLabels.at(a)->setPosition(170, a*20); - add(mSkillExpLabels.at(a)); - - mSkillLevelLabels.at(a) = new gcn::Label(""); - mSkillLevelLabels.at(a)->setPosition(245, a*20); - add(mSkillLevelLabels.at(a)); - - } + setDefaultSize(windowContainer->getWidth() - 255, 25, 230, 425); + + TabbedContainer *panel = new TabbedContainer(); + panel->setDimension(gcn::Rectangle(5, 5, 225, 420)); + panel->setOpaque(false); + + Skill_Tab* tab; + + tab = new Skill_Tab("Weapon"); + panel->addTab(tab, _("Weapons")); + mTabs.push_back(tab); + + tab = new Skill_Tab("Magic"); + panel->addTab(tab, _("Magic")); + mTabs.push_back(tab); + + tab = new Skill_Tab("Craft"); + panel->addTab(tab, _("Crafts")); + mTabs.push_back(tab); + + add(panel); update(); @@ -81,7 +75,7 @@ SkillDialog::SkillDialog(): SkillDialog::~SkillDialog() { - + for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); } void SkillDialog::action(const gcn::ActionEvent &event) @@ -104,10 +98,78 @@ void SkillDialog::draw(gcn::Graphics *g) void SkillDialog::update() { - for (int a = 0; a < CHAR_SKILL_NB; a++) + for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&Skill_Tab::update)); +} + +Skill_Tab::Skill_Tab(std::string type): type(type) +{ + int skillnum; + if (type == "Weapon") + { + skillnum = CHAR_SKILL_WEAPON_NB; + } + else if (type == "Magic") + { + skillnum = CHAR_SKILL_MAGIC_NB; + } + else if (type == "Craft") + { + skillnum = CHAR_SKILL_CRAFT_NB; + } + + mSkillNameLabels.resize(skillnum); + mSkillLevelLabels.resize(skillnum); + mSkillExpLabels.resize(skillnum); + mSkillProgress.resize(skillnum); + + for (int a=0; a < skillnum; a++) + { + mSkillNameLabels.at(a) = new gcn::Label(""); + mSkillNameLabels.at(a)->setPosition(1, a*32 ); + add(mSkillNameLabels.at(a)); + + mSkillProgress.at(a) = new ProgressBar(0.0f, 200, 20, 150, 150, 150); + mSkillProgress.at(a)->setPosition(1, a*32 + 13); + add(mSkillProgress.at(a)); + + mSkillExpLabels.at(a) = new gcn::Label(""); + mSkillExpLabels.at(a)->setPosition(10, a*32 + 16); + add(mSkillExpLabels.at(a)); + + mSkillLevelLabels.at(a) = new gcn::Label(""); + mSkillLevelLabels.at(a)->setPosition(165, a*32); + add(mSkillLevelLabels.at(a)); + } + + update(); + +} + +void Skill_Tab::update() +{ + setOpaque(false); + int skillnum; + int skillbegin; + if (type == "Weapon") + { + skillnum = CHAR_SKILL_WEAPON_NB; + skillbegin = CHAR_SKILL_WEAPON_BEGIN - CHAR_SKILL_BEGIN; + } + else if (type == "Magic") + { + skillnum = CHAR_SKILL_MAGIC_NB; + skillbegin = CHAR_SKILL_MAGIC_BEGIN - CHAR_SKILL_BEGIN; + } + else if (type == "Craft") + { + skillnum = CHAR_SKILL_CRAFT_NB; + skillbegin = CHAR_SKILL_CRAFT_BEGIN - CHAR_SKILL_BEGIN; + } + + for (int a = 0; a < skillnum; a++) { - int baseLevel = player_node->getAttributeBase(a + CHAR_SKILL_BEGIN); - int effLevel = player_node->getAttributeEffective(a + CHAR_SKILL_BEGIN); + int baseLevel = player_node->getAttributeBase(a + skillbegin + CHAR_SKILL_BEGIN); + int effLevel = player_node->getAttributeEffective(a + skillbegin + CHAR_SKILL_BEGIN); std::string skillLevel("Lvl: " + toString(baseLevel)); if (effLevel < baseLevel) @@ -120,18 +182,19 @@ void SkillDialog::update() } mSkillLevelLabels.at(a)->setCaption(skillLevel); - std::pair<int, int> exp = player_node->getExperience(a); + std::pair<int, int> exp = player_node->getExperience(a + skillbegin); std::string sExp (toString(exp.first) + " / " + toString(exp.second)); - mSkillNameLabels.at(a)->setCaption(LocalPlayer::getSkillName(a)); + mSkillNameLabels.at(a)->setCaption(LocalPlayer::getSkillName(a + skillbegin)); mSkillNameLabels.at(a)->adjustSize(); mSkillLevelLabels.at(a)->adjustSize(); mSkillExpLabels.at(a)->setCaption(sExp); mSkillExpLabels.at(a)->adjustSize(); + mSkillExpLabels.at(a)->setAlignment(gcn::Graphics::RIGHT); // more intense red as exp grows - int color = 150 - (150 * exp.first / exp.second); + int color = 150 - (150 * ((float) exp.first / exp.second)); mSkillProgress.at(a)->setColor(244, color, color); mSkillProgress.at(a)->setProgress((float) exp.first / exp.second); } |