mirror of
https://github.com/minetest/minetest.git
synced 2024-11-20 06:33:45 +01:00
Restore proportional minimap scaling (#15022)
This commit is contained in:
parent
52376fd87a
commit
322a9c2f74
@ -251,12 +251,17 @@ register_builtin_hud_element("minimap", {
|
||||
position = {x = 1, y = 0},
|
||||
alignment = {x = -1, y = 1},
|
||||
offset = {x = -10, y = 10},
|
||||
size = {x = 256, y = 256},
|
||||
size = {x = 0, y = -25},
|
||||
},
|
||||
show_elem = function(player, flags)
|
||||
local proto_ver = core.get_player_information(player:get_player_name()).protocol_version
|
||||
-- Don't add a minimap for clients which already have it hardcoded in C++.
|
||||
return flags.minimap and
|
||||
core.get_player_information(player:get_player_name()).protocol_version >= 44
|
||||
return flags.minimap and proto_ver >= 44
|
||||
end,
|
||||
update_def = function(player, elem_def)
|
||||
local proto_ver = core.get_player_information(player:get_player_name()).protocol_version
|
||||
-- Only use percentage when the client supports it.
|
||||
elem_def.size = proto_ver >= 45 and {x = 0, y = -25} or {x = 256, y = 256}
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -1809,6 +1809,11 @@ Displays a minimap on the HUD.
|
||||
|
||||
* `size`: Size of the minimap to display. Minimap should be a square to avoid
|
||||
distortion.
|
||||
* Negative values represent percentages of the screen. If either `x` or `y`
|
||||
is specified as a percentage, the resulting pixel size will be used for
|
||||
both `x` and `y`. Example: On a 1920x1080 screen, `{x = 0, y = -25}` will
|
||||
result in a 270x270 minimap.
|
||||
* Negative values are supported starting with protocol version 45.
|
||||
* `alignment`: The alignment of the minimap.
|
||||
* `offset`: offset in pixels from position.
|
||||
|
||||
|
@ -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);
|
||||
|
@ -225,7 +225,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
Move default minimap from client-side C++ to server-side builtin Lua
|
||||
[scheduled bump for 5.9.0]
|
||||
PROTOCOL VERSION 45:
|
||||
Reserved for minimap size change
|
||||
Minimap HUD element supports negative size values as percentages
|
||||
[bump for 5.9.1]
|
||||
PROTOCOL VERSION 46:
|
||||
Move default hotbar from client-side C++ to server-side builtin Lua
|
||||
[scheduled bump for 5.10.0]
|
||||
|
Loading…
Reference in New Issue
Block a user