mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 00:50:22 +02:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
aa10460886 | |||
cef11f5301 | |||
2297b47dc0 | |||
a67ef8b08b | |||
48ab26b4c6 | |||
1389027a22 | |||
629676a975 | |||
20b8110375 | |||
a3fea93a09 | |||
326ee3e098 | |||
60bdfa34fb | |||
9971b8c3e6 | |||
5a14116b69 | |||
222e04d2c4 | |||
8f4c9f28f1 | |||
37e0c21ca3 |
@ -7,7 +7,7 @@
|
||||
This mod features a modern, powerful inventory menu with a good user experience.
|
||||
**`i3`** provides a rich [**API**](https://github.com/minetest-mods/i3/blob/master/API.md) for mod developers who want to extend it.
|
||||
|
||||
This mod requires **Minetest 5.4+**
|
||||
This mod requires **Minetest 5.6+**
|
||||
|
||||
#### List of features:
|
||||
- Crafting Guide (survival mode only)
|
||||
@ -43,6 +43,8 @@ To use this mod in the best conditions:
|
||||
If the inventory's font size is too big on certain setups (namely Windows 10/11 or 144 DPI display), you should lower the
|
||||
value of the setting `display_density_factor` in your `minetest.conf`. Note that the change is applied after restart.
|
||||
|
||||
You can also use the font size slider in the inventory, settings window.
|
||||
|
||||
#### Notes
|
||||
|
||||
`i3` uses a larger inventory than the usual inventories in Minetest games.
|
||||
|
6
init.lua
6
init.lua
@ -20,14 +20,14 @@ local function lf(path)
|
||||
end
|
||||
|
||||
i3 = {
|
||||
version = 174,
|
||||
version = 180,
|
||||
data = core.deserialize(storage:get_string"data") or {},
|
||||
|
||||
settings = {
|
||||
debug_mode = false,
|
||||
max_favs = 6,
|
||||
max_waypoints = 30,
|
||||
min_fs_version = 4,
|
||||
min_fs_version = 6,
|
||||
item_btn_size = 1.1,
|
||||
drop_bag_on_die = true,
|
||||
save_interval = 600, -- Player data save interval (in seconds)
|
||||
@ -52,9 +52,9 @@ i3 = {
|
||||
saves = { -- Metadata to save
|
||||
bag = true,
|
||||
home = true,
|
||||
font_size = true,
|
||||
waypoints = true,
|
||||
inv_items = true,
|
||||
drop_items = true,
|
||||
known_recipes = true,
|
||||
},
|
||||
|
||||
|
@ -344,7 +344,7 @@ end
|
||||
i3.add_sorting_method("alphabetical", {
|
||||
description = S"Sort items by name (A-Z)",
|
||||
func = function(list, data)
|
||||
sorter(list, data.reverse_sorting, 1)
|
||||
sorter(list, data, 1)
|
||||
return list
|
||||
end
|
||||
})
|
||||
@ -352,7 +352,7 @@ i3.add_sorting_method("alphabetical", {
|
||||
i3.add_sorting_method("numerical", {
|
||||
description = S"Sort items by number of items per stack",
|
||||
func = function(list, data)
|
||||
sorter(list, data.reverse_sorting, 2)
|
||||
sorter(list, data, 2)
|
||||
return list
|
||||
end,
|
||||
})
|
||||
|
@ -149,6 +149,7 @@ local function init_data(player, info)
|
||||
data.itab = 1
|
||||
data.subcat = 1
|
||||
data.scrbar_inv = 0
|
||||
data.font_size = data.font_size or 0
|
||||
data.lang_code = get_lang_code(info)
|
||||
data.fs_version = info.formspec_version
|
||||
|
||||
|
@ -80,7 +80,7 @@ end
|
||||
local function utf8_len(str)
|
||||
local c = 0
|
||||
|
||||
for _ in str:gmatch"([%z\1-\127\194-\244][\128-\191]*)" do -- Arguably working duct-tape code
|
||||
for _ in str:gmatch"[%z\1-\127\194-\244][\128-\191]*" do -- Arguably working duct-tape code
|
||||
c++
|
||||
end
|
||||
|
||||
@ -482,15 +482,16 @@ local function get_sorting_idx(name)
|
||||
return idx
|
||||
end
|
||||
|
||||
local function sorter(inv, reverse, mode)
|
||||
local function sorter(inv, data, mode)
|
||||
sort(inv, function(a, b)
|
||||
if mode == 1 then
|
||||
a, b = a:get_name(), b:get_name()
|
||||
a = translate(data.lang_code, a:get_short_description())
|
||||
b = translate(data.lang_code, b:get_short_description())
|
||||
else
|
||||
a, b = a:get_count(), b:get_count()
|
||||
end
|
||||
|
||||
if reverse then
|
||||
if data.reverse_sorting then
|
||||
return a > b
|
||||
end
|
||||
|
||||
@ -557,35 +558,12 @@ local function compress_items(list, start_i)
|
||||
return new_inv
|
||||
end
|
||||
|
||||
local function drop_items(player, inv, list, start_i, rej, remove)
|
||||
for i = start_i, #list do
|
||||
local stack = list[i]
|
||||
local name = stack:get_name()
|
||||
|
||||
for _, it in ipairs(rej) do
|
||||
if name == it then
|
||||
if not remove then
|
||||
spawn_item(player, stack)
|
||||
end
|
||||
|
||||
inv:set_stack("main", i, ItemStack(""))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return inv:get_list"main"
|
||||
end
|
||||
|
||||
local function sort_inventory(player, data)
|
||||
local inv = player:get_inventory()
|
||||
local list = inv:get_list"main"
|
||||
local size = inv:get_size"main"
|
||||
local start_i = data.ignore_hotbar and (i3.settings.hotbar_len + 1) or 1
|
||||
|
||||
if true_table(data.drop_items) then
|
||||
list = drop_items(player, inv, list, start_i, data.drop_items, true)
|
||||
end
|
||||
|
||||
if data.inv_compress then
|
||||
list = compress_items(list, start_i)
|
||||
else
|
||||
|
@ -19,11 +19,6 @@ local function inv_fields(player, data, fields)
|
||||
return
|
||||
end
|
||||
|
||||
if fields.drop_items then
|
||||
local items = split(fields.drop_items, ",")
|
||||
data.drop_items = items
|
||||
end
|
||||
|
||||
for field in pairs(fields) do
|
||||
if sub(field, 1, 4) == "btn_" then
|
||||
data.subcat = indexof(i3.categories, sub(field, 5))
|
||||
@ -158,6 +153,9 @@ local function inv_fields(player, data, fields)
|
||||
elseif fields.bag_rename then
|
||||
data.bag_rename = true
|
||||
|
||||
elseif fields.sb_font_size then
|
||||
data.font_size = tonumber(fields.sb_font_size:match"-?%d+$")
|
||||
|
||||
elseif fields.confirm_rename then
|
||||
local bag = get_detached_inv("bag", name)
|
||||
local bagstack = bag:get_stack("main", 1)
|
||||
|
163
src/gui.lua
163
src/gui.lua
@ -37,25 +37,29 @@ local function weird_desc(str)
|
||||
return not true_str(str) or find(str, "\n") or not find(str, "%u")
|
||||
end
|
||||
|
||||
local function snip(str, limit)
|
||||
return fmt("%s...", sub(str, 1, limit - 3))
|
||||
local function snip(str, limit, font_size)
|
||||
limit -= (font_size > 3 and font_size + 1 or font_size)
|
||||
|
||||
if utf8_len(str) > limit then
|
||||
return fmt("%s...", sub(str, 1, limit - 3))
|
||||
end
|
||||
end
|
||||
|
||||
local function get_desc(item)
|
||||
local function get_desc(item, lang_code)
|
||||
if sub(item, 1, 1) == "_" then
|
||||
item = sub(item, 2)
|
||||
end
|
||||
|
||||
local def = reg_items[item]
|
||||
|
||||
if not def then
|
||||
return S("Unknown Item (@1)", item)
|
||||
end
|
||||
|
||||
local desc = def.description
|
||||
local desc = ItemStack(item):get_short_description()
|
||||
desc = translate(lang_code, desc)
|
||||
|
||||
if true_str(desc) then
|
||||
desc = desc:trim():match("[^\n]*"):gsub("_", " ")
|
||||
desc = desc:trim():gsub("_", " ")
|
||||
|
||||
if not find(desc, "%u") then
|
||||
desc = toupper(desc)
|
||||
@ -171,17 +175,11 @@ local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlo
|
||||
title = translate(data.lang_code, title)
|
||||
desc = translate(data.lang_code, desc):gsub("%.$", "")
|
||||
|
||||
local title_lim, _title = 27
|
||||
local desc_lim, _desc = 39
|
||||
local title_lim, desc_lim = 27, 39
|
||||
local icon_size = 1.1
|
||||
|
||||
if utf8_len(title) > title_lim then
|
||||
_title = snip(title, title_lim)
|
||||
end
|
||||
|
||||
if utf8_len(desc) > desc_lim then
|
||||
_desc = snip(desc, desc_lim)
|
||||
end
|
||||
local _title = snip(title, title_lim, data.font_size) or title
|
||||
local _desc = snip(desc, desc_lim, data.font_size) or desc
|
||||
|
||||
if not award.unlocked and def.secret then
|
||||
title = ES"Secret award"
|
||||
@ -191,7 +189,7 @@ local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlo
|
||||
local icon = def.icon or "awards_unknown.png"
|
||||
|
||||
if not award.unlocked then
|
||||
icon = fmt("%s^\\[colorize:#000:200", icon)
|
||||
icon = fmt("%s^\\[colorize:#000:220", icon)
|
||||
end
|
||||
|
||||
insert(fs, fmt("image", 0, y, icon_size, icon_size, icon))
|
||||
@ -316,11 +314,8 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||
fs"style_type[box;colors=#bababa30,#bababa30,#bababa05,#bababa05]"
|
||||
box(0, y, ctn_len, 0.6, "")
|
||||
|
||||
local waypoint_name, lim = v.name, 18
|
||||
|
||||
if utf8_len(v.name) > lim then
|
||||
waypoint_name = snip(waypoint_name, lim)
|
||||
end
|
||||
local waypoint_name, lim = v.name, 22
|
||||
waypoint_name = snip(waypoint_name, lim, data.font_size) or waypoint_name
|
||||
|
||||
local hex = fmt("%02x", v.color)
|
||||
|
||||
@ -370,9 +365,9 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||
|
||||
if waypoint_preview then
|
||||
image(0.25, y - 3.5, 5, 4, PNG.bg_content)
|
||||
fs"style[area_preview;font_size=16]"
|
||||
button(0.25, y - 3.35, 5, 0.55, "area_preview", v.name)
|
||||
image_button(4.65, y - 3.25, 0.25, 0.25,
|
||||
PNG.cancel_hover .. "^\\[brighten", "close_preview", "")
|
||||
image_button(4.65, y - 3.25, 0.25, 0.25, PNG.cancel_hover .. "^\\[brighten", "close_preview", "")
|
||||
|
||||
local pos = str_to_pos(data.waypoints[i].pos)
|
||||
get_isometric_view(fs, pos, 0.6, y - 2.5)
|
||||
@ -576,11 +571,11 @@ 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;font=bold;sound=i3_click]",
|
||||
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;sound=i3_click]",
|
||||
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;sound=i3_click]",
|
||||
fmt("style[setting_misc;textcolor=%s;font=bold;font_size=16;sound=i3_click]",
|
||||
show_misc and colors.yellow or "#fff"))
|
||||
|
||||
button(2.2, 9.25, 1.8, 0.55, "setting_home", "Home")
|
||||
@ -624,14 +619,12 @@ local function show_popup(fs, data)
|
||||
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))
|
||||
|
||||
for _ = 1, 3 do
|
||||
box(5.4, 10.68, 2.4, 0.45, "#707070")
|
||||
end
|
||||
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))
|
||||
|
||||
fs("style[drop_items;font_size=15;font=mono;textcolor=#dbeeff]",
|
||||
fmt("field[5.4,10.68;2.4,0.45;drop_items;Remove items:;%s]",
|
||||
ESC(concat(data.drop_items or {}, ","))),
|
||||
"field_close_on_enter[drop_items;false]")
|
||||
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("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
||||
ES"Enable this option to compress your inventory"),
|
||||
@ -640,10 +633,7 @@ local function show_popup(fs, data)
|
||||
fmt("tooltip[cb_ignore_hotbar;%s;#707070;#fff]",
|
||||
ES"Enable this option to sort your inventory except the hotbar slots"),
|
||||
fmt("tooltip[cb_auto_sorting;%s;#707070;#fff]",
|
||||
ES"Enable this option to sort your inventory automatically"),
|
||||
fmt("tooltip[drop_items;%s;#707070;#fff]",
|
||||
"Add a comma-separated list of items to remove on inventory sorting.\n" ..
|
||||
"Format: " .. ("mod:item,mod:item, ..."):gsub("(%a+:%a+)", clr("#bddeff", "%1"))))
|
||||
ES"Enable this option to sort your inventory automatically"))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -670,7 +660,7 @@ local function get_inventory_fs(player, data, fs)
|
||||
--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%s", anim.x, anim.y, data.fs_version >= 5 and ";30" or ""))
|
||||
fmt("%u,%u;30", anim.x, anim.y))
|
||||
else
|
||||
local size = 2.5
|
||||
image(0.7, 0.2, size, size * props.visual_size.y, props.textures[1])
|
||||
@ -750,7 +740,7 @@ local function get_inventory_fs(player, data, fs)
|
||||
show_popup(fs, data)
|
||||
end
|
||||
|
||||
local function get_tooltip(item, info, pos)
|
||||
local function get_tooltip(item, info, pos, lang_code)
|
||||
local tooltip
|
||||
|
||||
if info.groups then
|
||||
@ -768,7 +758,7 @@ local function get_tooltip(item, info, pos)
|
||||
tooltip = S("Any item belonging to the groups: @1", groupstr)
|
||||
end
|
||||
else
|
||||
tooltip = info.meta_desc or get_desc(item)
|
||||
tooltip = info.meta_desc or get_desc(item, lang_code)
|
||||
end
|
||||
|
||||
local function add(str)
|
||||
@ -786,7 +776,7 @@ local function get_tooltip(item, info, pos)
|
||||
if info.replace then
|
||||
for i = 1, #info.replace.items do
|
||||
local rpl = ItemStack(info.replace.items[i]):get_name()
|
||||
local desc = clr("#ff0", get_desc(rpl))
|
||||
local desc = clr("#ff0", get_desc(rpl, lang_code))
|
||||
|
||||
if info.replace.type == "cooking" then
|
||||
tooltip = add(S("Replaced by @1 on smelting", desc))
|
||||
@ -813,12 +803,13 @@ local function get_tooltip(item, info, pos)
|
||||
|
||||
if several then
|
||||
for i = 1, #info.tools do
|
||||
names = fmt("%s\t\t- %s\n", names, clr("#ff0", get_desc(info.tools[i])))
|
||||
names = fmt("%s\t\t- %s\n", names, clr("#ff0", get_desc(info.tools[i], lang_code)))
|
||||
end
|
||||
|
||||
tooltip = add(S("Only drop if using one of these tools: @1", sub(names, 1, -2)))
|
||||
else
|
||||
tooltip = add(S("Only drop if using this tool: @1", clr("#ff0", get_desc(info.tools[1]))))
|
||||
tooltip = add(S("Only drop if using this tool: @1",
|
||||
clr("#ff0", get_desc(info.tools[1], lang_code))))
|
||||
end
|
||||
end
|
||||
|
||||
@ -883,7 +874,6 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
|
||||
local name = item:get_name()
|
||||
local count = item:get_count()
|
||||
local wear = item:get_wear()
|
||||
local bt_s = BTN_SIZE * 1.2
|
||||
local _name = fmt("_%s", name)
|
||||
local pos
|
||||
|
||||
@ -899,11 +889,11 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
|
||||
inv:set_stack("main", 1, item)
|
||||
pos = {x = X + 0.11, y = Y}
|
||||
else
|
||||
image(X, Y - 0.11, bt_s, bt_s, PNG.slot)
|
||||
item_image_button(
|
||||
X + 0.11, Y, BTN_SIZE, BTN_SIZE,
|
||||
fmt("%s %u %u", name, count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1), wear),
|
||||
_name, "")
|
||||
local size = BTN_SIZE * 1.2
|
||||
slot(X, Y - 0.11, size, size)
|
||||
|
||||
count *= (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)
|
||||
item_image_button(X + 0.11, Y, BTN_SIZE, BTN_SIZE, fmt("%s %u %u", name, count, wear), _name, "")
|
||||
end
|
||||
|
||||
local def = reg_items[name]
|
||||
@ -927,7 +917,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
|
||||
}
|
||||
|
||||
if next(infos) then
|
||||
fs(get_tooltip(_name, infos, pos))
|
||||
fs(get_tooltip(_name, infos, pos, data.lang_code))
|
||||
end
|
||||
end
|
||||
|
||||
@ -1026,11 +1016,11 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||
end
|
||||
|
||||
if not large_recipe then
|
||||
image(X, Y, btn_size, btn_size, PNG.slot)
|
||||
slot(X, Y, btn_size, btn_size)
|
||||
end
|
||||
|
||||
local btn_name = groups and fmt("group!%s!%s", groups[1], name) or name
|
||||
local _count = count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)
|
||||
count *= (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)
|
||||
|
||||
if group_cache and group_cache.sprite and not large_recipe then
|
||||
local sprite = ESC(group_cache.sprite)
|
||||
@ -1040,11 +1030,11 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||
animated_image(X + 0.01, Y + 0.025, size, size, sprite, group_cache.count, 1500)
|
||||
label(X + 0.45, Y + 0.18, label)
|
||||
|
||||
if _count > 1 then
|
||||
label(X + 0.8, Y + 0.9, _count)
|
||||
if count > 1 then
|
||||
label(X + 0.8, Y + 0.9, count)
|
||||
end
|
||||
else
|
||||
item_image_button(X, Y, btn_size, btn_size, fmt("%s %u", name, _count), btn_name, label)
|
||||
item_image_button(X, Y, btn_size, btn_size, fmt("%s %u", name, count), btn_name, label)
|
||||
end
|
||||
|
||||
local def = reg_items[name]
|
||||
@ -1069,7 +1059,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||
}
|
||||
|
||||
if next(infos) then
|
||||
fs(get_tooltip(btn_name, infos))
|
||||
fs(get_tooltip(btn_name, infos, nil, data.lang_code))
|
||||
end
|
||||
end
|
||||
|
||||
@ -1182,27 +1172,27 @@ local function get_header(fs, data)
|
||||
fs(fmt("tooltip[exit;%s]", ES"Back to item list"))
|
||||
|
||||
local desc_lim, name_lim = 34, 35
|
||||
local desc = translate(data.lang_code, get_desc(data.query_item))
|
||||
local desc = get_desc(data.query_item, data.lang_code)
|
||||
desc = ESC(desc)
|
||||
local tech_name = data.query_item
|
||||
local X = data.inv_width + 0.95
|
||||
local Y1 = data.yoffset + 0.47
|
||||
local Y2 = Y1 + 0.5
|
||||
|
||||
if utf8_len(desc) > desc_lim then
|
||||
local _desc = snip(desc, desc_lim, data.font_size)
|
||||
if _desc then
|
||||
tooltip(X, Y1 - 0.1, 5.7, 0.24, desc)
|
||||
desc = snip(desc, desc_lim)
|
||||
end
|
||||
|
||||
if utf8_len(tech_name) > name_lim then
|
||||
local _tech_name = snip(tech_name, name_lim, data.font_size)
|
||||
if _tech_name then
|
||||
tooltip(X, Y2 - 0.1, 5.7, 0.24, tech_name)
|
||||
tech_name = snip(tech_name, name_lim)
|
||||
end
|
||||
|
||||
fs"style_type[label;font=bold;font_size=20]"
|
||||
label(X, Y1, desc)
|
||||
label(X, Y1, _desc or desc)
|
||||
fs"style_type[label;font=mono;font_size=16]"
|
||||
label(X, Y2, clr(colors.blue, tech_name))
|
||||
label(X, Y2, clr(colors.blue, _tech_name or tech_name))
|
||||
fs"style_type[label;font=normal;font_size=16]"
|
||||
|
||||
local def = reg_items[data.query_item]
|
||||
@ -1324,7 +1314,7 @@ local function get_items_fs(fs, data, player, full_height)
|
||||
local ipp = rows * lines
|
||||
local size = 0.85
|
||||
|
||||
bg9(data.inv_width + 0.1, 0, 7.9, full_height, PNG.bg_full, 10)
|
||||
bg9(data.inv_width + 0.1, 0, 7.9, full_height, PNG.bg_full)
|
||||
|
||||
if data.enable_search then
|
||||
fs("set_focus[filter]",
|
||||
@ -1334,7 +1324,7 @@ local function get_items_fs(fs, data, player, full_height)
|
||||
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.1, 4, 0.8, "enable_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", "")
|
||||
@ -1399,11 +1389,13 @@ local function get_items_fs(fs, data, player, full_height)
|
||||
|
||||
for i, title in ipairs(_tabs) do
|
||||
local selected = i == data.itab
|
||||
fs(fmt([[style_type[image_button;fgimg=%s;fgimg_hovered=%s;noclip=true;
|
||||
font_size=16;textcolor=%s;content_offset=0;sound=i3_tab] ]],
|
||||
selected and PNG.tab_small_hover or PNG.tab_small,
|
||||
PNG.tab_small_hover, selected and "#fff" or "#ddd"))
|
||||
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 "#ddd"))
|
||||
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)
|
||||
@ -1420,7 +1412,7 @@ local function get_favs(fs, data)
|
||||
local Y = data.yoffset + 0.8
|
||||
|
||||
if data.query_item == item then
|
||||
image(X, Y, btn_size, btn_size, PNG.slot)
|
||||
slot(X, Y, btn_size, btn_size)
|
||||
end
|
||||
|
||||
item_image_button(X, Y, btn_size, btn_size, item, name, "")
|
||||
@ -1440,7 +1432,7 @@ local function get_panels(fs, data, player)
|
||||
data.yoffset += panels[i - 1].height + 0.1
|
||||
end
|
||||
|
||||
bg9(data.inv_width + 0.1, data.yoffset, 7.9, panel.height, PNG.bg_full, 10)
|
||||
bg9(data.inv_width + 0.1, data.yoffset, 7.9, panel.height, PNG.bg_full)
|
||||
|
||||
local is_recipe, is_usage = panel.name == "recipes", panel.name == "usages"
|
||||
panel.func(fs, data, player, panel, is_recipe, is_usage)
|
||||
@ -1472,11 +1464,18 @@ local function get_tabs_fs(fs, player, data, full_height)
|
||||
end
|
||||
|
||||
local selected = i == data.tab
|
||||
local bgimg = selected and (btm and PNG.tab_hover or PNG.tab_hover_top) or
|
||||
(btm and PNG.tab or PNG.tab_top)
|
||||
local bgimg_hover = btm and PNG.tab_hover or PNG.tab_hover_top
|
||||
|
||||
fs(fmt([[style_type[image_button;fgimg=%s;fgimg_hovered=%s;noclip=true;
|
||||
font_size=16;textcolor=%s;content_offset=0;sound=i3_tab] ]],
|
||||
selected and (btm and PNG.tab_hover or PNG.tab_hover_top) or (btm and PNG.tab or PNG.tab_top),
|
||||
btm and PNG.tab_hover or PNG.tab_hover_top, selected and "#fff" or "#ddd"))
|
||||
local middle = btm and "16,0,-16,-16" or "16,0,-16,0"
|
||||
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] ]],
|
||||
bgimg, bgimg_hover, middle, padding))
|
||||
|
||||
fs(fmt("style_type[image_button;noclip=true;font_size=16;textcolor=%s;content_offset=0;sound=i3_tab]",
|
||||
selected and "#fff" or "#ddd"))
|
||||
|
||||
local X = (data.inv_width / 2) + (c * (tab_len + 0.1)) - ((tab_len + 0.05) * (shift / 2))
|
||||
local Y = btm and full_height or -tab_hgh
|
||||
@ -1486,7 +1485,7 @@ local function get_tabs_fs(fs, player, data, full_height)
|
||||
|
||||
if true_str(def.image) then
|
||||
local desc = translate(data.lang_code, def.description)
|
||||
local desc_len = utf8_len(desc)
|
||||
local desc_len = utf8_len(desc) + data.font_size
|
||||
|
||||
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)
|
||||
@ -1545,7 +1544,7 @@ local function make_fs(player, data)
|
||||
fs(fmt("formspec_version[%u]size[%f,%f]no_prepend[]bgcolor[#0000]",
|
||||
i3.settings.min_fs_version, data.inv_width + 8, full_height), styles)
|
||||
|
||||
bg9(0, 0, data.inv_width, full_height, PNG.bg_full, 10)
|
||||
bg9(0, 0, data.inv_width, full_height, PNG.bg_full)
|
||||
|
||||
local tab = i3.tabs[data.tab]
|
||||
|
||||
@ -1577,7 +1576,15 @@ local function make_fs(player, data)
|
||||
msg(data.player_name, fmt("#fs elements: %u", #fs))
|
||||
end
|
||||
|
||||
return concat(fs)
|
||||
fs = concat(fs)
|
||||
|
||||
if data.font_size ~= 0 then
|
||||
fs = fs:gsub("([font][global]*)([%s_])size=(%d+)", function(a, b, c)
|
||||
return fmt("%s%ssize=%s", a, b, tostring(tonumber(c) + data.font_size))
|
||||
end)
|
||||
end
|
||||
|
||||
return fs
|
||||
end
|
||||
|
||||
return make_fs, get_inventory_fs
|
||||
|
@ -1,3 +1,5 @@
|
||||
local fmt = string.format
|
||||
|
||||
local PNG = {
|
||||
blank = "i3_blank.png",
|
||||
bg = "i3_bg.png",
|
||||
@ -23,7 +25,7 @@ local PNG = {
|
||||
sign = "i3_sign.png",
|
||||
cancel = "i3_cancel.png",
|
||||
export = "i3_export.png",
|
||||
slot = "i3_slot.png",
|
||||
slot = "i3_slot.png^\\[resize:128x128",
|
||||
tab = "i3_tab.png",
|
||||
tab_small = "i3_tab_small.png",
|
||||
tab_top = "i3_tab.png^\\[transformFY",
|
||||
@ -44,6 +46,7 @@ local PNG = {
|
||||
edit = "i3_edit.png",
|
||||
no_result = "i3_no_result.png",
|
||||
find_more = "i3_find_more.png",
|
||||
search_outline = "i3_search_outline.png",
|
||||
|
||||
cancel_hover = "i3_cancel.png^\\[brighten",
|
||||
search_hover = "i3_search.png^\\[brighten",
|
||||
@ -74,12 +77,14 @@ local styles = string.format([[
|
||||
style_type[label,field;font_size=16]
|
||||
style_type[button;border=false;content_offset=0]
|
||||
style_type[image_button,item_image_button,checkbox,dropdown;border=false;sound=i3_click]
|
||||
style_type[item_image_button;bgimg_hovered=%s]
|
||||
style_type[item_image_button;bgimg_middle=9;padding=-9]
|
||||
style_type[item_image_button:hovered;bgimg=%s]
|
||||
|
||||
style[;sound=]
|
||||
style[nofav;sound=i3_cannot]
|
||||
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[exit;fgimg=%s;fgimg_hovered=%s;content_offset=0]
|
||||
style[cancel;fgimg=%s;fgimg_hovered=%s;content_offset=0]
|
||||
style[prev_page,prev_recipe,prev_usage,prev_sort,prev_skin;fgimg=%s;fgimg_hovered=%s]
|
||||
@ -97,6 +102,7 @@ local styles = string.format([[
|
||||
]],
|
||||
PNG.slot,
|
||||
PNG.search_hover,
|
||||
PNG.search_outline,
|
||||
PNG.exit, PNG.exit_hover,
|
||||
PNG.cancel, PNG.cancel_hover,
|
||||
PNG.prev, PNG.prev_hover,
|
||||
@ -111,9 +117,10 @@ local fs_elements = {
|
||||
tooltip = "tooltip[%f,%f;%f,%f;%s]",
|
||||
button = "button[%f,%f;%f,%f;%s;%s]",
|
||||
checkbox = "checkbox[%f,%f;%s;%s;%s]",
|
||||
slot = "image[%f,%f;%f,%f;" .. fmt("%s;9]", PNG.slot),
|
||||
item_image = "item_image[%f,%f;%f,%f;%s]",
|
||||
hypertext = "hypertext[%f,%f;%f,%f;%s;%s]",
|
||||
bg9 = "background9[%f,%f;%f,%f;%s;false;%u]",
|
||||
bg9 = "background9[%f,%f;%f,%f;%s;false;12]",
|
||||
scrollbar = "scrollbar[%f,%f;%f,%f;%s;%s;%u]",
|
||||
model = "model[%f,%f;%f,%f;%s;%s;%s;%s;%s;%s;%s]",
|
||||
image_button = "image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.0 KiB |
BIN
textures/i3_search_outline.png
Normal file
BIN
textures/i3_search_outline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 507 B |
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 2.4 KiB |
Reference in New Issue
Block a user