summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-01-28 07:57:49 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-01-28 07:57:49 +0000
commit5ff0cd265460ef3fcc30f663094dc2c99b9926e9 (patch)
tree91db46420bfaa21694bd69df2e46f854ac14910f /src/gui
parent0962fc8b567279a6e97e13e4b3f2f9f2ffe304c0 (diff)
downloadMana-5ff0cd265460ef3fcc30f663094dc2c99b9926e9.tar.gz
Mana-5ff0cd265460ef3fcc30f663094dc2c99b9926e9.tar.bz2
Mana-5ff0cd265460ef3fcc30f663094dc2c99b9926e9.tar.xz
Mana-5ff0cd265460ef3fcc30f663094dc2c99b9926e9.zip
Added weapon skill system and leveling system.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/skill.cpp125
-rw-r--r--src/gui/skill.h21
-rw-r--r--src/gui/status.cpp139
-rw-r--r--src/gui/status.h7
4 files changed, 137 insertions, 155 deletions
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index c553863f..8c47c4ad 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -24,6 +24,7 @@
#include <algorithm>
#include <guichan/widgets/label.hpp>
+#include <guichan/widgets/container.hpp>
#include "skill.h"
@@ -35,32 +36,8 @@
#include "../localplayer.h"
#include "../utils/dtor.h"
-
-const char *skill_db[] = {
- // 0-99
- "", "Basic", "Sword", "Two hand", "HP regeneration", "Bash", "Provoke", "Magnum", "Endure", "MP regeneration",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "MAX weight", "Discount", "Overcharge", "",
- "Identify", "", "", "", "", "", "", "", "Double", "Miss",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- // 100-199
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "First aid", "Play as dead", "Moving recovery", "Fatal blow", "Auto berserk", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
- "", "", "", "", "", "", "", "", "", "",
-};
-
+#include "../utils/toString.h"
+#include "../utils/gettext.h"
SkillDialog::SkillDialog():
Window("Skills")
@@ -68,25 +45,32 @@ SkillDialog::SkillDialog():
setCloseButton(true);
setDefaultSize(windowContainer->getWidth() - 255, 25, 240, 240);
- mSkillListBox = new ListBox(this);
- ScrollArea *skillScrollArea = new ScrollArea(mSkillListBox);
-
- mSkillListBox->setActionEventId("skill");
-
- skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180));
+ mSkillNameLabels.resize(CHAR_SKILL_NB);
+ mSkillLevelLabels.resize(CHAR_SKILL_NB);
+ mSkillExpLabels.resize(CHAR_SKILL_NB);
- add(skillScrollArea);
+ for (int a=0; a < CHAR_SKILL_NB; a++)
+ {
+ mSkillNameLabels.at(a) = new gcn::Label("");
+ mSkillNameLabels.at(a)->setPosition(1, a*10);
+ add(mSkillNameLabels.at(a));
+ mSkillLevelLabels.at(a) = new gcn::Label("");
+ mSkillLevelLabels.at(a)->setPosition(75, a*10);
+ add(mSkillLevelLabels.at(a));
+ mSkillExpLabels.at(a) = new gcn::Label("");
+ mSkillExpLabels.at(a)->setPosition(150, a*10);
+ add(mSkillExpLabels.at(a));
+ }
- mSkillListBox->addActionListener(this);
+ update();
setLocationRelativeTo(getParent());
- loadWindowState("Skills");
+ loadWindowState(_("Skills"));
}
SkillDialog::~SkillDialog()
{
- cleanList();
+
}
void SkillDialog::action(const gcn::ActionEvent &event)
@@ -100,60 +84,29 @@ void SkillDialog::action(const gcn::ActionEvent &event)
}
}
-void SkillDialog::update()
+void SkillDialog::draw(gcn::Graphics *g)
{
-}
+ update();
-int SkillDialog::getNumberOfElements()
-{
- return mSkillList.size();
+ Window::draw(g);
}
-std::string SkillDialog::getElementAt(int i)
+void SkillDialog::update()
{
- if (i >= 0 && i < (int)mSkillList.size())
+ for (int a = 0; a < CHAR_SKILL_NB; a++)
{
- char tmp[128];
- sprintf(tmp, "%s Lv: %i Sp: %i",
- skill_db[mSkillList[i]->id],
- mSkillList[i]->lv,
- mSkillList[i]->sp);
- return tmp;
+ int baseLevel = player_node->getAttributeBase(a + CHAR_SKILL_BEGIN);
+ int effLevel = player_node->getAttributeEffective(a + CHAR_SKILL_BEGIN);
+ std::string skillLevel("Lvl:" + toString(effLevel) + " / " + toString(baseLevel));
+
+ std::pair<int, int> exp = player_node->getExperience(a);
+ std::string sExp (toString(exp.first) + " / " + toString(exp.second));
+
+ mSkillNameLabels.at(a)->setCaption("Skill" + toString(a));
+ mSkillNameLabels.at(a)->adjustSize();
+ mSkillLevelLabels.at(a)->setCaption(skillLevel);
+ mSkillLevelLabels.at(a)->adjustSize();
+ mSkillExpLabels.at(a)->setCaption(sExp);
+ mSkillExpLabels.at(a)->adjustSize();
}
- return "";
-}
-
-bool SkillDialog::hasSkill(int id)
-{
- for (unsigned int i = 0; i < mSkillList.size(); i++) {
- if (mSkillList[i]->id == id) {
- return true;
- }
- }
- return false;
-}
-
-void SkillDialog::addSkill(int id, int lvl, int mp)
-{
- SKILL *tmp = new SKILL();
- tmp->id = id;
- tmp->lv = lvl;
- tmp->sp = mp;
- mSkillList.push_back(tmp);
-}
-
-void SkillDialog::setSkill(int id, int lvl, int mp)
-{
- for (unsigned int i = 0; i < mSkillList.size(); i++) {
- if (mSkillList[i]->id == id) {
- mSkillList[i]->lv = lvl;
- mSkillList[i]->sp = mp;
- }
- }
-}
-
-void SkillDialog::cleanList()
-{
- for_each(mSkillList.begin(), mSkillList.end(), make_dtor(mSkillList));
- mSkillList.clear();
}
diff --git a/src/gui/skill.h b/src/gui/skill.h
index f1a14d50..55d94d82 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -33,18 +33,13 @@
#include "../guichanfwd.h"
-struct SKILL {
- short id; /**< Index into "skill_db" array */
- short lv, sp;
-};
/**
* The skill dialog.
*
* \ingroup Interface
*/
-class SkillDialog : public Window, public gcn::ActionListener,
- public gcn::ListModel
+class SkillDialog : public Window, public gcn::ActionListener
{
public:
/**
@@ -61,18 +56,14 @@ class SkillDialog : public Window, public gcn::ActionListener,
void update();
- int getNumberOfElements();
- std::string getElementAt(int);
+ void setExp(int id, int exp);
- bool hasSkill(int id);
- void addSkill(int id, int lv, int sp);
- void setSkill(int id, int lv, int sp);
- void cleanList();
+ void draw(gcn::Graphics *g);
private:
- gcn::ListBox *mSkillListBox;
-
- std::vector<SKILL*> mSkillList;
+ std::vector<gcn::Label *> mSkillNameLabels;
+ std::vector<gcn::Label *> mSkillLevelLabels;
+ std::vector<gcn::Label *> mSkillExpLabels;
};
extern SkillDialog *skillDialog;
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index b0a92665..b9ebfecf 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -87,7 +87,6 @@ StatusWindow::StatusWindow(LocalPlayer *player):
// Static Labels
gcn::Label *mStatsTitleLabel = new gcn::Label("Stats");
gcn::Label *mStatsTotalLabel = new gcn::Label("Total");
- gcn::Label *mStatsCostLabel = new gcn::Label("Cost");
// Derived Stats
/*
@@ -111,37 +110,44 @@ StatusWindow::StatusWindow(LocalPlayer *player):
for (int i = 0; i < 6; i++) {
mStatsLabel[i] = new gcn::Label();
mStatsDisplayLabel[i] = new gcn::Label();
- mPointsLabel[i] = new gcn::Label("0");
}
- mRemainingStatsPointsLabel = new gcn::Label();
+ mCharacterPointsLabel = new gcn::Label();
+ mCorrectionPointsLabel = new gcn::Label();
// Set button events Id
- mStatsButton[0] = new Button("+", "STR", this);
- mStatsButton[1] = new Button("+", "AGI", this);
- mStatsButton[2] = new Button("+", "DEX", this);
- mStatsButton[3] = new Button("+", "VIT", this);
- mStatsButton[4] = new Button("+", "INT", this);
- mStatsButton[5] = new Button("+", "WIL", this);
- mStatsButton[6] = new Button("+", "CHR", this);
+ mStatsPlus[0] = new Button("+", "STR+", this);
+ mStatsPlus[1] = new Button("+", "AGI+", this);
+ mStatsPlus[2] = new Button("+", "DEX+", this);
+ mStatsPlus[3] = new Button("+", "VIT+", this);
+ mStatsPlus[4] = new Button("+", "INT+", this);
+ mStatsPlus[5] = new Button("+", "WIL+", this);
+
+ mStatsMinus[0] = new Button("-", "STR-", this);
+ mStatsMinus[1] = new Button("-", "AGI-", this);
+ mStatsMinus[2] = new Button("-", "DEX-", this);
+ mStatsMinus[3] = new Button("-", "VIT-", this);
+ mStatsMinus[4] = new Button("-", "INT-", this);
+ mStatsMinus[5] = new Button("-", "WIL-", this);
+
// Set position
mStatsTitleLabel->setPosition(mHpLabel->getX(), mHpLabel->getY() + 23 );
mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
int totalLabelY = mStatsTotalLabel->getY();
- mStatsCostLabel->setPosition(170, totalLabelY);
for (int i = 0; i < 6; i++)
{
mStatsLabel[i]->setPosition(5,
mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(85,
+ mStatsMinus[i]->setPosition(85, totalLabelY + (i * 23) + 15);
+ mStatsDisplayLabel[i]->setPosition(125,
totalLabelY + (i * 23) + 15);
- mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10);
- mPointsLabel[i]->setPosition(165, totalLabelY + (i * 23) + 15);
+ mStatsPlus[i]->setPosition(185, totalLabelY + (i * 23) + 15);
}
- mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[6]->getY() + 25);
+ mCharacterPointsLabel->setPosition(5, mStatsDisplayLabel[5]->getY() + 25);
+ mCorrectionPointsLabel->setPosition(5, mStatsDisplayLabel[5]->getY() + 35);
/*
mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY());
mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY());
@@ -162,13 +168,12 @@ StatusWindow::StatusWindow(LocalPlayer *player):
// Assemble
add(mStatsTitleLabel);
add(mStatsTotalLabel);
- add(mStatsCostLabel);
for(int i = 0; i < 6; i++)
{
add(mStatsLabel[i]);
add(mStatsDisplayLabel[i]);
- add(mStatsButton[i]);
- add(mPointsLabel[i]);
+ add(mStatsPlus[i]);
+ add(mStatsMinus[i]);
}/*
add(mStatsAttackLabel);
add(mStatsDefenseLabel);
@@ -186,14 +191,19 @@ StatusWindow::StatusWindow(LocalPlayer *player):
add(mStatsEvadePoints);
add(mStatsReflexPoints);*/
- add(mRemainingStatsPointsLabel);
+ add(mCharacterPointsLabel);
+ add(mCorrectionPointsLabel);
}
void StatusWindow::update()
{
// Status Part
// -----------
- mLvlLabel->setCaption("Level: " + toString(mPlayer->getLevel()));
+ mLvlLabel->setCaption( "Level: " +
+ toString(mPlayer->getLevel()) +
+ " (" +
+ toString(mPlayer->getLevelProgress()) +
+ "%)");
mLvlLabel->adjustSize();
mMoneyLabel->setCaption("Money: " + toString(mPlayer->getMoney()) + " GP");
@@ -232,8 +242,8 @@ void StatusWindow::update()
"Intelligence",
"Willpower"
};
- int statusPoints = mPlayer->getAttributeIncreasePoints();
-
+ int characterPoints = mPlayer->getCharacterPoints();
+ int correctionPoints = mPlayer->getCorrectionPoints();
// Update labels
for (int i = 0; i < 6; i++)
{
@@ -246,11 +256,16 @@ void StatusWindow::update()
mStatsLabel[i]->adjustSize();
mStatsDisplayLabel[i]->adjustSize();
- mStatsButton[i]->setEnabled(statusPoints);
+ mStatsPlus[i]->setEnabled(characterPoints);
+ mStatsMinus[i]->setEnabled(correctionPoints);
}
- mRemainingStatsPointsLabel->setCaption("Remaining Status Points: " +
- toString(statusPoints));
- mRemainingStatsPointsLabel->adjustSize();
+ mCharacterPointsLabel->setCaption("Character Points: " +
+ toString(characterPoints));
+ mCharacterPointsLabel->adjustSize();
+
+ mCorrectionPointsLabel->setCaption("Correction Points: " +
+ toString(correctionPoints));
+ mCorrectionPointsLabel->adjustSize();
/*
// Derived Stats Points
@@ -304,31 +319,53 @@ void StatusWindow::action(const gcn::ActionEvent &event)
const std::string &eventId = event.getId();
// Stats Part
- if (eventId.length() == 3)
+ if (eventId == "STR+")
+ {
+ mPlayer->raiseAttribute(LocalPlayer::STR);
+ }
+ else if (eventId == "AGI+")
+ {
+ mPlayer->raiseAttribute(LocalPlayer::AGI);
+ }
+ else if (eventId == "DEX+")
+ {
+ mPlayer->raiseAttribute(LocalPlayer::DEX);
+ }
+ else if (eventId == "VIT+")
+ {
+ mPlayer->raiseAttribute(LocalPlayer::VIT);
+ }
+ else if (eventId == "INT+")
+ {
+ mPlayer->raiseAttribute(LocalPlayer::INT);
+ }
+ else if (eventId == "WIL+")
+ {
+ mPlayer->raiseAttribute(LocalPlayer::WIL);
+ }
+
+ else if (eventId == "STR-")
+ {
+ mPlayer->lowerAttribute(LocalPlayer::STR);
+ }
+ else if (eventId == "AGI-")
+ {
+ mPlayer->lowerAttribute(LocalPlayer::AGI);
+ }
+ else if (eventId == "DEX-")
+ {
+ mPlayer->lowerAttribute(LocalPlayer::DEX);
+ }
+ else if (eventId == "VIT-")
+ {
+ mPlayer->lowerAttribute(LocalPlayer::VIT);
+ }
+ else if (eventId == "INT-")
+ {
+ mPlayer->lowerAttribute(LocalPlayer::INT);
+ }
+ else if (eventId == "WIL-")
{
- if (eventId == "STR")
- {
- mPlayer->raiseAttribute(LocalPlayer::STR);
- }
- else if (eventId == "AGI")
- {
- mPlayer->raiseAttribute(LocalPlayer::AGI);
- }
- else if (eventId == "DEX")
- {
- mPlayer->raiseAttribute(LocalPlayer::DEX);
- }
- else if (eventId == "VIT")
- {
- mPlayer->raiseAttribute(LocalPlayer::VIT);
- }
- else if (eventId == "INT")
- {
- mPlayer->raiseAttribute(LocalPlayer::INT);
- }
- else if (eventId == "WIL")
- {
- mPlayer->raiseAttribute(LocalPlayer::WIL);
- }
+ mPlayer->lowerAttribute(LocalPlayer::WIL);
}
}
diff --git a/src/gui/status.h b/src/gui/status.h
index f3475263..6e613495 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -91,14 +91,15 @@ class StatusWindow : public Window, public gcn::ActionListener
* Stats captions.
*/
gcn::Label *mStatsLabel[6];
- gcn::Label *mPointsLabel[6];
gcn::Label *mStatsDisplayLabel[6];
- gcn::Label *mRemainingStatsPointsLabel;
+ gcn::Label *mCharacterPointsLabel;
+ gcn::Label *mCorrectionPointsLabel;
/**
* Stats buttons.
*/
- gcn::Button *mStatsButton[6];
+ gcn::Button *mStatsPlus[6];
+ gcn::Button *mStatsMinus[6];
};
extern StatusWindow *statusWindow;