From 035e35c962896d9c8fd2ad9bced0f462346ae722 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Tue, 6 Jun 2023 19:37:16 +1200 Subject: [PATCH] Scale statbar background texture correctly when its resoltuion differs (cherry picked from commit 88c52130f81db79756087ffd95cd38d0ad2756a0) --- src/client/hud.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 1a08ac7ef..b028d79d7 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -622,6 +622,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, } core::dimension2di srcd(stat_texture->getOriginalSize()); + core::dimension2di srcd_bg = stat_texture_bg ? core::dimension2di(stat_texture_bg->getOriginalSize()) : srcd; core::dimension2di dstd; if (size == v2s32()) { dstd = srcd; @@ -685,7 +686,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, // Need to draw halves: Calculate rectangles srchalfrect = calculate_clipping_rect(srcd, steppos); dsthalfrect = calculate_clipping_rect(dstd, steppos); - srchalfrect2 = calculate_clipping_rect(srcd, steppos * -1); + srchalfrect2 = calculate_clipping_rect(srcd_bg, steppos * -1); dsthalfrect2 = calculate_clipping_rect(dstd, steppos * -1); } @@ -724,7 +725,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, else start_offset = count / 2; for (s32 i = start_offset; i < maxcount / 2; i++) { - core::rect srcrect(0, 0, srcd.Width, srcd.Height); + core::rect srcrect(0, 0, srcd_bg.Width, srcd_bg.Height); core::rect dstrect(0, 0, dstd.Width, dstd.Height); dstrect += p; @@ -736,7 +737,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, if (maxcount % 2 == 1) { draw2DImageFilterScaled(driver, stat_texture_bg, - dsthalfrect + p, srchalfrect, + dsthalfrect + p, calculate_clipping_rect(srcd_bg, steppos), NULL, colors, true); } }