mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2025-06-29 23:10:45 +02:00
Convert over to formspec version 4
I recreated the original layout as best as practical, but by necessity there are a few minor positioning changes, since the underlying hard-wired inventory slots are square now and image positioning is now scaled by exactly 1.250 in both dimensions (as opposed to roughly 1.25 by 1.16). Backstage, I also needed to fix the aspect ratios of the various inventory slot elements. That meant redesigning the single-slot image from scratch. It was already blurry/grainy and a little ugly, and trying to alter it would have only made it worse. The slot image is now exactly 56x56 pixels square, set on a 64x64 canvas, so there's a 4 pixel empty space around the edges. The full 256px .xcf workfile is included in the UI folder. I've re-tiled all slot/inv images from the new single slot. I also re-rendered the trash can icon from it since it was blurry and oddly-sized. I couldn't find the original upstream image, so since they're free, I used one of my Linux system's icons which happens to resemble it. I also removed a couple more improper uses of `background[]` where `image[]` is more appropriate. There are tons of minor tweaks throughout the code to re-align everything, and I had to rewrite a few sections to avoid code duplication and to allow for a little more flexibility (mainly to make "lite" mode look right).
This commit is contained in:
@ -17,20 +17,27 @@ local waypoints_temp = {}
|
||||
unified_inventory.register_page("waypoints", {
|
||||
get_formspec = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
local wp_info_x = unified_inventory.form_header_x + 1.25
|
||||
local wp_info_y = unified_inventory.form_header_y + 0.5
|
||||
local wp_bottom_row = unified_inventory.std_inv_y - 1
|
||||
local wp_buttons_rj = unified_inventory.std_inv_x + 10.1 - unified_inventory.btn_spc
|
||||
local wp_edit_w = unified_inventory.btn_spc * 4 - 0.1
|
||||
|
||||
-- build a "fake" temp entry if the server took too long
|
||||
-- during sign-on and returned an empty entry
|
||||
if not waypoints_temp[player_name] then waypoints_temp[player_name] = {hud = 1} end
|
||||
|
||||
local waypoints = datastorage.get(player_name, "waypoints")
|
||||
local formspec = string.gsub(unified_inventory.standard_inv_bg, "YYY", "4.4") ..
|
||||
"image[0,0;1,1;ui_waypoints_icon.png]" ..
|
||||
"label[1,0;" .. F(S("Waypoints")) .. "]"
|
||||
local formspec = unified_inventory.standard_inv_bg..
|
||||
"label["..unified_inventory.form_header_x..","..unified_inventory.form_header_y..";" .. F(S("Waypoints")) .. "]"..
|
||||
"image["..wp_info_x..","..wp_info_y..";1,1;ui_waypoints_icon.png]"
|
||||
|
||||
-- Tabs buttons:
|
||||
for i = 1, 5, 1 do
|
||||
for i = 1, 5 do
|
||||
formspec = formspec ..
|
||||
"image_button[0.0," .. 0.2 + i * 0.7 .. ";.8,.8;" ..
|
||||
"image_button["..unified_inventory.main_button_x..","..
|
||||
(wp_bottom_row - (5-i) * unified_inventory.btn_spc)..";"..
|
||||
unified_inventory.btn_size..","..unified_inventory.btn_size..";" ..
|
||||
(i == waypoints.selected and "ui_blue_icon_background.png^" or "") ..
|
||||
"ui_" .. i .. "_icon.png;" ..
|
||||
"select_waypoint" .. i .. ";]" ..
|
||||
@ -44,65 +51,52 @@ unified_inventory.register_page("waypoints", {
|
||||
local default_name = S("Waypoint @1", i)
|
||||
|
||||
-- Main buttons:
|
||||
formspec = formspec ..
|
||||
"image_button[4.5,3.7;.8,.8;"..
|
||||
"ui_waypoint_set_icon.png;"..
|
||||
"set_waypoint"..i..";]"..
|
||||
"tooltip[set_waypoint" .. i .. ";"
|
||||
.. F(S("Set waypoint to current location")).."]"
|
||||
-- note: the @1's in the set, arrow, and pencil tooltips are dummies.
|
||||
local btnlist = {
|
||||
{ "ui_waypoint_set_icon.png", "set_waypoint", "Set waypoint to current location@1" },
|
||||
{ waypoint.active and "ui_on_icon.png" or "ui_off_icon.png", "toggle_waypoint", "Make waypoint @1", waypoint.active and "invisible" or "visible" },
|
||||
{ waypoint.display_pos and "ui_green_icon_background.png" or "ui_red_icon_background.png", "toggle_display_pos", "@1 display of waypoint coordinates", waypoint.display_pos and "Disable" or "Enable" },
|
||||
{ "ui_circular_arrows_icon.png", "toggle_color", "Change color of waypoint display@1" },
|
||||
{ "ui_pencil_icon.png", "rename_waypoint", "Edit waypoint name@1" }
|
||||
}
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[5.2,3.7;.8,.8;"..
|
||||
(waypoint.active and "ui_on_icon.png" or "ui_off_icon.png")..";"..
|
||||
"toggle_waypoint"..i..";]"..
|
||||
"tooltip[toggle_waypoint" .. i .. ";"
|
||||
.. F(S("Make waypoint @1",
|
||||
waypoint.active and S("invisible") or S("visible"))).."]"
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[5.9,3.7;.8,.8;"..
|
||||
(waypoint.display_pos and "ui_green_icon_background.png" or "ui_red_icon_background.png").."^ui_xyz_icon.png;"..
|
||||
"toggle_display_pos" .. i .. ";]"..
|
||||
"tooltip[toggle_display_pos" .. i .. ";"
|
||||
.. F(S("@1 display of waypoint coordinates",
|
||||
waypoint.display_pos and S("Disable") or S("Enable"))) .."]"
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[6.6,3.7;.8,.8;"..
|
||||
"ui_circular_arrows_icon.png;"..
|
||||
"toggle_color"..i..";]"..
|
||||
"tooltip[toggle_color" .. i .. ";"
|
||||
.. F(S("Change color of waypoint display")).."]"
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[7.3,3.7;.8,.8;"..
|
||||
"ui_pencil_icon.png;"..
|
||||
"rename_waypoint"..i..";]"..
|
||||
"tooltip[rename_waypoint" .. i .. ";"
|
||||
.. F(S("Edit waypoint name")).."]"
|
||||
local x = 4
|
||||
for _, b in pairs(btnlist) do
|
||||
formspec = formspec ..
|
||||
"image_button["..(wp_buttons_rj - unified_inventory.btn_spc * x)..","..
|
||||
wp_bottom_row..";"..
|
||||
unified_inventory.btn_size..","..unified_inventory.btn_size..";"..
|
||||
b[1]..";"..
|
||||
b[2]..i..";]"..
|
||||
"tooltip["..b[2]..i..";"..F(S(b[3], b[4] or "")).."]"
|
||||
x = x - 1
|
||||
end
|
||||
|
||||
-- Waypoint's info:
|
||||
formspec = formspec.."label["..wp_info_x..","..(wp_info_y+1.1)..";"
|
||||
if waypoint.active then
|
||||
formspec = formspec .. "label[1,0.8;"..F(S("Waypoint active")).."]"
|
||||
formspec = formspec ..F(S("Waypoint active")).."]"
|
||||
else
|
||||
formspec = formspec .. "label[1,0.8;"..F(S("Waypoint inactive")).."]"
|
||||
formspec = formspec ..F(S("Waypoint inactive")).."]"
|
||||
end
|
||||
|
||||
if temp.edit then
|
||||
formspec = formspec ..
|
||||
"field[1.3,3.2;6,.8;rename_box" .. i .. ";;"
|
||||
..(waypoint.name or default_name).."]" ..
|
||||
"image_button[7.3,2.9;.8,.8;"..
|
||||
"field["..(wp_buttons_rj - wp_edit_w - 0.1)..","..(wp_bottom_row - unified_inventory.btn_spc)..";"..
|
||||
wp_edit_w..","..unified_inventory.btn_size..";rename_box" .. i .. ";;"..
|
||||
(waypoint.name or default_name).."]" ..
|
||||
"image_button["..wp_buttons_rj..","..(wp_bottom_row - unified_inventory.btn_spc)..";"..
|
||||
unified_inventory.btn_size..","..unified_inventory.btn_size..";"..
|
||||
"ui_ok_icon.png;"..
|
||||
"confirm_rename"..i.. ";]"..
|
||||
"tooltip[confirm_rename" .. i .. ";"
|
||||
.. F(S("Finish editing")).."]"
|
||||
end
|
||||
|
||||
formspec = formspec .. "label[1,1.3;"..F(S("World position"))..": " ..
|
||||
formspec = formspec .. "label["..wp_info_x..","..(wp_info_y+1.6)..";"..F(S("World position"))..": " ..
|
||||
minetest.pos_to_string(waypoint.world_pos or vector.new()) .. "]" ..
|
||||
"label[1,1.8;"..F(S("Name"))..": ".. (waypoint.name or default_name) .. "]" ..
|
||||
"label[1,2.3;"..F(S("HUD text color"))..": " ..
|
||||
"label["..wp_info_x..","..(wp_info_y+2.10)..";"..F(S("Name"))..": ".. (waypoint.name or default_name) .. "]" ..
|
||||
"label["..wp_info_x..","..(wp_info_y+2.60)..";"..F(S("HUD text color"))..": " ..
|
||||
hud_colors[waypoint.color or 1][3] .. "]"
|
||||
|
||||
return {formspec=formspec}
|
||||
|
Reference in New Issue
Block a user