summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-09-28 19:26:24 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-09-28 19:26:24 +0000
commit208e046a49a1b429dc6a58563874f478c5857778 (patch)
treedefd0d6df51a5afe72139aba78a36e5381668ef6
parentb1acdc8b5ebc1ab9506e5910c1d6c37504007653 (diff)
downloadmana-client-208e046a49a1b429dc6a58563874f478c5857778.tar.gz
mana-client-208e046a49a1b429dc6a58563874f478c5857778.tar.bz2
mana-client-208e046a49a1b429dc6a58563874f478c5857778.tar.xz
mana-client-208e046a49a1b429dc6a58563874f478c5857778.zip
HP and MP display in the mini status window.
-rw-r--r--ChangeLog2
-rw-r--r--src/gui/ministatus.cpp31
-rw-r--r--src/gui/ministatus.h1
3 files changed, 31 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 266ae954..216e97d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2005-09-26 Yohann Ferreira <bertram@cegetel.net>
* src/gui/updaterwindow.cpp: Fixed the scroll bug in the update window.
+ * src/gui/ministatus.h, src/gui/ministatus.cpp: Added HP, MP Display
+ in mini-status window.
2005-09-28 Björn Steinbrink <B.Steinbrink@gmx.de>
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 2d834949..8814a5fd 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -23,7 +23,7 @@
#include "ministatus.h"
-// #include <guichan/widgets/label.hpp>
+#include <guichan/widgets/label.hpp>
#include <sstream>
#include "progressbar.h"
@@ -38,15 +38,24 @@ MiniStatusWindow::MiniStatusWindow():
setMovable(false);
hpBar = new ProgressBar(1.0f,
- 0, 3, 80, 15,
+ 0, 3, 100, 20,
0, 171, 34);
mpBar = new ProgressBar(1.0f,
hpBar->getX() + hpBar->getWidth() + 3,
- hpBar->getY(), 80, 15, 26, 102, 230);
+ hpBar->getY(), 100, 20, 26, 102, 230);
+
+ hpLabel = new gcn::Label("/");
+ mpLabel = new gcn::Label("/");
+ hpLabel->setPosition(hpBar->getX() + int((hpBar->getWidth() / 2) - (hpLabel->getWidth() / 2)),
+ hpBar->getY() + int((hpBar->getHeight() / 2) - (hpLabel->getHeight() / 2)));
+ mpLabel->setPosition(mpBar->getX() + int((mpBar->getWidth() / 2) - (mpLabel->getWidth() / 2)),
+ mpBar->getY() + int((mpBar->getHeight() / 2) - (mpLabel->getHeight() / 2)));
add(hpBar);
add(mpBar);
+ add(hpLabel);
+ add(mpLabel);
setContentSize(mpBar->getX() + mpBar->getWidth(),
mpBar->getY() + mpBar->getHeight());
@@ -56,6 +65,8 @@ MiniStatusWindow::~MiniStatusWindow()
{
delete hpBar;
delete mpBar;
+ delete hpLabel;
+ delete mpLabel;
}
void MiniStatusWindow::update()
@@ -79,6 +90,20 @@ void MiniStatusWindow::update()
hpBar->setProgress((float)player_info->hp / (float)player_info->maxHp);
// mpBar->setProgress((float)player_info->mp / (float)player_info->maxMp);
+
+ // Update and center labels
+ std::stringstream updatedText;
+ updatedText << player_info->hp << "/" << player_info->maxHp;
+ hpLabel->setCaption(updatedText.str());
+ hpLabel->adjustSize();
+ updatedText.str("");
+ updatedText << player_info->mp << "/" << player_info->maxMp;
+ mpLabel->setCaption(updatedText.str());
+ mpLabel->adjustSize();
+ hpLabel->setPosition(hpBar->getX() + int((hpBar->getWidth() / 2) - (hpLabel->getWidth() / 2)),
+ hpBar->getY() + int((hpBar->getHeight() / 2) - (hpLabel->getHeight() / 2)));
+ mpLabel->setPosition(mpBar->getX() + int((mpBar->getWidth() / 2) - (mpLabel->getWidth() / 2)),
+ mpBar->getY() + int((mpBar->getHeight() / 2) - (mpLabel->getHeight() / 2)));
}
void MiniStatusWindow::draw(gcn::Graphics *graphics)
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index 27c51e42..07aa5d4a 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -72,6 +72,7 @@ class MiniStatusWindow : public Window, public gcn::ActionListener {
* Mini Status Bars
*/
ProgressBar *hpBar, *mpBar;
+ gcn::Label *hpLabel, *mpLabel;
};
extern MiniStatusWindow *miniStatusWindow;