From bb4ef529548d2d27fbea0617347d49eb7ba70b85 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nathana=C3=ABl=20Courant?= Date: Sun, 27 Aug 2017 19:06:40 +0200 Subject: [PATCH] Statbars: fix incorrect half-images in non-standard orientations (fixes #6198) --- src/hud.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/hud.cpp b/src/hud.cpp index a2f031b4c..6895349ef 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -407,24 +407,32 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, p += offset; v2s32 steppos; + core::rect srchalfrect, dsthalfrect; switch (drawdir) { case HUD_DIR_RIGHT_LEFT: steppos = v2s32(-1, 0); + srchalfrect = core::rect(srcd.Width / 2, 0, srcd.Width, srcd.Height); + dsthalfrect = core::rect(dstd.Width / 2, 0, dstd.Width, dstd.Height); break; case HUD_DIR_TOP_BOTTOM: steppos = v2s32(0, 1); + srchalfrect = core::rect(0, 0, srcd.Width, srcd.Height / 2); + dsthalfrect = core::rect(0, 0, dstd.Width, dstd.Height / 2); break; case HUD_DIR_BOTTOM_TOP: steppos = v2s32(0, -1); + srchalfrect = core::rect(0, srcd.Height / 2, srcd.Width, srcd.Height); + dsthalfrect = core::rect(0, dstd.Height / 2, dstd.Width, dstd.Height); break; default: steppos = v2s32(1, 0); + srchalfrect = core::rect(0, 0, srcd.Width / 2, srcd.Height); + dsthalfrect = core::rect(0, 0, dstd.Width / 2, dstd.Height); } steppos.X *= dstd.Width; steppos.Y *= dstd.Height; - for (s32 i = 0; i < count / 2; i++) - { + for (s32 i = 0; i < count / 2; i++) { core::rect srcrect(0, 0, srcd.Width, srcd.Height); core::rect dstrect(0,0, dstd.Width, dstd.Height); @@ -433,13 +441,9 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, p += steppos; } - if (count % 2 == 1) - { - core::rect srcrect(0, 0, srcd.Width / 2, srcd.Height); - core::rect dstrect(0,0, dstd.Width / 2, dstd.Height); - - dstrect += p; - draw2DImageFilterScaled(driver, stat_texture, dstrect, srcrect, NULL, colors, true); + if (count % 2 == 1) { + dsthalfrect += p; + draw2DImageFilterScaled(driver, stat_texture, dsthalfrect, srchalfrect, NULL, colors, true); } } -- 2.25.1