Add tooltips to the map formspec

This commit is contained in:
Hugues Ross 2020-04-21 07:54:16 -04:00
parent e16893f82e
commit 8f0e161b7c
2 changed files with 6 additions and 4 deletions

View File

@ -32,7 +32,7 @@ local function show_map_id_formspec(id, player_x, player_z, player_name, height_
formspec = formspec .. string.format("image_button[0.125,0.125;0.5,0.5;%s.png;height_button;]", cartographer.skin.flat_button_texture)
end
formspec = formspec .. "container_end[]";
formspec = formspec .. "tooltip[height_button;Toggle height view] container_end[]";
end
minetest.show_formspec(player_name, "cartographer:map", formspec);
end

View File

@ -10,7 +10,7 @@
function _cartographer.generate_marker_formspec(selected_id, detail, page, bg, button)
local fs = string.format("background9[0,0;3.25,3.875;%s.png;false;%s]", bg.texture, tostring(bg.radius))
.. string.format("style_type[button,image_button;border=false;bgimg=%s.png;bgimg_hovered=%s.png;bgimg_pressed=%s.png;bgimg_middle=%s;textcolor=%s]", button.texture, button.hovered_texture, button.pressed_texture, tostring(button.radius), button.font_color)
.. "button[0.125,0.125;1.125,0.5;clear_marker;Erase]";
.. "button[0.125,0.125;1.125,0.5;clear_marker;Erase] tooltip[clear_marker;Remove the selected marker]";
if selected_id then
fs = fs .. string.format("style[marker-%s;bgimg=%s.png;bgimg_hovered=%s.png;bgimg_pressed=%s.png]", selected_id, button.selected_texture, button.selected_texture, button.selected_texture);
end
@ -18,11 +18,13 @@ function _cartographer.generate_marker_formspec(selected_id, detail, page, bg, b
local starting_id = ((page - 1) * 20) + 1;
for i = starting_id,math.min(#_cartographer.marker_lookup,starting_id + 19),1 do
local marker = _cartographer.marker_lookup[i];
fs = fs .. string.format("image_button[%f,%f;0.5,0.5;%s.png;marker-%s;]",
fs = fs .. string.format("image_button[%f,%f;0.5,0.5;%s.png;marker-%s;] tooltip[marker-%s;%s]",
(i - starting_id) % 5 * 0.625 + 0.125,
math.floor((i - starting_id) / 5) * 0.625 + 0.75,
marker.textures[math.min(detail, #marker.textures)],
marker.id);
marker.id,
marker.id,
marker.name);
end
if page > 1 then