From e60f98648475b5beed3b3608cdceb499e142107f Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 15 Nov 2021 00:56:27 +0100 Subject: [PATCH] Minor polish --- API.md | 2 +- src/bags.lua | 14 +++++++++----- src/callbacks.lua | 8 ++++++-- src/gui.lua | 15 +++++++++------ textures/i3_next_hover.png | Bin 570 -> 7915 bytes 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/API.md b/API.md index 0b0f95a..99ddc21 100644 --- a/API.md +++ b/API.md @@ -2,7 +2,7 @@ ### Custom tabs -#### `i3.new_tab(def)` +#### `i3.new_tab(name, def)` Custom tabs can be added to the `i3` inventory as follow (example): diff --git a/src/bags.lua b/src/bags.lua index 99c0264..e819e9e 100644 --- a/src/bags.lua +++ b/src/bags.lua @@ -1,4 +1,4 @@ -local S, ES, fmt, clr, msg, slz, dslz = i3.get("S", "ES", "fmt", "clr", "msg", "slz", "dslz") +local S, ES, fmt, msg, slz, dslz = i3.get("S", "ES", "fmt", "msg", "slz", "dslz") local play_sound, create_inventory = i3.get("play_sound", "create_inventory") local function get_content_inv(name) @@ -131,9 +131,10 @@ local function init_bags(player) return c end + local percent = fmt("%.1f", (count_items() * 100) / (data.bag_size * 4)) + meta:set_string("description", "") - meta:set_string("description", ES("@1 (contains @2 / @3 stacks)", - bagstack:get_short_description(), clr("#ff0", count_items()), data.bag_size * 4)) + meta:set_string("description", ES("@1 (@2% full)", bagstack:get_description(), percent)) meta:set_string("content", slz(t)) end @@ -153,8 +154,11 @@ local function init_bags(player) if data.bag_item then local meta = bag:get_stack("main", 1):get_meta() - local content = dslz(meta:get_string"content") or {} - bag_content:set_list("main", get_content(content)) + local content = dslz(meta:get_string"content") + + if content then + bag_content:set_list("main", get_content(content)) + end end end diff --git a/src/callbacks.lua b/src/callbacks.lua index 3bb34fd..9eb0623 100644 --- a/src/callbacks.lua +++ b/src/callbacks.lua @@ -120,8 +120,12 @@ i3.new_tab("inventory", { data.confirm_trash = true elseif fields.settings then - data.confirm_trash = nil - data.show_settings = true + if not data.show_settings then + data.confirm_trash = nil + data.show_settings = true + else + data.show_settings = nil + end elseif fields.confirm_trash_yes or fields.confirm_trash_no then if fields.confirm_trash_yes then diff --git a/src/gui.lua b/src/gui.lua index b8d8d71..3f3abe8 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -452,9 +452,12 @@ local function show_popup(fs, data) local show_sorting = data.show_setting == "sorting" local show_misc = data.show_setting == "misc" - fs(fmt("style[setting_home;textcolor=%s;sound=i3_click]", show_home and colors.yellow or "#fff")) - fs(fmt("style[setting_sorting;textcolor=%s;sound=i3_click]", show_sorting and colors.yellow or "#fff")) - fs(fmt("style[setting_misc;textcolor=%s;sound=i3_click]", show_misc and colors.yellow or "#fff")) + fs(fmt("style[setting_home;textcolor=%s;font=bold;sound=i3_click]", + show_home and colors.yellow or "#fff")) + fs(fmt("style[setting_sorting;textcolor=%s;font=bold;sound=i3_click]", + show_sorting and colors.yellow or "#fff")) + fs(fmt("style[setting_misc;textcolor=%s;font=bold;sound=i3_click]", + show_misc and colors.yellow or "#fff")) fs("button", 2.2, 9.25, 1.8, 0.55, "setting_home", "Home") fs("button", 4, 9.25, 1.8, 0.55, "setting_sorting", "Sorting") @@ -496,9 +499,9 @@ local function show_popup(fs, data) elseif show_misc then fs("checkbox", 2.4, 10.05, "cb_inv_compress", "Compression", tostring(data.inv_compress)) - fs("checkbox", 2.4, 10.5, "cb_reverse_sorting", "Reverse sorting", tostring(data.reverse_sorting)) - fs("checkbox", 2.4, 10.95, "cb_auto_sorting", "Automatic sorting", tostring(data.auto_sorting)) - fs("checkbox", 5.4, 10.05, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar)) + fs("checkbox", 2.4, 10.5, "cb_reverse_sorting", "Reverse mode", tostring(data.reverse_sorting)) + fs("checkbox", 2.4, 10.95, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar)) + fs("checkbox", 5.4, 10.05, "cb_auto_sorting", "Automation", tostring(data.auto_sorting)) for _ = 1, 3 do fs("box", 5.4, 10.68, 2.4, 0.45, "#707070") diff --git a/textures/i3_next_hover.png b/textures/i3_next_hover.png index 9de795e4319a0a0e05c6f9badfd3e885ae414f1b..b748c27f7abbf8867e86bbb86814a2a1550ab4a5 100644 GIT binary patch literal 7915 zcmeHKXH-*Lw+-D;q$4Uy2#BDD6bK0jD4n1nO~4=}Bmp8JfrJte6jVT(fC5sK-n)W@ zUTg>mQZ7hGrI`;zl#b;E^tSQ7KX;7x{@sk6lXKRdYwoq?UVD$M2s2Yd0p5MQ002M$ zW29%n`aQXQ?c!$Li%DMN006&afR(Mc1m|8y^jDOgnD6^rO$q=Ppd@{`|ssD({PxS+AfmrwMVbjgc6OLfR#$uU6#WDxA$I?{s*Kk!1lqsb+O;W;OK05(n&>`^*~++yx}9F|?ZXeF z>Ye&!m3S%NG$WeqLQ>95YLvs1nX)1z)_JPDrr(W{ztKJdUHQ0Y zM(l{tr1!H(|Gly;F8gk(`OhK{*|Wk{P3(b?0nY zpBq|~>c1zA0_pKDr0{oork1t{99Wi!iNK1s>0RNqL=B`Eb62nBD`Vc53QWoG-J4pW z*Pw(P_q6qrg3F4IbMJpCa7^}Gm;WbGdv@Jtc8m3EEruC^tB2l9UJ;ae3d*+4jxp7j z){TZglR9<(<)I9nNX5K6#;QZ$RIP9+db`@~*5uIRdm8N@XC_=IE-Mc>s~dy-?ffYY ztyjniohZnIQDfAY?{ZG~!HdkA+gUtj`zY(e22!Lcb9u8gYZKHre&sHeFUM>KZd6|i zXoyD!5nh#^ei^#dzRwV^LCw-Pt)Gg%_74FSn;fepIB+JW8>=S&LF$Q=?YgA9xlv-2SFZ2gr26NzWP{ zkr#*8y=b&HWfqD6_Ydc*sYizQPj|NYRHN&^PB2x=V(_a`L8v-Pup}wQmK9_;3PQ6q9(NObXwX5Be!Qpb=Sk9qQs%4r4)+@MGm>wZ0v7sEO4HuHNZn`%rJS=u5j)n zgD*U`h8%+YLtM(8uFk`!N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