summaryrefslogtreecommitdiff
path: root/src/gui/ministatus.cpp
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/ministatus.cpp
parent6f9a2e74958d794fb049253833b98982e915df45 (diff)
downloadmana-346bb6d670d630d65f8c35125831c75d031aac7f.tar.gz
mana-346bb6d670d630d65f8c35125831c75d031aac7f.tar.bz2
mana-346bb6d670d630d65f8c35125831c75d031aac7f.tar.xz
mana-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/ministatus.cpp')
-rw-r--r--src/gui/ministatus.cpp54
1 files changed, 6 insertions, 48 deletions
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)