Minor polish

This commit is contained in:
Jean-Patrick Guerrero 2021-11-15 00:56:27 +01:00
parent f2248ae176
commit e60f986484
5 changed files with 25 additions and 14 deletions

2
API.md
View File

@ -2,7 +2,7 @@
### Custom tabs ### Custom tabs
#### `i3.new_tab(def)` #### `i3.new_tab(name, def)`
Custom tabs can be added to the `i3` inventory as follow (example): Custom tabs can be added to the `i3` inventory as follow (example):

View File

@ -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 play_sound, create_inventory = i3.get("play_sound", "create_inventory")
local function get_content_inv(name) local function get_content_inv(name)
@ -131,9 +131,10 @@ local function init_bags(player)
return c return c
end end
local percent = fmt("%.1f", (count_items() * 100) / (data.bag_size * 4))
meta:set_string("description", "") meta:set_string("description", "")
meta:set_string("description", ES("@1 (contains @2 / @3 stacks)", meta:set_string("description", ES("@1 (@2% full)", bagstack:get_description(), percent))
bagstack:get_short_description(), clr("#ff0", count_items()), data.bag_size * 4))
meta:set_string("content", slz(t)) meta:set_string("content", slz(t))
end end
@ -153,10 +154,13 @@ local function init_bags(player)
if data.bag_item then if data.bag_item then
local meta = bag:get_stack("main", 1):get_meta() local meta = bag:get_stack("main", 1):get_meta()
local content = dslz(meta:get_string"content") or {} local content = dslz(meta:get_string"content")
if content then
bag_content:set_list("main", get_content(content)) bag_content:set_list("main", get_content(content))
end end
end end
end
local bag_recipes = { local bag_recipes = {
small = { small = {

View File

@ -120,8 +120,12 @@ i3.new_tab("inventory", {
data.confirm_trash = true data.confirm_trash = true
elseif fields.settings then elseif fields.settings then
if not data.show_settings then
data.confirm_trash = nil data.confirm_trash = nil
data.show_settings = true data.show_settings = true
else
data.show_settings = nil
end
elseif fields.confirm_trash_yes or fields.confirm_trash_no then elseif fields.confirm_trash_yes or fields.confirm_trash_no then
if fields.confirm_trash_yes then if fields.confirm_trash_yes then

View File

@ -452,9 +452,12 @@ local function show_popup(fs, data)
local show_sorting = data.show_setting == "sorting" local show_sorting = data.show_setting == "sorting"
local show_misc = data.show_setting == "misc" 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_home;textcolor=%s;font=bold;sound=i3_click]",
fs(fmt("style[setting_sorting;textcolor=%s;sound=i3_click]", show_sorting and colors.yellow or "#fff")) show_home 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_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", 2.2, 9.25, 1.8, 0.55, "setting_home", "Home")
fs("button", 4, 9.25, 1.8, 0.55, "setting_sorting", "Sorting") 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 elseif show_misc then
fs("checkbox", 2.4, 10.05, "cb_inv_compress", "Compression", tostring(data.inv_compress)) 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.5, "cb_reverse_sorting", "Reverse mode", tostring(data.reverse_sorting))
fs("checkbox", 2.4, 10.95, "cb_auto_sorting", "Automatic sorting", tostring(data.auto_sorting)) fs("checkbox", 2.4, 10.95, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar))
fs("checkbox", 5.4, 10.05, "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 for _ = 1, 3 do
fs("box", 5.4, 10.68, 2.4, 0.45, "#707070") fs("box", 5.4, 10.68, 2.4, 0.45, "#707070")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 7.7 KiB