summaryrefslogtreecommitdiff
path: root/src/gui/ministatus.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-21 11:00:36 -0700
committerJared Adams <jaxad0127@gmail.com>2009-02-21 11:00:36 -0700
commit68340bb2222890407b03e2dd7868c0e13a13a156 (patch)
tree31a23db6f7a6d43ee410a807f90cb2f231c1fbef /src/gui/ministatus.cpp
parentdf37ad4697e674d16859e69c0ce358283f410e20 (diff)
downloadmana-68340bb2222890407b03e2dd7868c0e13a13a156.tar.gz
mana-68340bb2222890407b03e2dd7868c0e13a13a156.tar.bz2
mana-68340bb2222890407b03e2dd7868c0e13a13a156.tar.xz
mana-68340bb2222890407b03e2dd7868c0e13a13a156.zip
Fix bug when maximum level is reached
Also centralize code for updating the various progress bars for player status.
Diffstat (limited to 'src/gui/ministatus.cpp')
-rw-r--r--src/gui/ministatus.cpp36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 25f17bd3..9a3d27cc 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -22,6 +22,7 @@
#include "gui.h"
#include "ministatus.h"
#include "progressbar.h"
+#include "status.h"
#include "../animatedsprite.h"
#include "../configuration.h"
@@ -76,36 +77,9 @@ extern volatile int tick_time;
void MiniStatusWindow::update()
{
- // HP Bar coloration
- if (player_node->mHp < int(player_node->mMaxHp / 3))
- {
- mHpBar->setColor(223, 32, 32); // Red
- }
- else if (player_node->mHp < int((player_node->mMaxHp / 3) * 2))
- {
- mHpBar->setColor(230, 171, 34); // Orange
- }
- else
- {
- mHpBar->setColor(0, 171, 34); // Green
- }
-
- float xp = (float) player_node->getXp() / player_node->mXpForNextLevel;
-
- if (xp != xp) xp = 0.0f; // check for NaN
- if (xp < 0.0f) xp = 0.0f; // make sure the experience isn't negative (uninitialized pointer most likely)
- if (xp > 1.0f) xp = 1.0f;
-
- mHpBar->setProgress((float) player_node->mHp / player_node->mMaxHp);
- mMpBar->setProgress((float) player_node->mMp / player_node->mMaxMp);
- mXpBar->setProgress(xp);
-
- // Update labels
- mHpBar->setText(toString(player_node->mHp));
- mMpBar->setText(toString(player_node->mMp));
-
- std::stringstream updatedText;
- updatedText << (float) ((int) (xp * 10000.0f)) / 100.0f << "%";
+ StatusWindow::updateHPBar(mHpBar);
+ StatusWindow::updateMPBar(mMpBar);
+ StatusWindow::updateXPBar(mXpBar);
// Displays the number of monsters to next lvl
// (disabled for now but interesting idea)
@@ -120,8 +94,6 @@ void MiniStatusWindow::update()
}
*/
- mXpBar->setText(updatedText.str());
-
for (unsigned int i = 0; i < mIcons.size(); i++)
if (mIcons[i])
mIcons[i]->update(tick_time * 10);