From b8b4c832fee576525f438a09fe60d0f8aaa720f4 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:12:20 -0600 Subject: [PATCH] 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. --- init.lua | 6 +- src/gui.lua | 191 +++++++++++++++++++++------------------ textures/i3_crafting.png | Bin 1842 -> 442 bytes 3 files changed, 104 insertions(+), 93 deletions(-) diff --git a/init.lua b/init.lua index 80efa43..5346889 100644 --- a/init.lua +++ b/init.lua @@ -41,11 +41,11 @@ i3 = { }, categories = { - "bag", + "crafting", "armor", + "bag", "skins", - "awards", - "waypoints", + "waypoints" }, saves = { -- Metadata to save diff --git a/src/gui.lua b/src/gui.lua index d998a69..4519657 100644 --- a/src/gui.lua +++ b/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) diff --git a/textures/i3_crafting.png b/textures/i3_crafting.png index 06d44e766cef687b419821a90db2c9dadfdd72e7..ecf0ecff03ad7f41ba8ce5355a7bf229d6d858b3 100644 GIT binary patch delta 417 zcmdnQw~Kj#ay?_Cr;B4q#jUrq484vxNVM+n2@E?eD)yD3Y5Rtc9AROXqbsDP6W7?d z>uuJ#v7>uxMnt!)VxLFZ#hLaKzALysYyYDk-Q2>l2EE^^_Rv3N^ zRJYzxy60C}j%8V{nw`uB54l%W>tdqAgyo}{SsWPPh->xTq}9t3yL^Q45Dx2T!u&wf7qsI2xd63fqDfkLPim xf>Q)8Drqnzmvv4FO#tt{up|Hg delta 1828 zcmV+<2i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