summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-31 23:42:39 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-31 23:42:39 +0300
commit52d9663b97db3dfc419e16f2d0ba50bba0a85d82 (patch)
tree983b8623bd284bef445647d596c984d21370cba3
parent009c615d000bd45af6679694d2604a59e8122374 (diff)
downloadmanaverse-52d9663b97db3dfc419e16f2d0ba50bba0a85d82.tar.gz
manaverse-52d9663b97db3dfc419e16f2d0ba50bba0a85d82.tar.bz2
manaverse-52d9663b97db3dfc419e16f2d0ba50bba0a85d82.tar.xz
manaverse-52d9663b97db3dfc419e16f2d0ba50bba0a85d82.zip
Show hp and max hp in being popup.
-rw-r--r--src/being/being.h3
-rw-r--r--src/gui/popups/beingpopup.cpp20
2 files changed, 22 insertions, 1 deletions
diff --git a/src/being/being.h b/src/being/being.h
index 6b805a3b6..c242d2e7e 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -746,6 +746,9 @@ class Being notfinal : public ActorSprite,
int getHP() const restrict2 noexcept2 A_WARN_UNUSED
{ return mHP; }
+ int getMaxHP() const restrict2 noexcept2 A_WARN_UNUSED
+ { return mMaxHP; }
+
uint8_t calcDirection(const int dstX,
const int dstY) const restrict2 A_WARN_UNUSED;
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
index 308629343..44432c4d5 100644
--- a/src/gui/popups/beingpopup.cpp
+++ b/src/gui/popups/beingpopup.cpp
@@ -72,7 +72,7 @@ void BeingPopup::postInit()
void BeingPopup::addLabels(const int fontHeight)
{
- for (int f = 0; f < 10; f ++)
+ for (int f = 0; f < 11; f ++)
{
Label *const label = new Label(this, "A");
label->setPosition(0, fontHeight * (f + 1));
@@ -261,6 +261,24 @@ void BeingPopup::show(const int x, const int y, Being *const b)
num ++;
}
+ const int maxHp = b->getMaxHP();
+ if (maxHp > 0)
+ {
+ int hp = b->getHP();
+ if (hp == 0)
+ hp = maxHp - b->getDamageTaken();
+ if (hp > 0)
+ {
+ ptr = mLabels[num];
+ // TRANSLATORS: being popup label
+ ptr->setCaption(strprintf(_("Hp: %d/%d"),
+ hp,
+ maxHp));
+ ptr->adjustSize();
+ num ++;
+ }
+ }
+
ptr = mLabels[num];
// TRANSLATORS: being popup label
ptr->setCaption(strprintf(_("Particles: %u"),