mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 09:00:23 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
eac4a18df2 | |||
2ddaa4ddfb | |||
56b5cb78f2 | |||
813d27d2cc | |||
52464d4486 | |||
e300539dd3 | |||
2cdd03b127 | |||
8db3fb4a41 | |||
d3ad413876 |
3
init.lua
3
init.lua
@ -20,7 +20,7 @@ local function lf(path)
|
||||
end
|
||||
|
||||
i3 = {
|
||||
version = 190,
|
||||
version = 1100,
|
||||
data = core.deserialize(storage:get_string"data") or {},
|
||||
|
||||
settings = {
|
||||
@ -53,6 +53,7 @@ i3 = {
|
||||
bag = true,
|
||||
home = true,
|
||||
font_size = true,
|
||||
hide_tabs = true,
|
||||
waypoints = true,
|
||||
inv_items = true,
|
||||
known_recipes = true,
|
||||
|
@ -211,13 +211,13 @@ local function init_data(player, info)
|
||||
data.items = i3.init_items
|
||||
data.items_raw = i3.init_items
|
||||
data.favs = {}
|
||||
data.sort = "alphabetical"
|
||||
data.show_setting = "home"
|
||||
data.ignore_hotbar = false
|
||||
data.auto_sorting = false
|
||||
data.reverse_sorting = false
|
||||
data.inv_compress = true
|
||||
data.crafting_counts = {}
|
||||
data.sort = 1
|
||||
data.tab = 1
|
||||
data.itab = 1
|
||||
data.subcat = 1
|
||||
|
@ -443,10 +443,8 @@ local function craft_stack(player, data, craft_rcp)
|
||||
end
|
||||
|
||||
if rcp_def.replacements then
|
||||
for _, v in ipairs(rcp_def.replacements) do
|
||||
for _, item2 in ipairs(v) do
|
||||
get_stack(player, ItemStack(item2))
|
||||
end
|
||||
for _, pair in ipairs(rcp_def.replacements) do
|
||||
get_stack(player, ItemStack(pair[2]))
|
||||
end
|
||||
end
|
||||
|
||||
@ -479,18 +477,6 @@ local function safe_teleport(player, pos)
|
||||
player:set_pos(p)
|
||||
end
|
||||
|
||||
local function get_sorting_idx(name)
|
||||
local idx = 1
|
||||
|
||||
for i, def in ipairs(i3.sorting_methods) do
|
||||
if name == def.name then
|
||||
idx = i
|
||||
end
|
||||
end
|
||||
|
||||
return idx
|
||||
end
|
||||
|
||||
local function sorter(inv, data, mode)
|
||||
sort(inv, function(a, b)
|
||||
if mode == 1 then
|
||||
@ -579,8 +565,7 @@ local function sort_inventory(player, data)
|
||||
list = pre_sorting(list, start_i)
|
||||
end
|
||||
|
||||
local idx = get_sorting_idx(data.sort)
|
||||
local new_inv = i3.sorting_methods[idx].func(list, data)
|
||||
local new_inv = i3.sorting_methods[data.sort].func(list, data)
|
||||
if not new_inv then return end
|
||||
|
||||
if not data.ignore_hotbar then
|
||||
@ -676,7 +661,6 @@ local _ = {
|
||||
sorter = sorter,
|
||||
get_recipes = get_recipes,
|
||||
sort_inventory = sort_inventory,
|
||||
get_sorting_idx = get_sorting_idx,
|
||||
sort_by_category = sort_by_category,
|
||||
apply_recipe_filters = apply_recipe_filters,
|
||||
|
||||
|
@ -5,8 +5,8 @@ IMPORT("min", "max", "vec_eq", "vec_round")
|
||||
IMPORT("S", "random", "translate", "ItemStack")
|
||||
IMPORT("sort", "copy", "insert", "remove", "indexof")
|
||||
IMPORT("fmt", "find", "match", "sub", "lower", "split", "toupper")
|
||||
IMPORT("search", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv")
|
||||
IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "reset_data")
|
||||
IMPORT("search", "get_sorting_idx", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv")
|
||||
IMPORT("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
|
||||
|
||||
local function inv_fields(player, data, fields)
|
||||
@ -124,19 +124,8 @@ local function inv_fields(player, data, fields)
|
||||
elseif fields.sort then
|
||||
sort_inventory(player, data)
|
||||
|
||||
elseif fields.prev_sort or fields.next_sort then
|
||||
local idx = get_sorting_idx(data.sort)
|
||||
local tot = #i3.sorting_methods
|
||||
|
||||
idx -= (fields.prev_sort and 1 or -1)
|
||||
|
||||
if idx > tot then
|
||||
idx = 1
|
||||
elseif idx == 0 then
|
||||
idx = tot
|
||||
end
|
||||
|
||||
data.sort = i3.sorting_methods[idx].name
|
||||
elseif fields.dd_sorting_method then
|
||||
data.sort = tonumber(fields.dd_sorting_method)
|
||||
|
||||
elseif fields.home then
|
||||
if not data.home then
|
||||
@ -189,7 +178,7 @@ local function inv_fields(player, data, fields)
|
||||
for _, v in ipairs(data.waypoints) do
|
||||
if vec_eq(vec_round(pos), vec_round(str_to_pos(v.pos))) then
|
||||
play_sound(name, "i3_cannot", 0.8)
|
||||
return msg(name, S"You already set a waypoint at this position")
|
||||
return msg(name, S"You already have set a waypoint at this position")
|
||||
end
|
||||
end
|
||||
|
||||
@ -312,7 +301,7 @@ end
|
||||
local function rcp_fields(player, data, fields)
|
||||
local sb_rcp, sb_usg = fields.scrbar_rcp, fields.scrbar_usg
|
||||
|
||||
if fields.filter and fields.filter == "" then
|
||||
if not data.hide_tabs and fields.filter and fields.filter == "" then
|
||||
data.enable_search = nil
|
||||
end
|
||||
|
||||
@ -323,7 +312,11 @@ local function rcp_fields(player, data, fields)
|
||||
data.query_item = nil
|
||||
|
||||
elseif fields.enable_search then
|
||||
data.enable_search = true
|
||||
if data.hide_tabs then
|
||||
data.enable_search = not data.enable_search
|
||||
else
|
||||
data.enable_search = true
|
||||
end
|
||||
|
||||
elseif fields.filter and (fields.key_enter_field == "filter" or fields.search) then
|
||||
if fields.filter == "" then
|
||||
@ -436,14 +429,14 @@ core.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return false
|
||||
end
|
||||
|
||||
-- No-op buttons
|
||||
-- No-op buttons
|
||||
if fields.player_name or fields.awards or fields.home_pos or fields.no_item or
|
||||
fields.no_rcp or fields.select_sorting or fields.sort_method or fields.bg_content or
|
||||
fields.quick_crafting then
|
||||
return false
|
||||
end
|
||||
|
||||
--print(dump(fields))
|
||||
-- print(dump(fields))
|
||||
local data = i3.data[name]
|
||||
if not data then return end
|
||||
|
||||
|
295
src/gui.lua
295
src/gui.lua
@ -11,10 +11,10 @@ local VoxelArea, VoxelManip = VoxelArea, VoxelManip
|
||||
IMPORT("find", "match", "sub", "upper")
|
||||
IMPORT("vec_new", "vec_sub", "vec_round")
|
||||
IMPORT("clr", "ESC", "msg", "check_privs")
|
||||
IMPORT("compression_active", "compressible")
|
||||
IMPORT("min", "max", "floor", "ceil", "round")
|
||||
IMPORT("reg_items", "reg_tools", "reg_entities")
|
||||
IMPORT("true_str", "is_fav", "is_num", "str_to_pos")
|
||||
IMPORT("get_sorting_idx", "compression_active", "compressible")
|
||||
IMPORT("get_bag_description", "get_detached_inv", "get_recipes")
|
||||
IMPORT("S", "ES", "translate", "ItemStack", "toupper", "utf8_len")
|
||||
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
||||
@ -299,13 +299,13 @@ end
|
||||
|
||||
local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||
fs(fmt("box[0,%f;4.9,0.6;#bababa25]", yextra + 1.1))
|
||||
label(0, yextra + 0.85, ES"Waypoint name:")
|
||||
label(0, yextra + 0.85, ES"New waypoint" .. ":")
|
||||
fs(fmt("field[0.1,%f;4.8,0.6;waypoint_name;;]", yextra + 1.1))
|
||||
image_button(5.1, yextra + 1.15, 0.5, 0.5, "", "waypoint_add", "")
|
||||
fs(fmt("tooltip[waypoint_add;%s]", ES"Add waypoint"))
|
||||
|
||||
if #data.waypoints == 0 then return end
|
||||
fs("style_type[label;font=bold;font_size=17]")
|
||||
fs"style_type[label;font=bold;font_size=17]"
|
||||
|
||||
for i, v in ipairs(data.waypoints) do
|
||||
local y = yextra + 1.35 + (i - (i * 0.3))
|
||||
@ -572,45 +572,40 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||
end
|
||||
end
|
||||
|
||||
local function show_popup(fs, data)
|
||||
local function show_settings(fs, data)
|
||||
if data.confirm_trash then
|
||||
fs"style_type[box;colors=#999,#999,#808080,#808080]"
|
||||
|
||||
for _ = 1, 3 do
|
||||
box(2.97, 10.75, 4.3, 0.5, "")
|
||||
end
|
||||
|
||||
label(3.12, 11, "Confirm trash?")
|
||||
image_button(5.17, 10.75, 1, 0.5, "", "confirm_trash_yes", "Yes")
|
||||
image_button(6.27, 10.75, 1, 0.5, "", "confirm_trash_no", "No")
|
||||
image(2.8, 10.65, 4.6, 0.7, PNG.bg_goto)
|
||||
label(3.02, 11, "Confirm trash?")
|
||||
image_button(5.07, 10.75, 1, 0.5, "", "confirm_trash_yes", "Yes")
|
||||
image_button(6.17, 10.75, 1, 0.5, "", "confirm_trash_no", "No")
|
||||
|
||||
elseif data.show_settings then
|
||||
fs"style_type[box;colors=#999,#999,#808080,#808080]"
|
||||
|
||||
for _ = 1, 3 do
|
||||
box(2.1, 9.25, 6, 2, "")
|
||||
end
|
||||
|
||||
for _ = 1, 3 do
|
||||
box(2.1, 9.25, 6, 0.5, "#707070")
|
||||
end
|
||||
|
||||
image_button(7.75, 9.35, 0.25, 0.25, PNG.cancel_hover .. "^\\[brighten", "close_settings", "")
|
||||
image(2.2, 9, 6, 2.35, PNG.bg_content)
|
||||
|
||||
local show_home = data.show_setting == "home"
|
||||
local show_style = data.show_setting == "style"
|
||||
local show_sorting = data.show_setting == "sorting"
|
||||
local show_misc = data.show_setting == "misc"
|
||||
|
||||
fs(fmt("style[setting_home;textcolor=%s;font=bold;font_size=16;sound=i3_click]",
|
||||
show_home and colors.yellow or "#fff"),
|
||||
fmt("style[setting_sorting;textcolor=%s;font=bold;font_size=16;sound=i3_click]",
|
||||
show_sorting and colors.yellow or "#fff"),
|
||||
fmt("style[setting_misc;textcolor=%s;font=bold;font_size=16;sound=i3_click]",
|
||||
show_misc and colors.yellow or "#fff"))
|
||||
fs"style[setting_home,setting_style,setting_sorting;font=bold;font_size=16;sound=i3_click]"
|
||||
fs(fmt("style[setting_home:hovered;textcolor=%s]", show_home and colors.yellow or "#fff"))
|
||||
fs(fmt("style[setting_style:hovered;textcolor=%s]", show_style and colors.yellow or "#fff"))
|
||||
fs(fmt("style[setting_sorting:hovered;textcolor=%s]", show_sorting and colors.yellow or "#fff"))
|
||||
|
||||
button(2.2, 9.25, 1.8, 0.55, "setting_home", "Home")
|
||||
button(4, 9.25, 1.8, 0.55, "setting_sorting", "Sorting")
|
||||
button(5.8, 9.25, 1.8, 0.55, "setting_misc", "Misc.")
|
||||
fs(fmt("style[setting_home;bgimg=%s;bgimg_hovered=%s;bgimg_middle=9;padding=-9;textcolor=%s]",
|
||||
show_home and PNG.pagenum_hover or "", PNG.pagenum_hover,
|
||||
show_home and colors.yellow or "#ddd"),
|
||||
fmt("style[setting_style;bgimg=%s;bgimg_hovered=%s;bgimg_middle=9;padding=-9;textcolor=%s]",
|
||||
show_style and PNG.pagenum_hover or "", PNG.pagenum_hover,
|
||||
show_style and colors.yellow or "#ddd"),
|
||||
fmt("style[setting_sorting;bgimg=%s;bgimg_hovered=%s;bgimg_middle=9;padding=-9;textcolor=%s]",
|
||||
show_sorting and PNG.pagenum_hover or "", PNG.pagenum_hover,
|
||||
show_sorting and colors.yellow or "#ddd"))
|
||||
|
||||
local X = 2.5
|
||||
button(X, 9.1, 1.6, 0.55, "setting_home", "Home")
|
||||
button(X + 1.6, 9.1, 1.6, 0.55, "setting_style", "Style")
|
||||
button(X + 3.2, 9.1, 1.6, 0.55, "setting_sorting", "Sorting")
|
||||
image_button(X + 5, 9.2, 0.25, 0.25, PNG.cancel_hover .. "^\\[brighten", "close_settings", "")
|
||||
|
||||
if show_home then
|
||||
local coords, c, str = {"X", "Y", "Z"}, 0, ES"No home set"
|
||||
@ -620,41 +615,44 @@ local function show_popup(fs, data)
|
||||
"(%-?%d+)", function(a)
|
||||
c++
|
||||
return fmt("<b>%s: <style color=%s font=mono>%s</style></b>",
|
||||
coords[c], colors.black, a)
|
||||
coords[c], colors.blue, a)
|
||||
end)
|
||||
end
|
||||
|
||||
hypertext(2.1, 9.9, 6, 0.6, "home_pos", fmt("<global size=16><center>%s</center>", str))
|
||||
image_button(4.2, 10.4, 1.8, 0.7, "", "set_home", "Set home")
|
||||
|
||||
elseif show_sorting then
|
||||
button(2.1, 9.7, 6, 0.8, "select_sorting", ES"Select the inventory sorting method:")
|
||||
|
||||
image_button(2.2, 10.6, 0.35, 0.35, "", "prev_sort", "")
|
||||
image_button(7.65, 10.6, 0.35, 0.35, "", "next_sort", "")
|
||||
|
||||
fs"style[sort_method;font=bold;font_size=20]"
|
||||
button(2.55, 10.36, 5.1, 0.8, "sort_method", toupper(data.sort))
|
||||
|
||||
local idx = get_sorting_idx(data.sort)
|
||||
local desc = i3.sorting_methods[idx].description
|
||||
|
||||
if desc then
|
||||
fs(fmt("tooltip[%s;%s]", "sort_method", desc))
|
||||
end
|
||||
|
||||
elseif show_misc then
|
||||
checkbox(2.4, 10.05, "cb_inv_compress", "Compression", tostring(data.inv_compress))
|
||||
checkbox(2.4, 10.5, "cb_reverse_sorting", "Reverse mode", tostring(data.reverse_sorting))
|
||||
checkbox(2.4, 10.95, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar))
|
||||
checkbox(5.4, 10.05, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
||||
elseif show_style then
|
||||
checkbox(2.6, 9.95, "cb_hide_tabs", "Hide tabs", tostring(data.hide_tabs))
|
||||
|
||||
local sign = (data.font_size > 0 and "+") or (data.font_size > 0 and "-") or ""
|
||||
label(5.4, 10.55, ES"Font size" .. fmt(": %s", sign .. data.font_size))
|
||||
label(2.6, 10.45, ES"Font size" .. fmt(": %s", sign .. data.font_size))
|
||||
|
||||
local range = 5
|
||||
fs(fmt("scrollbaroptions[min=-%u;max=%u;smallstep=1;largestep=1;thumbsize=2]", range, range))
|
||||
fs(fmt("scrollbar[5.4,10.8;2.5,0.25;horizontal;sb_font_size;%d]", data.font_size))
|
||||
fs(fmt("scrollbar[2.6,10.65;2.5,0.3;horizontal;sb_font_size;%d]", data.font_size))
|
||||
|
||||
elseif show_sorting then
|
||||
checkbox(2.6, 9.95, "cb_inv_compress", "Compression", tostring(data.inv_compress))
|
||||
checkbox(2.6, 10.4, "cb_reverse_sorting", "Reverse mode", tostring(data.reverse_sorting))
|
||||
checkbox(2.6, 10.85, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar))
|
||||
checkbox(5.5, 9.95, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
||||
|
||||
local methods = {}
|
||||
|
||||
for _, v in ipairs(i3.sorting_methods) do
|
||||
local name = toupper(v.name)
|
||||
insert(methods, name)
|
||||
end
|
||||
|
||||
label(5.5, 10.4, ES"Sorting method:")
|
||||
fs(fmt("dropdown[%f,%f;2.3,0.5;dd_sorting_method;%s;%u;true]",
|
||||
5.5, 10.6, concat(methods, ","), data.sort))
|
||||
|
||||
local desc = i3.sorting_methods[data.sort].description
|
||||
if desc then
|
||||
tooltip(5.5, 10.6, 2.3, 0.5, ESC(desc))
|
||||
end
|
||||
|
||||
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
||||
ES"Enable this option to compress your inventory"),
|
||||
@ -687,7 +685,7 @@ local function get_inventory_fs(player, data, fs)
|
||||
|
||||
local textures = concat(t, ","):gsub("!", ",")
|
||||
|
||||
--fs("style[player_model;bgcolor=black]")
|
||||
-- fs"style[player_model;bgcolor=black]"
|
||||
model(0.2, 0.2, armor_skin and 4 or 3.4, ctn_hgt,
|
||||
"player_model", props.mesh, textures, "0,-150", "false", "false",
|
||||
fmt("%u,%u;30", anim.x, anim.y))
|
||||
@ -767,7 +765,7 @@ local function get_inventory_fs(player, data, fs)
|
||||
fs(fmt("tooltip[%s;%s]", btn_name, tooltip))
|
||||
end
|
||||
|
||||
show_popup(fs, data)
|
||||
show_settings(fs, data)
|
||||
end
|
||||
|
||||
local function get_tooltip(item, info, pos, lang_code)
|
||||
@ -1110,7 +1108,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
||||
end
|
||||
|
||||
if large_recipe then
|
||||
fs("style_type[item_image_button;border=false]")
|
||||
fs"style_type[item_image_button;border=false]"
|
||||
end
|
||||
|
||||
get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, right, btn_size, _btn_size)
|
||||
@ -1290,7 +1288,6 @@ local function get_crafting_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, ma
|
||||
button(x + 0.2, data.yoffset + 1.85, 2.5, 0.7, fmt("craft_%s", name), ES("Craft (×@1)", stack_fs))
|
||||
|
||||
fs"style_type[label;font_size=16;textcolor=#fff]"
|
||||
fs"style_type[image,button,image_button;noclip=false]"
|
||||
end
|
||||
|
||||
local function get_rcp_extra(fs, data, player, panel, is_recipe, is_usage)
|
||||
@ -1362,50 +1359,116 @@ local function hide_items(player, data)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_header_items_fs(fs, data)
|
||||
local X = data.inv_width
|
||||
fs"set_focus[filter;true]"
|
||||
|
||||
if data.hide_tabs then
|
||||
fs(fmt("style[enable_search;bgimg=%s;bgimg_hovered=%s;bgimg_pressed=%s]",
|
||||
data.enable_search and PNG.search_hover or PNG.search, PNG.search_hover, PNG.search_hover))
|
||||
image_button(X + 0.3, 0.2, 0.5, 0.5, "", "enable_search", "")
|
||||
fs(fmt("tooltip[enable_search;%s]", ES"Search"))
|
||||
|
||||
if data.enable_search then
|
||||
image(X + 0.4, 0.75, 3.4, 0.8, PNG.bg_goto)
|
||||
|
||||
fs("style[filter;font_size=16]",
|
||||
fmt("field[%f,%f;3,0.45;filter;;%s]", X + 0.6, 0.95, data.filter),
|
||||
"field_close_on_enter[filter;false]")
|
||||
end
|
||||
|
||||
box(X + 1, 0.2, 0.01, 0.5, "#bababa50")
|
||||
local cat = {{"all", "all items"}, {"node", "nodes only"}, {"item", "items only"}}
|
||||
|
||||
for i in ipairs(cat) do
|
||||
local name, desc = unpack(cat[i])
|
||||
local active = PNG[name .. "_hover"]
|
||||
|
||||
fs(fmt("style[itab_%u;bgimg=%s;bgimg_hovered=%s;bgimg_pressed=%s;sound=i3_tab]",
|
||||
i, data.itab == i and active or PNG[name], active, active))
|
||||
image_button(X + 1.25 + ((i - 1) * 0.7), 0.2, 0.5, 0.5, "", fmt("itab_%s", i), "")
|
||||
fs(fmt("tooltip[itab_%u;Show %s]", i, desc))
|
||||
end
|
||||
else
|
||||
fs(fmt("style[search;bgimg=%s]", PNG.search_hover))
|
||||
image_button(X + 0.35, 0.32, 0.35, 0.35, "", "search", "")
|
||||
fs(fmt("tooltip[search;%s]", ES"Search"))
|
||||
|
||||
if data.enable_search then
|
||||
fs("style[filter;font_size=18]",
|
||||
fmt("field[%f,0.2;3.35,0.6;filter;;%s]", X + 0.85, ESC(data.filter)),
|
||||
"field_close_on_enter[filter;false]")
|
||||
|
||||
if not true_str(data.filter) then
|
||||
image(X + 0.85, 0.75, 4, 0.01, PNG.search_outline_trim .. "^[opacity:100")
|
||||
end
|
||||
else
|
||||
fs"style_type[label;font=italic;font_size=18]"
|
||||
label(X + 0.9, 0.49, clr("#aaa", ES"Search..."))
|
||||
button(X + 0.8, 0.12, 4, 0.8, "enable_search", "")
|
||||
fs"style_type[label;font=normal;font_size=16]"
|
||||
end
|
||||
|
||||
if true_str(data.filter) then
|
||||
image_button(X + 4.3, 0.4, 0.2, 0.2, "", "cancel", "")
|
||||
fs(fmt("tooltip[cancel;%s]", ES"Clear"))
|
||||
box(X + 0.85, 0.75, 3.74, 0.01, "#f9826c")
|
||||
end
|
||||
end
|
||||
|
||||
image_button(X + 5.27, 0.3, 0.35, 0.35, "", "prev_page", "")
|
||||
image_button(X + 7.45, 0.3, 0.35, 0.35, "", "next_page", "")
|
||||
|
||||
fs(fmt("style[pagenum;bgimg=%s;bgimg_hovered=%s;bgimg_middle=9;padding=-9;sound=i3_click]",
|
||||
data.goto_page and PNG.pagenum_hover or "", PNG.pagenum_hover))
|
||||
|
||||
button(X + 5.8, 0.14, 1.48, 0.7, "pagenum",
|
||||
fmt("%s / %u", clr(colors.yellow, data.pagenum), data.pagemax))
|
||||
|
||||
if data.goto_page then
|
||||
image(X + 4.8, 0.85, 2.9, 0.8, PNG.bg_goto)
|
||||
fs"style_type[label;font_size=16;textcolor=#ddd]"
|
||||
label(X + 5, 1.25, ES"Go to page" .. ":")
|
||||
box(X + 6.5, 1, 1, 0.45, "#bababa10")
|
||||
|
||||
fs(fmt("style[goto_page;font=mono,bold;font_size=16;textcolor=%s]", colors.yellow),
|
||||
fmt("field[%f,%f;1,0.45;goto_page;;%s]", X + 6.55, 1.05, data.pagenum),
|
||||
"field_close_on_enter[goto_page;false]")
|
||||
|
||||
fs"style_type[label;font_size=16;textcolor=#fff]"
|
||||
end
|
||||
end
|
||||
|
||||
local function get_minitabs(fs, data, full_height)
|
||||
local _tabs = {"All", "Nodes", "Items"}
|
||||
local tab_len, tab_hgh = 1.8, 0.5
|
||||
|
||||
for i, title in ipairs(_tabs) do
|
||||
local selected = i == data.itab
|
||||
local hover_texture = selected and PNG.tab_small_hover or PNG.tab_small
|
||||
|
||||
fs(fmt([[style_type[image_button;bgimg=%s;bgimg_hovered=%s;
|
||||
bgimg_middle=14,0,-14,-14;padding=-14,0,14,14] ]], hover_texture, PNG.tab_small_hover))
|
||||
|
||||
fs(fmt([[style_type[image_button;noclip=true;font=bold;font_size=16;
|
||||
textcolor=%s;content_offset=0;sound=i3_tab] ]], selected and "#fff" or "#bbb"))
|
||||
fs"style_type[image_button:hovered;textcolor=#fff]"
|
||||
image_button((data.inv_width - 0.65) + (i * (tab_len + 0.1)),
|
||||
full_height, tab_len, tab_hgh, "", fmt("itab_%u", i), title)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_items_fs(fs, data, player, full_height)
|
||||
hide_items(player, data)
|
||||
bg9(data.inv_width + 0.1, 0, 7.9, full_height, PNG.bg_full)
|
||||
|
||||
local items = data.alt_items or data.items or {}
|
||||
local rows, lines = 8, 12
|
||||
local ipp = rows * lines
|
||||
local size = 0.85
|
||||
|
||||
bg9(data.inv_width + 0.1, 0, 7.9, full_height, PNG.bg_full)
|
||||
|
||||
if data.enable_search then
|
||||
fs("set_focus[filter]",
|
||||
"style[filter;font_size=18;textcolor=#ccc]",
|
||||
fmt("field[%f,0.2;3.35,0.6;filter;;%s]", data.inv_width + 0.85, ESC(data.filter)),
|
||||
"field_close_on_enter[filter;false]")
|
||||
|
||||
image(data.inv_width + 0.85, 0.75, 4, 0.01, PNG.search_outline_trim .. "^[opacity:100")
|
||||
else
|
||||
fs"style_type[label;font=italic;font_size=18]"
|
||||
label(data.inv_width + 0.9, 0.49, clr("#aaa", ES"Search..."))
|
||||
button(data.inv_width + 0.8, 0.12, 4, 0.8, "enable_search", "")
|
||||
end
|
||||
|
||||
image_button(data.inv_width + 0.35, 0.32, 0.35, 0.35, "", "search", "")
|
||||
image_button(data.inv_width + 5.27, 0.3, 0.35, 0.35, "", "prev_page", "")
|
||||
image_button(data.inv_width + 7.45, 0.3, 0.35, 0.35, "", "next_page", "")
|
||||
|
||||
fs(fmt("tooltip[search;%s]", ES"Search"))
|
||||
|
||||
if true_str(data.filter) then
|
||||
image_button(data.inv_width + 4.3, 0.4, 0.2, 0.2, "", "cancel", "")
|
||||
fs(fmt("tooltip[cancel;%s]", ES"Clear"))
|
||||
box(data.inv_width + 0.85, 0.75, 3.74, 0.01, "#f9826c")
|
||||
end
|
||||
|
||||
data.pagemax = max(1, ceil(#items / ipp))
|
||||
|
||||
|
||||
fs(fmt("style[pagenum;bgimg=%s;bgimg_hovered=%s;bgimg_middle=9;padding=-9]",
|
||||
data.goto_page and PNG.pagenum_hover or "", PNG.pagenum_hover))
|
||||
|
||||
button(data.inv_width + 5.8, 0.14, 1.48, 0.7, "pagenum",
|
||||
fmt("%s / %u", clr(colors.yellow, data.pagenum), data.pagemax))
|
||||
|
||||
if #items == 0 then
|
||||
local lbl = ES"No item to show"
|
||||
local icon, width, offset = PNG.no_result, 4, 2
|
||||
@ -1446,35 +1509,7 @@ local function get_items_fs(fs, data, player, full_height)
|
||||
end
|
||||
end
|
||||
|
||||
if data.goto_page then
|
||||
image(data.inv_width + 4.8, 0.85, 2.9, 0.8, PNG.bg_goto)
|
||||
fs"style_type[label;font_size=16;textcolor=#ddd]"
|
||||
label(data.inv_width + 5, 1.25, ES"Go to page" .. ":")
|
||||
box(data.inv_width + 6.5, 1, 1, 0.45, "#bababa10")
|
||||
|
||||
fs(fmt("style[goto_page;font=mono,bold;font_size=16;textcolor=%s]", colors.yellow),
|
||||
fmt("field[%f,%f;1,0.45;goto_page;;%s]", data.inv_width + 6.55, 1.05, data.pagenum),
|
||||
"field_close_on_enter[goto_page;false]")
|
||||
|
||||
fs"style_type[label;font_size=16;textcolor=#fff]"
|
||||
end
|
||||
|
||||
local _tabs = {"All", "Nodes", "Items"}
|
||||
local tab_len, tab_hgh = 1.8, 0.5
|
||||
|
||||
for i, title in ipairs(_tabs) do
|
||||
local selected = i == data.itab
|
||||
local hover_texture = selected and PNG.tab_small_hover or PNG.tab_small
|
||||
|
||||
fs(fmt([[style_type[image_button;bgimg=%s;bgimg_hovered=%s;
|
||||
bgimg_middle=14,0,-14,-14;padding=-14,0,14,14] ]], hover_texture, PNG.tab_small_hover))
|
||||
|
||||
fs(fmt("style_type[image_button;noclip=true;font_size=16;textcolor=%s;content_offset=0;sound=i3_tab]",
|
||||
selected and "#fff" or "#bbb"))
|
||||
fs"style_type[image_button:hovered;textcolor=#fff]"
|
||||
image_button((data.inv_width - 0.65) + (i * (tab_len + 0.1)),
|
||||
full_height, tab_len, tab_hgh, "", fmt("itab_%u", i), title)
|
||||
end
|
||||
get_header_items_fs(fs, data)
|
||||
end
|
||||
|
||||
local function get_favs(fs, data)
|
||||
@ -1543,7 +1578,7 @@ local function get_tabs_fs(fs, player, data, full_height)
|
||||
(btm and PNG.tab or PNG.tab_top)
|
||||
local bgimg_hover = btm and PNG.tab_hover or PNG.tab_hover_top
|
||||
|
||||
local middle = btm and "16,0,-16,-16" or "16,0,-16,0"
|
||||
local middle = btm and "16,0,-16,-16" or "16,16,-16,-16"
|
||||
local padding = btm and "-16,0,16,16" or "-16,-16,16,16"
|
||||
|
||||
fs(fmt([[style_type[image_button;bgimg=%s;bgimg_hovered=%s;bgimg_middle=%s;padding=%s] ]],
|
||||
@ -1562,7 +1597,7 @@ local function get_tabs_fs(fs, player, data, full_height)
|
||||
local desc = translate(data.lang_code, def.description)
|
||||
local desc_len = utf8_len(desc) + data.font_size
|
||||
|
||||
fs("style_type[image;noclip=true]")
|
||||
fs"style_type[image;noclip=true]"
|
||||
image(X + (tab_len / 2) - ((desc_len * 0.1) / 2) - 0.55, Y + 0.05, 0.35, 0.35, def.image)
|
||||
end
|
||||
|
||||
@ -1575,7 +1610,7 @@ local function get_debug_grid(data, fs, full_height)
|
||||
button(-2, full_height - 1, 2, 1, "hide_debug_grid", "Toggle grid")
|
||||
if data.hide_debug_grid then return end
|
||||
|
||||
fs("style_type[label;font_size=8;noclip=true]")
|
||||
fs"style_type[label;font_size=8;noclip=true]"
|
||||
local spacing, i = 0.2, 1
|
||||
|
||||
for x = 0, data.inv_width + 8, spacing do
|
||||
@ -1631,6 +1666,10 @@ local function make_fs(player, data)
|
||||
get_panels(fs, data, player)
|
||||
else
|
||||
get_items_fs(fs, data, player, full_height)
|
||||
|
||||
if not data.hide_tabs then
|
||||
get_minitabs(fs, data, full_height)
|
||||
end
|
||||
end
|
||||
|
||||
local visible_tabs = #i3.tabs
|
||||
|
@ -51,6 +51,9 @@ local PNG = {
|
||||
find_more = "i3_find_more.png",
|
||||
search_outline = "i3_search_outline.png",
|
||||
search_outline_trim = "i3_search_outline_trim.png",
|
||||
all = "i3_all.png",
|
||||
node = "i3_node.png",
|
||||
item = "i3_item.png",
|
||||
|
||||
cancel_hover = "i3_cancel.png^\\[brighten",
|
||||
search_hover = "i3_search.png^\\[brighten",
|
||||
@ -74,6 +77,9 @@ local PNG = {
|
||||
exit_hover = "i3_exit.png^\\[brighten",
|
||||
home_hover = "i3_home.png^\\[brighten",
|
||||
edit_hover = "i3_edit.png^\\[brighten",
|
||||
all_hover = "i3_all_on.png^\\[brighten",
|
||||
node_hover = "i3_node_on.png^\\[brighten",
|
||||
item_hover = "i3_item_on.png^\\[brighten",
|
||||
}
|
||||
|
||||
local styles = string.format([[
|
||||
@ -86,8 +92,8 @@ local styles = string.format([[
|
||||
|
||||
style[;sound=]
|
||||
style[nofav;sound=i3_cannot]
|
||||
style[search;content_offset=0]
|
||||
style[pagenum,no_item,no_rcp;font=bold;font_size=18]
|
||||
style[search;fgimg=%s;content_offset=0]
|
||||
style[enable_search:hovered;bgimg=%s]
|
||||
style[enable_search:pressed;bgimg=%s^[opacity:178]
|
||||
style[exit;fgimg=%s;fgimg_hovered=%s;content_offset=0]
|
||||
@ -106,14 +112,13 @@ local styles = string.format([[
|
||||
style[confirm_trash_yes;sound=i3_trash]
|
||||
]],
|
||||
PNG.slot,
|
||||
PNG.search_hover,
|
||||
PNG.search_outline, PNG.search_outline,
|
||||
PNG.exit, PNG.exit_hover,
|
||||
PNG.cancel, PNG.cancel_hover,
|
||||
PNG.prev, PNG.prev_hover,
|
||||
PNG.next, PNG.next_hover,
|
||||
PNG.add, PNG.add_hover,
|
||||
PNG.edit, PNG.edit_hover)
|
||||
PNG.exit, PNG.exit_hover,
|
||||
PNG.cancel, PNG.cancel_hover,
|
||||
PNG.prev, PNG.prev_hover,
|
||||
PNG.next, PNG.next_hover,
|
||||
PNG.add, PNG.add_hover,
|
||||
PNG.edit, PNG.edit_hover)
|
||||
|
||||
local fs_elements = {
|
||||
label = "label[%f,%f;%s]",
|
||||
|
BIN
textures/i3_all.png
Normal file
BIN
textures/i3_all.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
textures/i3_all_on.png
Normal file
BIN
textures/i3_all_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
textures/i3_item.png
Normal file
BIN
textures/i3_item.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
textures/i3_item_on.png
Normal file
BIN
textures/i3_item_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
textures/i3_node.png
Normal file
BIN
textures/i3_node.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
textures/i3_node_on.png
Normal file
BIN
textures/i3_node_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user