summaryrefslogtreecommitdiff
path: root/src/gui/ministatus.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-30 01:34:16 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-02-09 20:00:07 +0100
commit1b1050da1c7b84cc72b7efbb2229294975be9e10 (patch)
tree68d15ccb015d58aeb5797ffd06efca3e55997c24 /src/gui/ministatus.cpp
parent0d4142a891cd228da24ee3aa3bbd7dc622da5b75 (diff)
parent955a7613d1fe116fe5e1da07a222b6849b3c885c (diff)
downloadmana-client-1b1050da1c7b84cc72b7efbb2229294975be9e10.tar.gz
mana-client-1b1050da1c7b84cc72b7efbb2229294975be9e10.tar.bz2
mana-client-1b1050da1c7b84cc72b7efbb2229294975be9e10.tar.xz
mana-client-1b1050da1c7b84cc72b7efbb2229294975be9e10.zip
Merged with Aethyra master as of 2009-01-27
Conflicts: Almost everywhere.
Diffstat (limited to 'src/gui/ministatus.cpp')
-rw-r--r--src/gui/ministatus.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index e613a745..915db961 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -19,14 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "ministatus.h"
-
#include "gui.h"
+#include "ministatus.h"
#include "progressbar.h"
-#include "../localplayer.h"
#include "../configuration.h"
#include "../graphics.h"
+#include "../localplayer.h"
#include "../utils/tostring.h"
@@ -90,24 +89,22 @@ void MiniStatusWindow::update()
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);
- if (player_node->MATK <= 0)
- mMpBar->setColor(100, 100, 100); // grey, to indicate that we lack magic
- else
- mMpBar->setColor(26, 102, 230); // blue, to indicate that we have magic
-
- mXpBar->setProgress(
- (float) player_node->getXp() / player_node->mXpForNextLevel);
+ mXpBar->setProgress(xp);
// Update labels
mHpBar->setText(toString(player_node->mHp));
mMpBar->setText(toString(player_node->mMp));
std::stringstream updatedText;
- updatedText << (int) (
- (float) player_node->getXp() /
- player_node->mXpForNextLevel * 100) << "%";
+ updatedText << (float) ((int) (xp * 10000.0f)) / 100.0f << "%";
// Displays the number of monsters to next lvl
// (disabled for now but interesting idea)