1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Restore proportional minimap scaling (#15022)

This commit is contained in:
grorp 2024-08-31 18:11:56 +02:00 committed by SmallJoker
parent f79a51c265
commit ecf535ee83
4 changed files with 27 additions and 7 deletions

View file

@ -544,14 +544,21 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
}
break; }
case HUD_ELEM_MINIMAP: {
if (e->size.X <= 0 || e->size.Y <= 0)
break;
if (!client->getMinimap())
break;
// Draw a minimap of size "size"
v2s32 dstsize(e->size.X * m_scale_factor,
e->size.Y * m_scale_factor);
// (no percent size as minimap would likely be anamorphosed)
// Only one percentage is supported to avoid distortion.
if (e->size.X < 0)
dstsize.X = dstsize.Y = m_screensize.X * (e->size.X * -0.01);
else if (e->size.Y < 0)
dstsize.X = dstsize.Y = m_screensize.Y * (e->size.Y * -0.01);
if (dstsize.X <= 0 || dstsize.Y <= 0)
return;
v2s32 offset((e->align.X - 1.0) * dstsize.X / 2,
(e->align.Y - 1.0) * dstsize.Y / 2);
core::rect<s32> rect(0, 0, dstsize.X, dstsize.Y);