diff options
author | ewew ukek <ewewukek@gmail.com> | 2024-09-23 20:28:13 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-09-23 20:28:13 +0000 |
commit | f9e62010fb73efb22476c64fe13947b0437b7633 (patch) | |
tree | d62f5fa36585331a3ade2c3ca067638cd4b989a8 /src | |
parent | 8dc4ae48a375a1f217d13bcc356eb1aebed546a6 (diff) | |
download | plus-f9e62010fb73efb22476c64fe13947b0437b7633.tar.gz plus-f9e62010fb73efb22476c64fe13947b0437b7633.tar.bz2 plus-f9e62010fb73efb22476c64fe13947b0437b7633.tar.xz plus-f9e62010fb73efb22476c64fe13947b0437b7633.zip |
Show MP bar below HP bar
Adds a light blue bar for MP below player's HP bar. It shows only if M.Atk is above 0.
I didn't add a checkbox to the settings to disable this, let me know if I should.
Squashed with:
* Sneak in another TODO
* Sneak in a TODO
****
mana/plus!68
Co-authored-by: Fedja Beader <fedja@protonmail.ch>
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 35 | ||||
-rw-r--r-- | src/enums/gui/usercolorid.h | 2 | ||||
-rw-r--r-- | src/gui/userpalette.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_colors.cpp | 2 |
4 files changed, 49 insertions, 4 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 1a9ce201f..75c9651d5 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -3999,16 +3999,40 @@ void Being::drawPlayerSpriteAt(Graphics *restrict const graphics, localPlayer == this && mAction != BeingAction::DEAD) { + int barX = x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(); + int barY = y + mapTileSize - 6 + mInfo->getHpBarOffsetY(); + const int barW = 2 * 50; + const int barH = 4; + + const bool drawMpBar = + PlayerInfo::getStatEffective(Attributes::PLAYER_MATK) > 0; + if (drawMpBar) + barY -= 3; + drawHpBar(graphics, PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP), PlayerInfo::getAttribute(Attributes::PLAYER_HP), 0, UserColorId::PLAYER_HP_FG, UserColorId::PLAYER_HP_BG, - x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(), - y + mapTileSize - 6 + mInfo->getHpBarOffsetY(), - 2 * 50, - 4); + barX, + barY, + barW, + barH); + + if (drawMpBar) + { + drawHpBar(graphics, + PlayerInfo::getAttribute(Attributes::PLAYER_MAX_MP), + PlayerInfo::getAttribute(Attributes::PLAYER_MP), + 0, + UserColorId::PLAYER_MP_FG, + UserColorId::PLAYER_MP_BG, + barX, + barY + barH + 1, + barW, + barH); + } } } @@ -4281,6 +4305,7 @@ void Being::drawPortalSpriteAt(Graphics *restrict const graphics, CompoundSprite::drawSimple(graphics, x, y); } +// TODO: Additionally used for drawing the MP/SP bar void Being::drawHpBar(Graphics *restrict const graphics, const int maxHP, const int hp, @@ -4317,6 +4342,8 @@ void Being::drawHpBar(Graphics *restrict const graphics, const int dx = static_cast<int>(static_cast<float>(width) / p); #ifdef TMWA_SUPPORT + // TODO: this is support for pre-2015 TMWAthena, remove in 2025? + // See mana/plus!68. if (!serverFeatures->haveServerHp()) { // old servers if ((damage == 0 && (this != localPlayer || hp == maxHP)) diff --git a/src/enums/gui/usercolorid.h b/src/enums/gui/usercolorid.h index 3a5e91203..0607173bb 100644 --- a/src/enums/gui/usercolorid.h +++ b/src/enums/gui/usercolorid.h @@ -58,6 +58,8 @@ enumStart(UserColorId) LABEL_HP, PLAYER_HP_FG, PLAYER_HP_BG, + PLAYER_MP_FG, + PLAYER_MP_BG, MONSTER_HP_FG, MONSTER_HP_BG, HOMUN_HP_FG, diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 8ad436a60..dbed4a93e 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -64,6 +64,8 @@ const std::string ColorTypeNames[CAST_SIZE( "", "ColorPlayerHp", "ColorPlayerHp2", + "ColorPlayerMp", + "ColorPlayerMp2", "ColorMonsterHp", "ColorMonsterHp2", "ColorHomunHp", @@ -296,6 +298,18 @@ UserPalette::UserPalette() : // TRANSLATORS: palette color _("Player HP bar (background)"), 50); + addColor(UserColorId::PLAYER_MP_FG, + 0x00a0ff, + GradientType::STATIC, + // TRANSLATORS: palette color + _("Player MP bar"), + 50); + addColor(UserColorId::PLAYER_MP_BG, + 0x303030, + GradientType::STATIC, + // TRANSLATORS: palette color + _("Player MP bar (background)"), + 50); addColor(UserColorId::MONSTER_HP_FG, 0x00ff00, GradientType::STATIC, diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 0fde9b1f6..71cebc71d 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -367,6 +367,8 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) case UserColorId::ELEMENTAL_HP_BG: case UserColorId::PLAYER_HP_FG: case UserColorId::PLAYER_HP_BG: + case UserColorId::PLAYER_MP_FG: + case UserColorId::PLAYER_MP_BG: case UserColorId::FLOOR_ITEM_TEXT: case UserColorId::NET: // TRANSLATORS: colors tab. label. |