summaryrefslogtreecommitdiff
path: root/src/gui/statuswindow.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
commitcc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch)
treeedd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/statuswindow.cpp
parentb0df784f1be44a657ca8092069488602270629b7 (diff)
parent99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff)
downloadmana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz
mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2
mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz
mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip
Merge branch 'eathena/master'
Conflicts: A lot of files.
Diffstat (limited to 'src/gui/statuswindow.cpp')
-rw-r--r--src/gui/statuswindow.cpp50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index bcac0a90..8d4363d9 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -208,28 +208,7 @@ void StatusWindow::update()
mMoneyLabel->setCaption("Money: " + toString(mPlayer->getMoney()) + " GP");
mMoneyLabel->adjustSize();
- int hp = mPlayer->getHp();
- int maxHp = mPlayer->getMaxHp();
-
- mHpValueLabel->setCaption(toString(hp) +
- " / " + toString(maxHp));
- mHpValueLabel->adjustSize();
-
- // HP Bar coloration
- if (hp < int(maxHp / 3))
- {
- mHpBar->setColor(223, 32, 32); // Red
- }
- else if (hp < int((maxHp / 3) * 2))
- {
- mHpBar->setColor(230, 171, 34); // Orange
- }
- else
- {
- mHpBar->setColor(0, 171, 34); // Green
- }
-
- mHpBar->setProgress((float) hp / maxHp);
+ updateHPBar(mHpBar, true);
// Stats Part
// ----------
@@ -368,3 +347,30 @@ void StatusWindow::action(const gcn::ActionEvent &event)
mPlayer->lowerAttribute(LocalPlayer::WIL);
}
}
+
+// WARNING: Duplicated method!
+
+void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax)
+{
+ if (showMax)
+ bar->setText(toString(player_node->getHp()) +
+ "/" + toString(player_node->getMaxHp()));
+ else
+ bar->setText(toString(player_node->getHp()));
+
+ // HP Bar coloration
+ if (player_node->getHp() < player_node->getMaxHp() / 3)
+ {
+ bar->setColor(223, 32, 32); // Red
+ }
+ else if (player_node->getHp() < (player_node->getMaxHp() / 3) * 2)
+ {
+ bar->setColor(230, 171, 34); // Orange
+ }
+ else
+ {
+ bar->setColor(0, 171, 34); // Green
+ }
+
+ bar->setProgress((float) player_node->getHp() / (float) player_node->getMaxHp());
+}