Moves crafting table into a tab beside armor et al
This helps better use limited vertical space. The tab for awards is removed as well, temporarily, which I hope to move to another spot soon.
This commit is contained in:
parent
9437545ddb
commit
b8b4c832fe
6
init.lua
6
init.lua
|
@ -41,11 +41,11 @@ i3 = {
|
|||
},
|
||||
|
||||
categories = {
|
||||
"bag",
|
||||
"crafting",
|
||||
"armor",
|
||||
"bag",
|
||||
"skins",
|
||||
"awards",
|
||||
"waypoints",
|
||||
"waypoints"
|
||||
},
|
||||
|
||||
saves = { -- Metadata to save
|
||||
|
|
155
src/gui.lua
155
src/gui.lua
|
@ -280,6 +280,7 @@ local function get_isometric_view(fs, pos, X, Y, t, cubes, depth, high)
|
|||
animated_image(2.75, Y + shift, 3/14, 0.3, "i3_flag_anim.png", 4, 150)
|
||||
end
|
||||
|
||||
-- Writes the formspec for waypoints, displaying a list of waypoints.
|
||||
local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||
fs("box[0,%f;4.9,0.6;#bababa25]", yextra + 1.1)
|
||||
label(0, yextra + 0.85, ES"New waypoint" .. ":")
|
||||
|
@ -360,6 +361,16 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
|||
fs"style_type[label;font=normal;font_size=16;textcolor=#fff]"
|
||||
end
|
||||
|
||||
-- Writes the formspec for the crafting-table and item-removal trash icon.
|
||||
local function get_crafting_fs(fs, yoffset)
|
||||
fs("list[current_player;craft;%f,%f;3,3;]", 0, yoffset + .7)
|
||||
image(3.47, yoffset + 2.0, 0.85, 0.85, PNG.arrow)
|
||||
fs("list[current_player;craftpreview;%f,%f;1,1;]", 4.45, yoffset + 1.85) --2.6)
|
||||
fs("list[detached:i3_trash;main;%f,%f;1,1;]", 4.45, yoffset + 3.0) -- 3.75)
|
||||
image(4.45, yoffset + 3.0, 1, 1, PNG.trash) -- 3.75, 1,1
|
||||
end
|
||||
|
||||
-- Writes the formspec for the backpack slot + representation.
|
||||
local function get_bag_fs(fs, data, bag_size, yextra)
|
||||
fs("list[detached:i3_bag_%s;main;0,%f;1,1;]", data.player_name, yextra + 0.7)
|
||||
local bag = get_detached_inv("bag", data.player_name)
|
||||
|
@ -400,68 +411,8 @@ local function get_bag_fs(fs, data, bag_size, yextra)
|
|||
fs"style_type[list;size=1;spacing=0.15]"
|
||||
end
|
||||
|
||||
local function get_container(fs, data, player, yoffset, ctn_len, award_list, awards_unlocked, award_list_nb, bag_size)
|
||||
local nametag = player:get_nametag_attributes()
|
||||
local name = true_str(nametag.text) and nametag.text or data.player_name
|
||||
local esc_name = ESC(name)
|
||||
|
||||
add_subtitle(fs, "player_name", 0, ctn_len, 22, true, esc_name)
|
||||
|
||||
if damage_enabled then
|
||||
local hp = data.hp or player:get_hp() or 20
|
||||
local half = ceil((hp / 2) % 1)
|
||||
local hearts = (hp / 2) + half
|
||||
local heart_size = 0.35
|
||||
local heart_x, heart_h = 0.65, yoffset + 0.75
|
||||
|
||||
for i = 1, 10 do
|
||||
image(heart_x + ((i - 1) * (heart_size + 0.1)), heart_h,
|
||||
heart_size, heart_size, PNG.heart .. "^[colorize:#232428")
|
||||
end
|
||||
|
||||
for i = 1, hearts do
|
||||
image(heart_x + ((i - 1) * (heart_size + 0.1)), heart_h,
|
||||
heart_size, heart_size,
|
||||
(half == 1 and i == floor(hearts)) and PNG.heart_half or PNG.heart)
|
||||
end
|
||||
else
|
||||
yoffset -= 0.5
|
||||
end
|
||||
|
||||
fs("list[current_player;craft;%f,%f;3,3;]", 0, yoffset + 1.45)
|
||||
image(3.47, yoffset + 2.69, 0.85, 0.85, PNG.arrow)
|
||||
fs("list[current_player;craftpreview;%f,%f;1,1;]", 4.45, yoffset + 2.6)
|
||||
fs("list[detached:i3_trash;main;%f,%f;1,1;]", 4.45, yoffset + 3.75)
|
||||
image(4.45, yoffset + 3.75, 1, 1, PNG.trash)
|
||||
|
||||
local yextra = damage_enabled and 5.5 or 5
|
||||
|
||||
for i, title in ipairs(i3.categories) do
|
||||
local btn_name = fmt("btn_%s", title)
|
||||
fs("style[btn_%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]", title,
|
||||
data.subcat == i and PNG[fmt("%s_hover", title)] or PNG[title],
|
||||
PNG[fmt("%s_hover", title)])
|
||||
image_button(0.25 + ((i - 1) * 1.18), yextra - 0.2, 0.5, 0.5, "", btn_name, "")
|
||||
fs("tooltip[%s;%s;#32333899;#fff]", btn_name, title:gsub("^%l", upper))
|
||||
end
|
||||
|
||||
box(0, yextra + 0.45, ctn_len, 0.045, "#bababa50")
|
||||
image((data.subcat - 1) * 1.18, yextra + 0.45, 1, 0.045, PNG.highlight)
|
||||
|
||||
local function not_installed(modname)
|
||||
hypertext(0, yextra + 0.9, ctn_len, 0.6, "not_installed",
|
||||
fmt("<global size=16><center><style color=%s font=mono>%s</style> not installed</center>",
|
||||
colors.blue, modname))
|
||||
end
|
||||
|
||||
if data.subcat == 1 then
|
||||
get_bag_fs(fs, data, bag_size, yextra)
|
||||
|
||||
elseif data.subcat == 2 then
|
||||
if not i3.modules.armor then
|
||||
return not_installed "3d_armor"
|
||||
end
|
||||
|
||||
-- Writes formspec for the 3Darmor tab.
|
||||
local function get_3darmor_fs(data, fs, player, esc_name, yextra)
|
||||
local armor_def = armor.def[data.player_name]
|
||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||
|
||||
|
@ -497,12 +448,10 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
|||
label(1.1, yextra + 2.75, ES"Armor healing")
|
||||
|
||||
fs"style_type[label;font_size=16]"
|
||||
|
||||
elseif data.subcat == 3 then
|
||||
if not i3.modules.skins then
|
||||
return not_installed "skinsdb"
|
||||
end
|
||||
|
||||
-- Writes the formspec for the skinsdb skins-list, with image-buttons.
|
||||
local function get_skinsdb_fs(data, fs, player, yextra)
|
||||
local _skins = skins.get_skinlist_for_player(data.player_name)
|
||||
local skin_name = skins.get_player_skin(player).name
|
||||
local spp, add_y = 24, 0
|
||||
|
@ -542,14 +491,76 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
|||
image_button(X, Y, 1.86, 3.4, "", btn_name, "")
|
||||
fs("tooltip[%s;%s;#32333899;#fff]", btn_name, ESC(skin.name))
|
||||
end
|
||||
|
||||
elseif data.subcat == 4 then
|
||||
if not i3.modules.awards then
|
||||
return not_installed "awards"
|
||||
end
|
||||
|
||||
yextra = yextra + 0.7
|
||||
get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlocked, award_list_nb)
|
||||
-- Writes the formspec for the tabbed menu above the inventory; with crafting-table, etc.
|
||||
local function get_container(fs, data, player, yoffset, ctn_len, award_list, awards_unlocked, award_list_nb, bag_size)
|
||||
local nametag = player:get_nametag_attributes()
|
||||
local name = true_str(nametag.text) and nametag.text or data.player_name
|
||||
local esc_name = ESC(name)
|
||||
|
||||
add_subtitle(fs, "player_name", 0, ctn_len, 22, true, esc_name)
|
||||
|
||||
if damage_enabled then
|
||||
local hp = data.hp or player:get_hp() or 20
|
||||
local half = ceil((hp / 2) % 1)
|
||||
local hearts = (hp / 2) + half
|
||||
local heart_size = 0.35
|
||||
local heart_x, heart_h = 0.65, yoffset + 0.75
|
||||
|
||||
for i = 1, 10 do
|
||||
image(heart_x + ((i - 1) * (heart_size + 0.1)), heart_h,
|
||||
heart_size, heart_size, PNG.heart .. "^[colorize:#232428")
|
||||
end
|
||||
|
||||
for i = 1, hearts do
|
||||
image(heart_x + ((i - 1) * (heart_size + 0.1)), heart_h,
|
||||
heart_size, heart_size,
|
||||
(half == 1 and i == floor(hearts)) and PNG.heart_half or PNG.heart)
|
||||
end
|
||||
else
|
||||
yoffset -= 0.5
|
||||
end
|
||||
|
||||
local yextra = 1.5 -- damage_enabled and 5.5 or 5
|
||||
|
||||
for i, title in ipairs(i3.categories) do
|
||||
local btn_name = fmt("btn_%s", title)
|
||||
fs("style[btn_%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]", title,
|
||||
data.subcat == i and PNG[fmt("%s_hover", title)] or PNG[title],
|
||||
PNG[fmt("%s_hover", title)])
|
||||
image_button(0.25 + ((i - 1) * 1.18), yextra - 0.2, 0.5, 0.5, "", btn_name, "")
|
||||
fs("tooltip[%s;%s;#32333899;#fff]", btn_name, title:gsub("^%l", upper))
|
||||
end
|
||||
|
||||
box(0, yextra + 0.45, ctn_len, 0.045, "#bababa50")
|
||||
image((data.subcat - 1) * 1.18, yextra + 0.45, 1, 0.045, PNG.highlight)
|
||||
|
||||
local function not_installed(modname)
|
||||
hypertext(0, yextra + 0.9, ctn_len, 0.6, "not_installed",
|
||||
fmt("<global size=16><center><style color=%s font=mono>%s</style> not installed</center>",
|
||||
colors.blue, modname))
|
||||
end
|
||||
|
||||
if data.subcat == 1 then
|
||||
get_crafting_fs(fs, yextra)
|
||||
|
||||
elseif data.subcat == 2 then
|
||||
if not i3.modules.armor then
|
||||
return not_installed "3d_armor"
|
||||
end
|
||||
|
||||
get_3darmor_fs(data, fs, player, esc_name, yextra)
|
||||
|
||||
elseif data.subcat == 3 then
|
||||
get_bag_fs(fs, data, bag_size, yextra)
|
||||
|
||||
elseif data.subcat == 4 then
|
||||
if not i3.modules.skins then
|
||||
return not_installed "skinsdb"
|
||||
end
|
||||
|
||||
get_skinsdb_fs(data, fs, player, yextra)
|
||||
|
||||
elseif data.subcat == 5 then
|
||||
get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 442 B |
Ŝarĝante…
Reference in New Issue