diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 31 | ||||
-rw-r--r-- | src/gui/ministatus.h | 1 |
3 files changed, 31 insertions, 3 deletions
@@ -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; |