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 | |
parent | b047811ba2e0fd8ced277f9b3f7bc35d6c274e09 (diff) | |
download | mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.tar.gz mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.tar.bz2 mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.tar.xz mana-ee5830a18757f5b34890a27a239e6a9214f8ac62.zip |
Skill gui beautifications by roderic.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/gui/skill.cpp | 135 | ||||
-rw-r--r-- | src/gui/skill.h | 29 | ||||
-rw-r--r-- | src/localplayer.cpp | 30 |
4 files changed, 148 insertions, 54 deletions
@@ -1,3 +1,11 @@ +2008-03-03 Philipp Sehmisch <tmw@crushnet.org> + + * src/gui/skill.cpp, src/gui/skill.h: Skill gui beautifications by + roderic. + * src/localplayer.cpp: Made skill names translateable. + * data/graphics/sprites/monster-maggot.xml: Made maggot attack animation + finite. + 2008-03-01 Philipp Sehmisch <tmw@crushnet.org> * src/gui/textdialog.cpp, src/gui/textdialog.h: Replaced the basic 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); } diff --git a/src/gui/skill.h b/src/gui/skill.h index 64b7d468..bf32fe64 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -25,16 +25,35 @@ #define _TMW_SKILL_H #include <vector> +#include <list> #include <guichan/listmodel.hpp> #include <guichan/actionlistener.hpp> #include "window.h" +#include "gccontainer.h" #include "../guichanfwd.h" class ProgressBar; +class Skill_Tab : public GCContainer, public gcn::ActionListener +{ + public: + const std::string type; + Skill_Tab(std::string type); + void update(); + void action(const gcn::ActionEvent &event) {} + + protected: + + std::vector<gcn::Label *> mSkillNameLabels; + std::vector<gcn::Label *> mSkillLevelLabels; + std::vector<gcn::Label *> mSkillExpLabels; + std::vector<ProgressBar *> mSkillProgress; +}; + + /** * The skill dialog. * @@ -62,12 +81,14 @@ class SkillDialog : public Window, public gcn::ActionListener void draw(gcn::Graphics *g); private: - std::vector<gcn::Label *> mSkillNameLabels; - std::vector<gcn::Label *> mSkillLevelLabels; - std::vector<gcn::Label *> mSkillExpLabels; - std::vector<ProgressBar *> mSkillProgress; + + std::list<Skill_Tab*> mTabs; + }; + + + extern SkillDialog *skillDialog; #endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 3c70c228..f581db27 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -41,6 +41,7 @@ #include "net/protocol.h" #include "utils/tostring.h" +#include "utils/gettext.h" LocalPlayer *player_node = NULL; @@ -445,20 +446,21 @@ void LocalPlayer::lowerAttribute(size_t attr) const std::string& LocalPlayer::getSkillName(int skill) { static const std::string skills[CHAR_SKILL_NB + 1] = - { "Unarmed", // CHAR_SKILL_WEAPON_NONE - "Knife", // CHAR_SKILL_WEAPON_KNIFE - "Sword", // CHAR_SKILL_WEAPON_SWORD - "Polearm", // CHAR_SKILL_WEAPON_POLEARM - "Staff", // CHAR_SKILL_WEAPON_STAFF - "Whip", // CHAR_SKILL_WEAPON_WHIP - "Bow", // CHAR_SKILL_WEAPON_BOW - "Shooting", // CHAR_SKILL_WEAPON_SHOOTING - "Mace", // CHAR_SKILL_WEAPON_MACE - "Axe", // CHAR_SKILL_WEAPON_AXE - "Thrown", // CHAR_SKILL_WEAPON_THROWN - "Magic", // CHAR_SKILL_MAGIC_IAMJUSTAPLACEHOLDER - "Craft", // CHAR_SKILL_CRAFT_IAMJUSTAPLACEHOLDER - "Unknown Skill" + { + _("Unarmed"), // CHAR_SKILL_WEAPON_NONE + _("Knife"), // CHAR_SKILL_WEAPON_KNIFE + _("Sword"), // CHAR_SKILL_WEAPON_SWORD + _("Polearm"), // CHAR_SKILL_WEAPON_POLEARM + _("Staff"), // CHAR_SKILL_WEAPON_STAFF + _("Whip"), // CHAR_SKILL_WEAPON_WHIP + _("Bow"), // CHAR_SKILL_WEAPON_BOW + _("Shooting"), // CHAR_SKILL_WEAPON_SHOOTING + _("Mace"), // CHAR_SKILL_WEAPON_MACE + _("Axe"), // CHAR_SKILL_WEAPON_AXE + _("Thrown"), // CHAR_SKILL_WEAPON_THROWN + _("Magic"), // CHAR_SKILL_MAGIC_IAMJUSTAPLACEHOLDER + _("Craft"), // CHAR_SKILL_CRAFT_IAMJUSTAPLACEHOLDER + _("Unknown Skill") }; if ((skill < 0) || (skill > CHAR_SKILL_NB)) |