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
|
||||
|
|
191
src/gui.lua
191
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,6 +411,89 @@ local function get_bag_fs(fs, data, bag_size, yextra)
|
|||
fs"style_type[list;size=1;spacing=0.15]"
|
||||
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")
|
||||
|
||||
fs("list[detached:%s_armor;armor;0,%f;5,1;]", esc_name, yextra + 0.7)
|
||||
|
||||
for i = 1, 5 do
|
||||
local stack = armor_inv:get_stack("armor", i)
|
||||
|
||||
if stack:is_empty() then
|
||||
local tips = {ES"Helmet", ES"Chest", ES"Leggings", ES"Boots", ES"Shield"}
|
||||
local x = (i - 1) + ((i - 1) * 0.15)
|
||||
local y = yextra + 0.7
|
||||
|
||||
image(x, y, 1, 1, fmt("i3_armor_%u.png", i))
|
||||
tooltip(x, y, 1, 1, tips[i])
|
||||
end
|
||||
end
|
||||
|
||||
local box_len, max_level, max_heal = 4, 85, 60
|
||||
local bar_lvl = (armor_def.level * box_len) / max_level
|
||||
local bar_heal = (armor_def.heal * box_len) / max_heal
|
||||
|
||||
fs"style_type[label;font_size=15]"
|
||||
|
||||
box(0.8, yextra + 1.95, box_len, 0.4, "#101010")
|
||||
fs"style_type[box;colors=#9dc34c80,#9dc34c,#9dc34c,#9dc34c80]"
|
||||
box(0.8, yextra + 1.95, bar_lvl, 0.4, "")
|
||||
label(1.1, yextra + 2.15, ES"Armor level")
|
||||
|
||||
box(0.8, yextra + 2.55, box_len, 0.4, "#101010")
|
||||
fs"style_type[box;colors=#4466aa80,#4466aa,#4466aa,#4466aa80]"
|
||||
box(0.8, yextra + 2.55, bar_heal, 0.4, "")
|
||||
label(1.1, yextra + 2.75, ES"Armor healing")
|
||||
|
||||
fs"style_type[label;font_size=16]"
|
||||
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
|
||||
|
||||
if #_skins > spp then
|
||||
local btn_y = yextra + 0.75
|
||||
add_y += 0.6
|
||||
|
||||
data.skin_pagemax = max(1, ceil(#_skins / spp))
|
||||
|
||||
image_button(1.5, btn_y, 0.35, 0.35, "", "prev_skin", "")
|
||||
image_button(3.85, btn_y, 0.35, 0.35, "", "next_skin", "")
|
||||
|
||||
fs"style[skin_page;font=bold;font_size=18]"
|
||||
button(1.85, btn_y - 0.23, 2, 0.8, "skin_page",
|
||||
fmt("%s / %u", clr(colors.yellow, data.skin_pagenum), data.skin_pagemax))
|
||||
end
|
||||
|
||||
local first = (data.skin_pagenum - 1) * spp
|
||||
local last = first + spp - 1
|
||||
|
||||
for i = first, last do
|
||||
local skin = _skins[i + 1]
|
||||
if not skin then break end
|
||||
local btn_name = fmt("skin_btn_%u", i + 1)
|
||||
|
||||
fs([[ style[%s;padding=10;fgimg=%s;bgimg=%s;bgimg_hovered=i3_btn9_hovered.png;
|
||||
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6;sound=] ]],
|
||||
btn_name, skin:get_preview(),
|
||||
skin.name == skin_name and "i3_btn9_hovered.png" or "i3_btn9.png")
|
||||
|
||||
local X = (i % 3) * 1.93
|
||||
|
||||
local Y = ceil((i % spp - X) / 3 + 1)
|
||||
Y += (Y * 2.45) + yextra - 2.75 + add_y
|
||||
|
||||
image_button(X, Y, 1.86, 3.4, "", btn_name, "")
|
||||
fs("tooltip[%s;%s;#32333899;#fff]", btn_name, ESC(skin.name))
|
||||
end
|
||||
end
|
||||
|
||||
-- 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
|
||||
|
@ -428,13 +522,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
|||
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
|
||||
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)
|
||||
|
@ -455,101 +543,24 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
|||
end
|
||||
|
||||
if data.subcat == 1 then
|
||||
get_bag_fs(fs, data, bag_size, yextra)
|
||||
get_crafting_fs(fs, yextra)
|
||||
|
||||
elseif data.subcat == 2 then
|
||||
if not i3.modules.armor then
|
||||
return not_installed "3d_armor"
|
||||
end
|
||||
|
||||
local armor_def = armor.def[data.player_name]
|
||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||
|
||||
fs("list[detached:%s_armor;armor;0,%f;5,1;]", esc_name, yextra + 0.7)
|
||||
|
||||
for i = 1, 5 do
|
||||
local stack = armor_inv:get_stack("armor", i)
|
||||
|
||||
if stack:is_empty() then
|
||||
local tips = {ES"Helmet", ES"Chest", ES"Leggings", ES"Boots", ES"Shield"}
|
||||
local x = (i - 1) + ((i - 1) * 0.15)
|
||||
local y = yextra + 0.7
|
||||
|
||||
image(x, y, 1, 1, fmt("i3_armor_%u.png", i))
|
||||
tooltip(x, y, 1, 1, tips[i])
|
||||
end
|
||||
end
|
||||
|
||||
local box_len, max_level, max_heal = 4, 85, 60
|
||||
local bar_lvl = (armor_def.level * box_len) / max_level
|
||||
local bar_heal = (armor_def.heal * box_len) / max_heal
|
||||
|
||||
fs"style_type[label;font_size=15]"
|
||||
|
||||
box(0.8, yextra + 1.95, box_len, 0.4, "#101010")
|
||||
fs"style_type[box;colors=#9dc34c80,#9dc34c,#9dc34c,#9dc34c80]"
|
||||
box(0.8, yextra + 1.95, bar_lvl, 0.4, "")
|
||||
label(1.1, yextra + 2.15, ES"Armor level")
|
||||
|
||||
box(0.8, yextra + 2.55, box_len, 0.4, "#101010")
|
||||
fs"style_type[box;colors=#4466aa80,#4466aa,#4466aa,#4466aa80]"
|
||||
box(0.8, yextra + 2.55, bar_heal, 0.4, "")
|
||||
label(1.1, yextra + 2.75, ES"Armor healing")
|
||||
|
||||
fs"style_type[label;font_size=16]"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if #_skins > spp then
|
||||
local btn_y = yextra + 0.75
|
||||
add_y += 0.6
|
||||
|
||||
data.skin_pagemax = max(1, ceil(#_skins / spp))
|
||||
|
||||
image_button(1.5, btn_y, 0.35, 0.35, "", "prev_skin", "")
|
||||
image_button(3.85, btn_y, 0.35, 0.35, "", "next_skin", "")
|
||||
|
||||
fs"style[skin_page;font=bold;font_size=18]"
|
||||
button(1.85, btn_y - 0.23, 2, 0.8, "skin_page",
|
||||
fmt("%s / %u", clr(colors.yellow, data.skin_pagenum), data.skin_pagemax))
|
||||
end
|
||||
|
||||
local first = (data.skin_pagenum - 1) * spp
|
||||
local last = first + spp - 1
|
||||
|
||||
for i = first, last do
|
||||
local skin = _skins[i + 1]
|
||||
if not skin then break end
|
||||
local btn_name = fmt("skin_btn_%u", i + 1)
|
||||
|
||||
fs([[ style[%s;padding=10;fgimg=%s;bgimg=%s;bgimg_hovered=i3_btn9_hovered.png;
|
||||
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6;sound=] ]],
|
||||
btn_name, skin:get_preview(),
|
||||
skin.name == skin_name and "i3_btn9_hovered.png" or "i3_btn9.png")
|
||||
|
||||
local X = (i % 3) * 1.93
|
||||
|
||||
local Y = ceil((i % spp - X) / 3 + 1)
|
||||
Y += (Y * 2.45) + yextra - 2.75 + add_y
|
||||
|
||||
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)
|
||||
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