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 9de795e..b748c27 100644 Binary files a/textures/i3_next_hover.png and b/textures/i3_next_hover.png differ