diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-02-23 14:04:18 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-02-25 18:28:11 +0100 |
commit | 6cfb5140c94dc1a8350f14a4be88d2e0e7956b4c (patch) | |
tree | 4229b64cd817a23ace5cf85904832c038dc56f47 /src/gui | |
parent | e0c3bba0cb009a82b68e729edf7cb8dcb9291f06 (diff) | |
download | mana-6cfb5140c94dc1a8350f14a4be88d2e0e7956b4c.tar.gz mana-6cfb5140c94dc1a8350f14a4be88d2e0e7956b4c.tar.bz2 mana-6cfb5140c94dc1a8350f14a4be88d2e0e7956b4c.tar.xz mana-6cfb5140c94dc1a8350f14a4be88d2e0e7956b4c.zip |
Fixed status effect icon positions
The status effect icons are implemented as sprites. Traditionally, since
sprites were rendered on the map, they were by default centered
horizontally on a tile and aligned to the bottom of the tile. The
necessary offsets were part of the animation frames.
This was changed in ae4aea451d6e2c44b273c963026c4fd697568f79 and
0248b2f58c783f21b7e68a20deadc0a3f942c869, which moved this offset to be
applied at a later stage. At that point, client data was changed to
remove this offset from the status effect icons, where it wasn't
meaningful.
Unfortunately, those client data changes were later reverted because the
M+ fork of the client still applies the above offsets to the animation
frames. Hence, to fix the status icon sprite positions, Mana client now
applies the same offsets when rendering the status icons.
Closes https://git.themanaworld.org/mana/mana/-/issues/95
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/ministatuswindow.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 1218fbf3..4c2a7b1d 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -22,6 +22,7 @@ #include "gui/ministatuswindow.h" #include "configuration.h" +#include "game.h" #include "graphics.h" #include "playerinfo.h" #include "sprite.h" @@ -46,6 +47,8 @@ #include "utils/stringutils.h" #include "utils/time.h" +static constexpr int ICON_SPACING = 4; + MiniStatusWindow::MiniStatusWindow(): Popup("MiniStatus") { @@ -113,12 +116,19 @@ void MiniStatusWindow::eraseIcon(int index) void MiniStatusWindow::drawIcons(Graphics *graphics) { - // Draw icons - int icon_x = mXpBar->getX() + mXpBar->getWidth() + 14; + const auto game = Game::instance(); + const int tileWidth = game->getCurrentTileWidth(); + const int tileHeight = game->getCurrentTileHeight(); + + int iconX = mXpBar->getX() + mXpBar->getWidth() + 3 + tileWidth / 2; + int iconY = 3 + tileHeight; + for (auto &icon : mIcons) { - icon->draw(graphics, icon_x, 3); - icon_x += 2 + icon->getWidth(); + icon->draw(graphics, + iconX - icon->getWidth() / 2, + iconY - icon->getHeight()); + iconX += ICON_SPACING + icon->getWidth(); } } |