mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-25 18:30:38 +01:00
Minor polish
This commit is contained in:
parent
f2248ae176
commit
e60f986484
2
API.md
2
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):
|
||||
|
||||
|
14
src/bags.lua
14
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
|
||||
|
||||
|
@ -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
|
||||
|
15
src/gui.lua
15
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")
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 570 B After Width: | Height: | Size: 7.7 KiB |
Loading…
Reference in New Issue
Block a user