summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2007-03-22 23:10:27 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2007-03-22 23:10:27 +0000
commit346bb6d670d630d65f8c35125831c75d031aac7f (patch)
treec79877ea0d6b46ae748bf4a6d6d3969dc483f0a4 /src/gui
parent6f9a2e74958d794fb049253833b98982e915df45 (diff)
downloadmana-client-346bb6d670d630d65f8c35125831c75d031aac7f.tar.gz
mana-client-346bb6d670d630d65f8c35125831c75d031aac7f.tar.bz2
mana-client-346bb6d670d630d65f8c35125831c75d031aac7f.tar.xz
mana-client-346bb6d670d630d65f8c35125831c75d031aac7f.zip
Redesigned the localplayer class to use getters and setters instead of direct access to the member variables. Implemented communication of attributes between server and client.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/char_select.cpp4
-rw-r--r--src/gui/inventorywindow.cpp4
-rw-r--r--src/gui/ministatus.cpp54
-rw-r--r--src/gui/ministatus.h4
-rw-r--r--src/gui/skill.cpp33
-rw-r--r--src/gui/skill.h3
-rw-r--r--src/gui/status.cpp95
-rw-r--r--src/gui/status.h8
8 files changed, 42 insertions, 163 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index bd348c88..09ce5b87 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -194,8 +194,8 @@ void CharSelectDialog::updatePlayerInfo()
if (pi)
{
mNameLabel->setCaption(pi->getName());
- mLevelLabel->setCaption("Lvl: " + toString(pi->mLevel));
- mMoneyLabel->setCaption("Money: " + toString(pi->mMoney));
+ mLevelLabel->setCaption("Lvl: " + toString(pi->getLevel()));
+ mMoneyLabel->setCaption("Money: " + toString(pi->getMoney()));
if (!mCharSelected)
{
mNewCharButton->setEnabled(false);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index e533c16c..44d042a6 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -94,8 +94,8 @@ void InventoryWindow::logic()
// Update weight information
mWeightLabel->setCaption(
- "Total Weight: " + toString(player_node->mTotalWeight) + " - "
- "Maximum Weight: " + toString(player_node->mMaxWeight));
+ "Total Weight: " + toString(player_node->getTotalWeight()) + " - "
+ "Maximum Weight: " + toString(player_node->getMaxWeight()));
mWeightLabel->adjustSize();
}
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 932b1f22..9a4c2273 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -43,51 +43,32 @@ MiniStatusWindow::MiniStatusWindow():
setTitleBarHeight(0);
mHpBar = new ProgressBar(1.0f, 100, 20, 0, 171, 34);
- mMpBar = new ProgressBar(1.0f, 100, 20, 26, 102, 230);
- mXpBar = new ProgressBar(1.0f, 100, 20, 143, 192, 211);
mHpLabel = new gcn::Label("");
- mMpLabel = new gcn::Label("");
- mXpLabel = new gcn::Label("");
mHpBar->setPosition(0, 3);
- mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
- mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3);
mHpLabel->setDimension(mHpBar->getDimension());
- mMpLabel->setDimension(mMpBar->getDimension());
- mXpLabel->setDimension(mXpBar->getDimension());
mHpLabel->setForegroundColor(gcn::Color(255, 255, 255));
- mMpLabel->setForegroundColor(gcn::Color(255, 255, 255));
- mXpLabel->setForegroundColor(gcn::Color(255, 255, 255));
mHpLabel->setFont(speechFont);
- mMpLabel->setFont(speechFont);
- mXpLabel->setFont(speechFont);
mHpLabel->setAlignment(gcn::Graphics::CENTER);
- mMpLabel->setAlignment(gcn::Graphics::CENTER);
- mXpLabel->setAlignment(gcn::Graphics::CENTER);
add(mHpBar);
- add(mMpBar);
- add(mXpBar);
add(mHpLabel);
- add(mMpLabel);
- add(mXpLabel);
-
- setDefaultSize(0, 0, mXpBar->getX() + mXpBar->getWidth(),
- mXpBar->getY() + mXpBar->getHeight());
}
void MiniStatusWindow::update()
{
// HP Bar coloration
- if (player_node->mHp < int(player_node->mMaxHp / 3))
+ int maxHp = player_node->getMaxHP();
+ int hp = player_node->getHP();
+ if (hp < int(maxHp / 3))
{
mHpBar->setColor(223, 32, 32); // Red
}
- else if (player_node->mHp < int((player_node->mMaxHp / 3) * 2))
+ else if (hp < int((maxHp / 3) * 2))
{
mHpBar->setColor(230, 171, 34); // Orange
}
@@ -96,33 +77,10 @@ void MiniStatusWindow::update()
mHpBar->setColor(0, 171, 34); // Green
}
- mHpBar->setProgress((float) player_node->mHp / player_node->mMaxHp);
- // mMpBar->setProgress((float) player_node->mMp / player_node->mMaxMp);
- mXpBar->setProgress((float) player_node->mXp / player_node->mXpForNextLevel);
+ mHpBar->setProgress((float) hp / maxHp);
// Update labels
- mHpLabel->setCaption(toString(player_node->mHp));
- mMpLabel->setCaption(toString(player_node->mMp));
-
- std::stringstream updatedText;
- updatedText << (int) (
- (float) player_node->mXp /
- player_node->mXpForNextLevel * 100) << "%";
-
- // Displays the number of monsters to next lvl
- // (disabled for now but interesting idea)
- /*
- if(config.getValue("xpBarMonsterCounterExp", 0)!=0)
- {
- updatedText << " | "
- << (int)(((float)player_node->mXpForNextLevel - (float)player_node->mXp)
- / (float)config.getValue("xpBarMonsterCounterExp", 0))
- << " "
- << config.getValue("xpBarMonsterCounterName", "Monsters") <<" left...";
- }
- */
-
- mXpLabel->setCaption(updatedText.str());
+ mHpLabel->setCaption(toString(hp));
}
void MiniStatusWindow::draw(gcn::Graphics *graphics)
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index 718fe140..1192bc1e 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -60,11 +60,7 @@ class MiniStatusWindow : public Window
* Mini Status Bars
*/
ProgressBar *mHpBar;
- ProgressBar *mMpBar;
- ProgressBar *mXpBar;
gcn::Label *mHpLabel;
- gcn::Label *mMpLabel;
- gcn::Label *mXpLabel;
};
#endif
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 1b00a732..c9babda2 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -68,28 +68,17 @@ SkillDialog::SkillDialog():
mSkillListBox = new ListBox(this);
ScrollArea *skillScrollArea = new ScrollArea(mSkillListBox);
- mPointsLabel = new gcn::Label("Skill Points:");
- mIncButton = new Button("Up", "inc", this);
- mUseButton = new Button("Use", "use", this);
- mUseButton->setEnabled(false);
mCloseButton = new Button("Close", "close", this);
mSkillListBox->setActionEventId("skill");
skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180));
- mPointsLabel->setDimension(gcn::Rectangle(8, 190, 200, 16));
- mIncButton->setPosition(skillScrollArea->getX(), 210);
- mUseButton->setPosition(mIncButton->getX() + mIncButton->getWidth() + 5,
- 210);
mCloseButton->setPosition(
skillScrollArea->getX() + skillScrollArea->getWidth() - mCloseButton->getWidth(),
210);
add(skillScrollArea);
- add(mPointsLabel);
- add(mIncButton);
- add(mUseButton);
add(mCloseButton);
mSkillListBox->addActionListener(this);
@@ -105,20 +94,8 @@ SkillDialog::~SkillDialog()
void SkillDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "inc")
- {
- // Increment skill
- int selectedSkill = mSkillListBox->getSelected();
- if (selectedSkill >= 0)
- {
- player_node->raiseSkill(mSkillList[selectedSkill]->id);
- }
- }
- else if (event.getId() == "skill")
+ if (event.getId() == "skill")
{
- mIncButton->setEnabled(
- mSkillListBox->getSelected() > -1 &&
- player_node->mSkillPoint > 0);
}
else if (event.getId() == "close")
{
@@ -128,14 +105,6 @@ void SkillDialog::action(const gcn::ActionEvent &event)
void SkillDialog::update()
{
- if (mPointsLabel != NULL) {
- char tmp[128];
- sprintf(tmp, "Skill points: %i", player_node->mSkillPoint);
- mPointsLabel->setCaption(tmp);
- }
-
- mIncButton->setEnabled(mSkillListBox->getSelected() > -1 &&
- player_node->mSkillPoint > 0);
}
int SkillDialog::getNumberOfElements()
diff --git a/src/gui/skill.h b/src/gui/skill.h
index ed1257b0..b8794e35 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -71,9 +71,6 @@ class SkillDialog : public Window, public gcn::ActionListener,
private:
gcn::ListBox *mSkillListBox;
- gcn::Label *mPointsLabel;
- gcn::Button *mIncButton;
- gcn::Button *mUseButton;
gcn::Button *mCloseButton;
std::vector<SKILL*> mSkillList;
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 9c60752d..c7cb80c3 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -54,14 +54,6 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
mHpValueLabel = new gcn::Label("");
- mXpLabel = new gcn::Label("Exp:");
- mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211);
- mXpValueLabel = new gcn::Label("");
-
- mMpLabel = new gcn::Label("MP:");
- mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230);
- mMpValueLabel = new gcn::Label("");
-
int y = 3;
int x = 5;
@@ -78,30 +70,14 @@ StatusWindow::StatusWindow(LocalPlayer *player):
x += mHpBar->getWidth() + 5;
mHpValueLabel->setPosition(x, y);
- mXpLabel->setPosition(175, y);
- mXpBar->setPosition(205, y);
- mXpValueLabel->setPosition(290, y);
-
y += mHpLabel->getHeight() + 5; // Next Row
x = 5;
- mMpLabel->setPosition(x, y);
- x += mMpLabel->getWidth() + 5;
- mMpBar->setPosition(x, y);
- x += mMpBar->getWidth() + 5;
- mMpValueLabel->setPosition(x, y);
-
add(mLvlLabel);
add(mMoneyLabel);
add(mHpLabel);
add(mHpValueLabel);
- add(mMpLabel);
- add(mMpValueLabel);
- add(mXpLabel);
- add(mXpValueLabel);
add(mHpBar);
- add(mMpBar);
- add(mXpBar);
// ----------------------
// Stats Part
@@ -113,6 +89,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
gcn::Label *mStatsCostLabel = new gcn::Label("Cost");
// Derived Stats
+/*
mStatsAttackLabel = new gcn::Label("Attack:");
mStatsDefenseLabel= new gcn::Label("Defense:");
mStatsMagicAttackLabel = new gcn::Label("M.Attack:");
@@ -128,7 +105,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsAccuracyPoints = new gcn::Label("% Accuracy:");
mStatsEvadePoints = new gcn::Label("% Evade:");
mStatsReflexPoints = new gcn::Label("% Reflex:");
-
+*/
// New labels
for (int i = 0; i < 7; i++) {
mStatsLabel[i] = new gcn::Label();
@@ -148,7 +125,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
// Set position
- mStatsTitleLabel->setPosition(mMpLabel->getX(), mMpLabel->getY() + 23 );
+ mStatsTitleLabel->setPosition(mHpLabel->getX(), mHpLabel->getY() + 23 );
mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
int totalLabelY = mStatsTotalLabel->getY();
mStatsCostLabel->setPosition(170, totalLabelY);
@@ -157,14 +134,14 @@ StatusWindow::StatusWindow(LocalPlayer *player):
{
mStatsLabel[i]->setPosition(5,
mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(115,
+ mStatsDisplayLabel[i]->setPosition(85,
totalLabelY + (i * 23) + 15);
mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10);
- mPointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15);
+ mPointsLabel[i]->setPosition(165, totalLabelY + (i * 23) + 15);
}
mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[6]->getY() + 25);
-
+/*
mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY());
mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY());
mStatsMagicAttackLabel->setPosition(220, mStatsLabel[2]->getY());
@@ -180,7 +157,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsAccuracyPoints->setPosition(310, mStatsLabel[4]->getY());
mStatsEvadePoints->setPosition(310, mStatsLabel[5]->getY());
mStatsReflexPoints->setPosition(310, mStatsLabel[6]->getY());
-
+*/
// Assemble
add(mStatsTitleLabel);
add(mStatsTotalLabel);
@@ -191,7 +168,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
add(mStatsDisplayLabel[i]);
add(mStatsButton[i]);
add(mPointsLabel[i]);
- }
+ }/*
add(mStatsAttackLabel);
add(mStatsDefenseLabel);
add(mStatsMagicAttackLabel);
@@ -206,7 +183,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
add(mStatsMagicDefensePoints);
add(mStatsAccuracyPoints);
add(mStatsEvadePoints);
- add(mStatsReflexPoints);
+ add(mStatsReflexPoints);*/
add(mRemainingStatsPointsLabel);
}
@@ -215,30 +192,25 @@ void StatusWindow::update()
{
// Status Part
// -----------
- mLvlLabel->setCaption("Level: " + toString(mPlayer->mLevel));
+ mLvlLabel->setCaption("Level: " + toString(mPlayer->getLevel()));
mLvlLabel->adjustSize();
- mMoneyLabel->setCaption("Money: " + toString(mPlayer->mMoney) + " GP");
+ mMoneyLabel->setCaption("Money: " + toString(mPlayer->getMoney()) + " GP");
mMoneyLabel->adjustSize();
- mHpValueLabel->setCaption(toString(mPlayer->mHp) +
- "/" + toString(mPlayer->mMaxHp));
- mHpValueLabel->adjustSize();
-
- mMpValueLabel->setCaption(toString(mPlayer->mMp) +
- "/" + toString(mPlayer->mMaxMp));
- mMpValueLabel->adjustSize();
+ int hp = mPlayer->getHP();
+ int maxHp = mPlayer->getMaxHP();
- mXpValueLabel->setCaption(toString(mPlayer->mXp) +
- "/" + toString(mPlayer->mXpForNextLevel));
- mXpValueLabel->adjustSize();
+ mHpValueLabel->setCaption(toString(hp) +
+ " / " + toString(maxHp));
+ mHpValueLabel->adjustSize();
// HP Bar coloration
- if (mPlayer->mHp < int(mPlayer->mMaxHp / 3))
+ if (hp < int(maxHp / 3))
{
mHpBar->setColor(223, 32, 32); // Red
}
- else if (mPlayer->mHp < int((mPlayer->mMaxHp / 3) * 2))
+ else if (hp < int((maxHp / 3) * 2))
{
mHpBar->setColor(230, 171, 34); // Orange
}
@@ -247,11 +219,7 @@ void StatusWindow::update()
mHpBar->setColor(0, 171, 34); // Green
}
- mHpBar->setProgress((float)mPlayer->mHp / (float)mPlayer->mMaxHp);
- // mMpBar->setProgress((float)mPlayer->mp / (float)mPlayer->maxMp);
-
- mXpBar->setProgress(
- (float) mPlayer->mXp / (float) mPlayer->mXpForNextLevel);
+ mHpBar->setProgress((float)hp / maxHp);
// Stats Part
// ----------
@@ -264,24 +232,26 @@ void StatusWindow::update()
"Willpower",
"Charisma"
};
- int statusPoints = mPlayer->mStatsPointsToAttribute;
+ int statusPoints = mPlayer->getAttributeIncreasePoints();
// Update labels
for (int i = 0; i < 7; i++) {
mStatsLabel[i]->setCaption(attrNames[i]);
- mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i]));
- mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i]));
+ mStatsDisplayLabel[i]->setCaption(
+ toString(mPlayer->getAttributeEffective(i)) +
+ " / " +
+ toString(mPlayer->getAttributeBase(i))
+ );
mStatsLabel[i]->adjustSize();
mStatsDisplayLabel[i]->adjustSize();
- mPointsLabel[i]->adjustSize();
- mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints);
+ mStatsButton[i]->setEnabled(statusPoints);
}
mRemainingStatsPointsLabel->setCaption("Remaining Status Points: " +
toString(statusPoints));
mRemainingStatsPointsLabel->adjustSize();
-
+/*
// Derived Stats Points
// Attack TODO: Count equipped Weapons and items attack bonuses
@@ -315,20 +285,11 @@ void StatusWindow::update()
// Reflex %
mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
-
+*/
// Update Second column widgets position
mMoneyLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
mLvlLabel->getY());
- mXpLabel->setPosition(
- mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
- mHpLabel->getY());
- mXpBar->setPosition(
- mXpLabel->getX() + mXpLabel->getWidth() + 5,
- mXpLabel->getY());
- mXpValueLabel->setPosition(
- mXpBar->getX() + mXpBar->getWidth() + 5,
- mXpLabel->getY());
}
void StatusWindow::draw(gcn::Graphics *g)
diff --git a/src/gui/status.h b/src/gui/status.h
index 37f8a648..40d25a2a 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -70,14 +70,12 @@ class StatusWindow : public Window, public gcn::ActionListener {
* Status Part
*/
gcn::Label *mLvlLabel, *mMoneyLabel, *mHpLabel, *mHpValueLabel;
- gcn::Label *mMpLabel, *mMpValueLabel;
- gcn::Label *mXpLabel, *mXpValueLabel;
- ProgressBar *mHpBar, *mMpBar;
- ProgressBar *mXpBar;
+ ProgressBar *mHpBar;
/**
* Derived Statistics captions
*/
+/*
gcn::Label *mStatsAttackLabel, *mStatsDefenseLabel;
gcn::Label *mStatsMagicAttackLabel, *mStatsMagicDefenseLabel;
gcn::Label *mStatsAccuracyLabel, *mStatsEvadeLabel;
@@ -87,7 +85,7 @@ class StatusWindow : public Window, public gcn::ActionListener {
gcn::Label *mStatsMagicAttackPoints, *mStatsMagicDefensePoints;
gcn::Label *mStatsAccuracyPoints, *mStatsEvadePoints;
gcn::Label *mStatsReflexPoints;
-
+*/
/**
* Stats captions.
*/