summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-25 22:04:17 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-25 22:04:17 +0000
commit85bf6b54600356671f4bd52e4ca49f7fe5cbe24b (patch)
tree2291c7ab27f214ed810d52f5d58bfc3a99e530d1
parentb08056a18524d65924e2eb3e3ea4b7843e492cca (diff)
downloadmana-85bf6b54600356671f4bd52e4ca49f7fe5cbe24b.tar.gz
mana-85bf6b54600356671f4bd52e4ca49f7fe5cbe24b.tar.bz2
mana-85bf6b54600356671f4bd52e4ca49f7fe5cbe24b.tar.xz
mana-85bf6b54600356671f4bd52e4ca49f7fe5cbe24b.zip
Applied patch by mrha (Herbi), adding experience bar to the ministatus in the top left.
-rw-r--r--ChangeLog5
-rw-r--r--src/gui/ministatus.cpp42
-rw-r--r--src/gui/ministatus.h10
3 files changed, 49 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 448185d8..e32e12bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-08-26 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/ministatus.cpp, src/gui/ministatus.h: Applied patch by mrha
+ (Herbi), adding experience bar to the ministatus in the top left.
+
2006-08-25 Matthias Hartmann <hartmann.matthias@gmail.com>
* src/gui/char_select.cpp, src/gui/char_select.h, src/main.cpp: Added
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 53849550..932b1f22 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -29,6 +29,8 @@
#include "progressbar.h"
#include "../localplayer.h"
+#include "../configuration.h"
+#include "../graphics.h"
#include "../utils/tostring.h"
@@ -42,31 +44,40 @@ MiniStatusWindow::MiniStatusWindow():
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, mMpBar->getX() + mMpBar->getWidth(),
- mMpBar->getY() + mMpBar->getHeight());
+ setDefaultSize(0, 0, mXpBar->getX() + mXpBar->getWidth(),
+ mXpBar->getY() + mXpBar->getHeight());
}
void MiniStatusWindow::update()
@@ -85,12 +96,33 @@ void MiniStatusWindow::update()
mHpBar->setColor(0, 171, 34); // Green
}
- mHpBar->setProgress((float)player_node->mHp / (float)player_node->mMaxHp);
- // mpBar->setProgress((float)player_node->mp / (float)player_node->maxMp);
+ 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);
- // Update and center labels
+ // 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());
}
void MiniStatusWindow::draw(gcn::Graphics *graphics)
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index f56f847c..718fe140 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -56,11 +56,15 @@ class MiniStatusWindow : public Window
*/
void update();
- /**
+ /*
* Mini Status Bars
*/
- ProgressBar *mHpBar, *mMpBar;
- gcn::Label *mHpLabel, *mMpLabel;
+ ProgressBar *mHpBar;
+ ProgressBar *mMpBar;
+ ProgressBar *mXpBar;
+ gcn::Label *mHpLabel;
+ gcn::Label *mMpLabel;
+ gcn::Label *mXpLabel;
};
#endif