1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Restore proportional minimap scaling (#15022)

This commit is contained in:
grorp 2024-08-31 18:11:56 +02:00 committed by GitHub
parent 52376fd87a
commit 322a9c2f74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 7 deletions

View file

@ -568,14 +568,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);