forked from Mirrorlandia_minetest/minetest
Statbars: fix incorrect half-images in non-standard orientations (fixes #6198)
This commit is contained in:
parent
1f207a3ddb
commit
520b481383
22
src/hud.cpp
22
src/hud.cpp
@ -399,24 +399,32 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
|
|||||||
p += offset;
|
p += offset;
|
||||||
|
|
||||||
v2s32 steppos;
|
v2s32 steppos;
|
||||||
|
core::rect<s32> srchalfrect, dsthalfrect;
|
||||||
switch (drawdir) {
|
switch (drawdir) {
|
||||||
case HUD_DIR_RIGHT_LEFT:
|
case HUD_DIR_RIGHT_LEFT:
|
||||||
steppos = v2s32(-1, 0);
|
steppos = v2s32(-1, 0);
|
||||||
|
srchalfrect = core::rect<s32>(srcd.Width / 2, 0, srcd.Width, srcd.Height);
|
||||||
|
dsthalfrect = core::rect<s32>(dstd.Width / 2, 0, dstd.Width, dstd.Height);
|
||||||
break;
|
break;
|
||||||
case HUD_DIR_TOP_BOTTOM:
|
case HUD_DIR_TOP_BOTTOM:
|
||||||
steppos = v2s32(0, 1);
|
steppos = v2s32(0, 1);
|
||||||
|
srchalfrect = core::rect<s32>(0, 0, srcd.Width, srcd.Height / 2);
|
||||||
|
dsthalfrect = core::rect<s32>(0, 0, dstd.Width, dstd.Height / 2);
|
||||||
break;
|
break;
|
||||||
case HUD_DIR_BOTTOM_TOP:
|
case HUD_DIR_BOTTOM_TOP:
|
||||||
steppos = v2s32(0, -1);
|
steppos = v2s32(0, -1);
|
||||||
|
srchalfrect = core::rect<s32>(0, srcd.Height / 2, srcd.Width, srcd.Height);
|
||||||
|
dsthalfrect = core::rect<s32>(0, dstd.Height / 2, dstd.Width, dstd.Height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
steppos = v2s32(1, 0);
|
steppos = v2s32(1, 0);
|
||||||
|
srchalfrect = core::rect<s32>(0, 0, srcd.Width / 2, srcd.Height);
|
||||||
|
dsthalfrect = core::rect<s32>(0, 0, dstd.Width / 2, dstd.Height);
|
||||||
}
|
}
|
||||||
steppos.X *= dstd.Width;
|
steppos.X *= dstd.Width;
|
||||||
steppos.Y *= dstd.Height;
|
steppos.Y *= dstd.Height;
|
||||||
|
|
||||||
for (s32 i = 0; i < count / 2; i++)
|
for (s32 i = 0; i < count / 2; i++) {
|
||||||
{
|
|
||||||
core::rect<s32> srcrect(0, 0, srcd.Width, srcd.Height);
|
core::rect<s32> srcrect(0, 0, srcd.Width, srcd.Height);
|
||||||
core::rect<s32> dstrect(0,0, dstd.Width, dstd.Height);
|
core::rect<s32> dstrect(0,0, dstd.Width, dstd.Height);
|
||||||
|
|
||||||
@ -425,13 +433,9 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
|
|||||||
p += steppos;
|
p += steppos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count % 2 == 1)
|
if (count % 2 == 1) {
|
||||||
{
|
dsthalfrect += p;
|
||||||
core::rect<s32> srcrect(0, 0, srcd.Width / 2, srcd.Height);
|
draw2DImageFilterScaled(driver, stat_texture, dsthalfrect, srchalfrect, NULL, colors, true);
|
||||||
core::rect<s32> dstrect(0,0, dstd.Width / 2, dstd.Height);
|
|
||||||
|
|
||||||
dstrect += p;
|
|
||||||
draw2DImageFilterScaled(driver, stat_texture, dstrect, srcrect, NULL, colors, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user