Compare commits

...

42 Commits
1.7.1 ... 1.9.1

Author SHA1 Message Date
6219c2f64e Fix bug with Quick Crafting 2022-08-14 21:57:45 +02:00
55d364acae Bump version 2022-08-14 20:37:07 +02:00
0a8ae9a3d7 Take replacements into consideration in Quick Crafting (fix #73) 2022-08-14 20:29:22 +02:00
0e2f233234 Improve Quick Crafting look a bit 2022-08-14 20:12:28 +02:00
aeeac6ac1b New highlight look 2022-08-14 19:37:44 +02:00
0c4b4e6c4f Add ability to goto pagenum from pagenum button 2022-08-14 19:21:01 +02:00
7b31c998de Specify custom recipe type in UI 2022-08-14 17:41:03 +02:00
7ee19e3dc5 Minor tweak 2022-08-09 15:19:01 +02:00
60e21627e1 Some tweaks 2022-08-08 22:09:39 +02:00
7e7422def7 🚀 Redesign the armor tab (preview: https://i.imgur.com/Ulkx6KB.png) 2022-08-08 02:50:12 +02:00
aa10460886 Bump version 2022-08-07 16:34:41 +02:00
cef11f5301 Update README 2022-08-07 16:34:19 +02:00
2297b47dc0 Minor Fix 2022-08-07 01:40:49 +02:00
a67ef8b08b Some adjusting 2022-08-07 01:23:36 +02:00
48ab26b4c6 Add a font size global change slider 2022-08-07 00:42:52 +02:00
1389027a22 Another UI tweak 2022-08-01 06:43:20 +02:00
629676a975 Bump version 2022-08-01 04:34:06 +02:00
20b8110375 Minor tweak 2022-08-01 04:21:17 +02:00
a3fea93a09 Remove all the legacy code (MT 5.6+ required) 2022-08-01 04:04:14 +02:00
326ee3e098 Improve search bar look 2022-08-01 03:54:35 +02:00
60bdfa34fb Cleaner bg + slot textures 2022-07-04 05:10:31 +02:00
9971b8c3e6 Improve get_desc() 2022-07-04 03:01:30 +02:00
5a14116b69 Improve alphabetical sorting 2022-07-03 19:40:23 +02:00
222e04d2c4 Minor cleaning 2022-07-03 19:21:13 +02:00
8f4c9f28f1 Also for slots 2022-07-03 18:55:13 +02:00
37e0c21ca3 Add support for bgimg_middle (better looking tabs) 2022-07-03 17:27:03 +02:00
057f0cf03f Fix again 2022-07-03 05:07:49 +02:00
dca93b7249 Minor cleaning 2022-07-02 02:21:14 +02:00
1e9c3ce55a Minor cleaning 2022-07-01 17:28:50 +02:00
1627172cce Check string limits correctly 2022-07-01 17:15:10 +02:00
bd356e4a40 Minor QoL 2022-07-01 15:50:04 +02:00
f26c6af9c4 Minor fix 2022-07-01 15:15:21 +02:00
3f2d983091 Minor tweak 2022-07-01 03:46:25 +02:00
6dd95a6a87 Remove the bullshit and fix the sprite once and for all 2022-07-01 03:36:16 +02:00
32779ab56f Add comments 2022-07-01 03:10:37 +02:00
4ccff6621b Minor tweak 2022-07-01 02:43:05 +02:00
7d0f25e8b2 Minor tweak 2022-07-01 00:47:43 +02:00
652c486249 Tweak textures 2022-06-30 16:31:43 +02:00
9ab47fc0f0 Improve UTF-8 string length counting 2022-06-30 15:18:32 +02:00
c635343c9b Add a 404 image when no item found 2022-06-30 03:10:24 +02:00
662c938afb Minor UI improvement 2022-06-30 02:32:03 +02:00
b2c8447971 Some UI improvements + fix bug with custom tabs 2022-06-30 01:15:35 +02:00
34 changed files with 404 additions and 196 deletions

View File

@ -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.

View File

@ -20,13 +20,14 @@ local function lf(path)
end
i3 = {
version = 190,
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)
@ -51,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,
},

BIN
sounds/i3_heavy_armor.ogg Normal file

Binary file not shown.

BIN
sounds/i3_heavy_boots.ogg Normal file

Binary file not shown.

BIN
sounds/i3_heavy_helmet.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
sounds/i3_heavy_shield.ogg Normal file

Binary file not shown.

BIN
sounds/i3_light_armor.ogg Normal file

Binary file not shown.

BIN
sounds/i3_light_boots.ogg Normal file

Binary file not shown.

BIN
sounds/i3_light_helmet.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
sounds/i3_light_shield.ogg Normal file

Binary file not shown.

View File

@ -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,
})

View File

@ -34,7 +34,7 @@ local function cache_groups(group, groups)
local items = i3.groups[group].items
if #items <= 1 then return end
local c, px, lim = 0, 256, 10
local px, lim, c = 64, 10, 0
local sprite = "[combine:WxH"
for _, item in ipairs(items) do
@ -44,11 +44,10 @@ local function cache_groups(group, groups)
if def.drawtype and is_cube(def.drawtype) then
texture = get_cube(tiles)
elseif texture then
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. "\\^[resize\\:150x150"
end
if texture then
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. fmt("\\^[resize\\:%ux%u", px, px)
sprite = sprite .. fmt(":0,%u=%s", c * px, texture)
c++
if c == lim then break end
@ -57,7 +56,6 @@ local function cache_groups(group, groups)
if c > 1 then
sprite = sprite:gsub("WxH", px .. "x" .. px * c)
i3.groups[group].sprite = sprite
i3.groups[group].count = c
end

View File

@ -6,7 +6,7 @@ local init_hud = i3.files.hud()
local set_fs = i3.set_fs
IMPORT("slz", "min", "insert", "copy", "ItemStack")
IMPORT("spawn_item", "reset_data", "get_detached_inv")
IMPORT("spawn_item", "reset_data", "get_detached_inv", "play_sound")
core.register_on_player_hpchange(function(player, hpchange)
local name = player:get_player_name()
@ -66,16 +66,89 @@ core.register_on_player_inventory_action(function(player, _, _, info)
end
end)
if core.global_exists("armor") then
if core.global_exists"armor" then
i3.modules.armor = true
armor:register_on_update(set_fs)
local group_indexes = {
{"armor_head", "i3_heavy_helmet"},
{"armor_torso", "i3_heavy_armor"},
{"armor_legs", "i3_heavy_leggings"},
{"armor_feet", "i3_heavy_boots"},
{"armor_shield", "i3_heavy_shield"},
}
local function check_group(def, group)
return def.groups[group] and def.groups[group] > 0
end
armor:register_on_equip(function(player, idx, stack)
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
local def = stack:get_definition()
local name = player:get_player_name()
local data = i3.data[name]
for i, v in ipairs(group_indexes) do
local group, sound = unpack(v)
local stackname = stack:get_name()
if stackname:find"wood" or stackname:find"stone" or stackname:find"cactus" then
sound = sound:gsub("heavy", "light")
end
if i == idx and check_group(def, group) then
data.armor_allow = sound
return armor:register_on_update(set_fs)
end
end
data.armor_disallow = true
armor_inv:remove_item("armor", stack)
end)
armor:register_on_update(function(player)
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
if not armor_inv then return end
for i = 1, 5 do
local stack = armor_inv:get_stack("armor", i)
local def = stack:get_definition()
for j, v in ipairs(group_indexes) do
local group = v[1]
if check_group(def, group) and i ~= j then
armor_inv:set_stack("armor", i, armor_inv:get_stack("armor", j))
armor_inv:set_stack("armor", j, stack)
return play_sound(player:get_player_name(), "i3_cannot", 0.8)
end
end
end
end)
core.register_on_player_inventory_action(function(player, action, _, info)
if action ~= "take" then return end
local name = player:get_player_name()
local data = i3.data[name]
if data.armor_disallow then
local inv = player:get_inventory()
inv:set_stack("main", info.index, info.stack)
data.armor_disallow = nil
play_sound(name, "i3_cannot", 0.8)
elseif data.armor_allow then
play_sound(name, data.armor_allow, 0.8)
data.armor_allow = nil
end
end)
end
if core.global_exists("skins") then
if core.global_exists"skins" then
i3.modules.skins = true
end
if core.global_exists("awards") then
if core.global_exists"awards" then
i3.modules.awards = true
core.register_on_craft(function(_, player)
@ -144,11 +217,12 @@ local function init_data(player, info)
data.auto_sorting = false
data.reverse_sorting = false
data.inv_compress = true
data.export_counts = {}
data.crafting_counts = {}
data.tab = 1
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

View File

@ -77,6 +77,16 @@ local function toupper(str)
return str:gsub("%f[%w]%l", upper):gsub("_", " ")
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
c++
end
return c
end
local function get_bag_description(data, stack)
local desc = translate(data.lang_code, stack:get_description())
desc = split(desc, "(")[1] or desc
@ -398,12 +408,13 @@ end
local function craft_stack(player, data, craft_rcp)
local inv = player:get_inventory()
local rcp_usg = craft_rcp and "recipe" or "usage"
local rcp_def = rcp_usg == "recipe" and data.recipes[data.rnum] or data.usages[data.unum]
local output = craft_rcp and data.recipes[data.rnum].output or data.usages[data.unum].output
output = ItemStack(output)
local stackname, stackcount, stackmax = output:get_name(), output:get_count(), output:get_stack_max()
local scrbar_val = data[fmt("scrbar_%s", craft_rcp and "rcp" or "usg")] or 1
for name, count in pairs(data.export_counts[rcp_usg].rcp) do
for name, count in pairs(data.crafting_counts[rcp_usg].rcp) do
local items = {[name] = count}
if is_group(name) then
@ -414,7 +425,7 @@ local function craft_stack(player, data, craft_rcp)
local remaining = count
for _, item in ipairs(item_groups) do
for _name, _count in pairs(data.export_counts[rcp_usg].inv) do
for _name, _count in pairs(data.crafting_counts[rcp_usg].inv) do
if item == _name and remaining > 0 then
local c = min(remaining, _count)
items[item] = c
@ -431,6 +442,14 @@ local function craft_stack(player, data, craft_rcp)
end
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
end
end
local count = stackcount * scrbar_val
local iter = ceil(count / stackmax)
local leftover = count
@ -472,15 +491,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
@ -547,35 +567,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
@ -606,10 +603,12 @@ local function reset_data(data)
data.scrbar_rcp = 1
data.scrbar_usg = 1
data.query_item = nil
data.enable_search = nil
data.goto_page = nil
data.recipes = nil
data.usages = nil
data.export_rcp = nil
data.export_usg = nil
data.crafting_rcp = nil
data.crafting_usg = nil
data.alt_items = nil
data.confirm_trash = nil
data.show_settings = nil
@ -748,6 +747,7 @@ local _ = {
match = string.match,
gmatch = string.gmatch,
toupper = toupper,
utf8_len = utf8_len,
-- Table
maxn = table.maxn,

View File

@ -1,7 +1,7 @@
local set_fs = i3.set_fs
IMPORT("vec_eq", "vec_round")
IMPORT("reg_items", "reg_aliases")
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")
@ -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))
@ -94,6 +89,11 @@ local function inv_fields(player, data, fields)
data.show_settings = nil
data.waypoint_see = nil
data.bag_rename = nil
data.goto_page = nil
if data.filter == "" then
data.enable_search = nil
end
elseif fields.trash then
data.show_settings = nil
@ -154,6 +154,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)
@ -301,21 +304,28 @@ local function select_item(player, data, fields)
data.unum = 1
data.scrbar_rcp = 1
data.scrbar_usg = 1
data.export_rcp = nil
data.export_usg = nil
data.crafting_rcp = nil
data.crafting_usg = nil
end
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
data.enable_search = nil
end
if fields.cancel then
reset_data(data)
elseif fields.exit then
data.query_item = nil
elseif fields.key_enter_field == "filter" or fields.search then
elseif fields.enable_search then
data.enable_search = true
elseif fields.filter and (fields.key_enter_field == "filter" or fields.search) then
if fields.filter == "" then
reset_data(data)
return set_fs(player)
@ -333,6 +343,14 @@ local function rcp_fields(player, data, fields)
sort_by_category(data)
end
elseif fields.pagenum then
data.goto_page = not data.goto_page
elseif fields.goto_page then
local pagenum = tonumber(fields.goto_page)
data.pagenum = max(1, min(data.pagemax, pagenum or data.pagenum))
data.goto_page = nil
elseif fields.prev_page or fields.next_page then
if data.pagemax == 1 then return end
data.pagenum -= (fields.prev_page and 1 or -1)
@ -356,13 +374,13 @@ local function rcp_fields(player, data, fields)
elseif fields.prev_recipe or fields.next_recipe then
local num = data.rnum + (fields.prev_recipe and -1 or 1)
data.rnum = data.recipes[num] and num or (fields.prev_recipe and #data.recipes or 1)
data.export_rcp = nil
data.crafting_rcp = nil
data.scrbar_rcp = 1
elseif fields.prev_usage or fields.next_usage then
local num = data.unum + (fields.prev_usage and -1 or 1)
data.unum = data.usages[num] and num or (fields.prev_usage and #data.usages or 1)
data.export_usg = nil
data.crafting_usg = nil
data.scrbar_usg = 1
elseif fields.fav then
@ -374,17 +392,17 @@ local function rcp_fields(player, data, fields)
remove(data.favs, fav)
end
elseif fields.export_rcp or fields.export_usg then
if fields.export_rcp then
data.export_rcp = not data.export_rcp
elseif fields.crafting_rcp or fields.crafting_usg then
if fields.crafting_rcp then
data.crafting_rcp = not data.crafting_rcp
if not data.export_rcp then
if not data.crafting_rcp then
data.scrbar_rcp = 1
end
else
data.export_usg = not data.export_usg
data.crafting_usg = not data.crafting_usg
if not data.export_usg then
if not data.crafting_usg then
data.scrbar_usg = 1
end
end
@ -397,10 +415,10 @@ local function rcp_fields(player, data, fields)
craft_stack(player, data, fields.craft_rcp)
if fields.craft_rcp then
data.export_rcp = nil
data.crafting_rcp = nil
data.scrbar_rcp = 1
else
data.export_usg = nil
data.crafting_usg = nil
data.scrbar_usg = 1
end
else
@ -419,9 +437,9 @@ core.register_on_player_receive_fields(function(player, formname, fields)
end
-- No-op buttons
if fields.player_name or fields.awards or fields.home_pos or fields.pagenum or
fields.no_item or fields.no_rcp or fields.select_sorting or fields.sort_method or
fields.bg_content then
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

View File

@ -14,9 +14,9 @@ IMPORT("clr", "ESC", "msg", "check_privs")
IMPORT("min", "max", "floor", "ceil", "round")
IMPORT("reg_items", "reg_tools", "reg_entities")
IMPORT("true_str", "is_fav", "is_num", "str_to_pos")
IMPORT("S", "ES", "translate", "ItemStack", "toupper")
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")
IMPORT("extract_groups", "groups_to_items", "is_group", "item_has_groups", "get_group")
@ -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 #str > limit and fmt("%s...", sub(str, 1, limit - 3)) or str
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)
@ -78,8 +82,8 @@ local function get_stack_max(inv, data, is_recipe, rcp)
counts_rcp[it] = (counts_rcp[it] or 0) + 1
end
data.export_counts[rcp_usg] = {}
data.export_counts[rcp_usg].rcp = counts_rcp
data.crafting_counts[rcp_usg] = {}
data.crafting_counts[rcp_usg].rcp = counts_rcp
for i = 1, size do
local stack = list[i]
@ -107,7 +111,7 @@ local function get_stack_max(inv, data, is_recipe, rcp)
end
end
data.export_counts[rcp_usg].inv = counts_inv
data.crafting_counts[rcp_usg].inv = counts_inv
for name in pairs(counts_rcp) do
counts[name] = floor((counts_inv[name] or 0) / (counts_rcp[name] or 0))
@ -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 #title > title_lim then
_title = snip(title, title_lim)
end
if #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 #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,16 +365,16 @@ 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;textcolor=#ddd]"
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)
end
end
fs"style_type[label;font=normal;font_size=16]"
fs"style_type[label;font=normal;font_size=16;textcolor=#fff]"
end
local function get_bag_fs(fs, data, name, esc_name, bag_size, yextra)
@ -467,7 +462,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
end
box(0, yextra + 0.45, ctn_len, 0.045, "#bababa50")
box((data.subcat - 1) * 1.18, yextra + 0.45, 1, 0.045, "#f9826c")
image((data.subcat - 1) * 1.18, yextra + 0.45, 1, 0.045, PNG.highlight)
local function not_installed(modname)
hypertext(0, yextra + 0.9, ctn_len, 0.6, "not_installed",
@ -484,9 +479,39 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
end
local armor_def = armor.def[name]
fs(fmt("list[detached:%s_armor;armor;0,%f;3,2;]", esc_name, yextra + 0.7))
label(3.65, yextra + 1.55, fmt("%s: %s", ES"Level", armor_def.level))
label(3.65, yextra + 2.05, fmt("%s: %s", ES"Heal", armor_def.heal))
fs(fmt("list[detached:%s_armor;armor;0,%f;5,1;]", esc_name, yextra + 0.7))
for i = 1, 5 do
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
local stack = armor_inv:get_stack("armor", i)
if stack:is_empty() then
local tips = {ES"Helmet", ES"Chest", ES"Leggings", ES"Boots", ES"Shield"}
local x = (i - 1) + ((i - 1) * 0.15)
local y = yextra + 0.7
image(x, y, 1, 1, fmt("i3_armor_%u.png", i))
tooltip(x, y, 1, 1, tips[i])
end
end
local box_len, max_level, max_heal = 4, 85, 60
local bar_lvl = (armor_def.level * box_len) / max_level
local bar_heal = (armor_def.heal * box_len) / max_heal
fs"style_type[label;font_size=15]"
box(0.8, yextra + 1.95, box_len, 0.4, "#101010")
fs"style_type[box;colors=#9dc34c80,#9dc34c,#9dc34c,#9dc34c80]"
box(0.8, yextra + 1.95, bar_lvl, 0.4, "")
label(1.1, yextra + 2.15, ES"Armor level")
box(0.8, yextra + 2.55, box_len, 0.4, "#101010")
fs"style_type[box;colors=#4466aa80,#4466aa,#4466aa,#4466aa80]"
box(0.8, yextra + 2.55, bar_heal, 0.4, "")
label(1.1, yextra + 2.75, ES"Armor healing")
fs"style_type[label;font_size=16]"
elseif data.subcat == 3 then
if not i3.modules.skins then
@ -576,11 +601,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 +649,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 +663,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 +690,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 +770,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 +788,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 +806,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 +833,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
@ -830,7 +851,23 @@ local function get_tooltip(item, info, pos)
return fmt("tooltip[%s;%s]", item, ESC(tooltip))
end
local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_size, btn_size2)
local function get_true_count(data, count, is_recipe, is_usage)
local count_mul = 1
if is_recipe then
count_mul = data.scrbar_rcp
elseif is_usage then
count_mul = data.scrbar_usg
end
if count_mul then
count *= count_mul
end
return count
end
local function get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, right, btn_size, btn_size2)
local custom_recipe = i3.craft_types[rcp.type]
local cooking = rcp.type == "cooking"
local fuel = rcp.type == "fuel"
@ -883,7 +920,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 +935,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 = get_true_count(data, count, is_recipe, is_usage)
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,11 +963,11 @@ 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
local function get_grid_fs(fs, data, rcp, is_recipe)
local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
local width = rcp.width or 1
local right = 0
local btn_size, _btn_size = i3.settings.item_btn_size
@ -998,7 +1034,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
if is_group(name) then
groups = group_cache and group_cache.groups or extract_groups(name)
name = group_cache and (group_cache.stereotype or group_cache.items[1]) or
groups_to_items(groups)[1]
groups_to_items(groups)[1] or ""
end
local label = groups and "\nG" or ""
@ -1026,24 +1062,25 @@ 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 = get_true_count(data, count, is_recipe, is_usage)
if group_cache and group_cache.sprite and not large_recipe then
local sprite = ESC(group_cache.sprite)
local size = btn_size - 0.02
item_image_button(X, Y, btn_size, btn_size, "", btn_name, "")
animated_image(X + 0.01, Y + 0.01, 1.89, 1.89, sprite, group_cache.count, 1000)
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]
@ -1068,7 +1105,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
@ -1076,15 +1113,16 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
fs("style_type[item_image_button;border=false]")
end
get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_size, _btn_size)
get_output_fs(fs, data, rcp, is_recipe, is_usage, shapeless, right, btn_size, _btn_size)
end
local function get_rcp_lbl(fs, data, panel, rn, is_recipe)
local function get_rcp_lbl(fs, data, panel, rn, is_recipe, is_usage)
local rcp = is_recipe and panel.rcp[data.rnum] or panel.rcp[data.unum]
if rcp.custom then
hypertext(data.inv_width + 4.8, data.yoffset + 0.12, 3, 0.6, "custom_rcp",
fmt("<global size=16><right><i>%s</i></right>", ES"Custom recipe"))
local desc = i3.craft_types[rcp.type].description
hypertext(data.inv_width + 4.8, data.yoffset + 0.12, 3, 1, "custom_rcp",
fmt("<right><i><global size=16>%s\n<global size=15>%s</i></right>", ES"Custom recipe", desc))
end
local lbl = ES("Usage @1 of @2", data.unum, rn)
@ -1109,7 +1147,7 @@ local function get_rcp_lbl(fs, data, panel, rn, is_recipe)
image_button(data.inv_width + 7.5, y, size, size, "", next_name, "")
end
get_grid_fs(fs, data, rcp, is_recipe)
get_grid_fs(fs, data, rcp, is_recipe, is_usage)
end
local function get_model_fs(fs, data, def, model_alias)
@ -1181,27 +1219,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 #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 #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]
@ -1214,16 +1252,16 @@ local function get_header(fs, data)
end
end
local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg)
local function get_crafting_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg)
local name = is_recipe and "rcp" or "usg"
local show_export = (is_recipe and data.export_rcp) or (is_usage and data.export_usg)
local show_crafting = (is_recipe and data.crafting_rcp) or (is_usage and data.crafting_usg)
fs(fmt("style[export_%s;fgimg=%s;fgimg_hovered=%s]",
name, fmt("%s", show_export and PNG.export_hover or PNG.export), PNG.export_hover))
image_button(data.inv_width + 7.35, data.yoffset + 0.2, 0.45, 0.45, "", fmt("export_%s", name), "")
fs(fmt("tooltip[export_%s;%s]", name, ES"Quick crafting"))
fs(fmt("style[crafting_%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]",
name, fmt("%s", show_crafting and PNG.crafting_hover or PNG.crafting), PNG.crafting_hover))
image_button(data.inv_width + 7.35, data.yoffset + 0.2, 0.45, 0.45, "", fmt("crafting_%s", name), "")
fs(fmt("tooltip[crafting_%s;%s]", name, ES"Quick crafting"))
if not show_export then return end
if not show_crafting then return end
local craft_max = is_recipe and max_stacks_rcp or max_stacks_usg
local stack_fs = (is_recipe and data.scrbar_rcp) or (is_usage and data.scrbar_usg) or 1
@ -1238,12 +1276,21 @@ local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_
end
end
local x = data.inv_width + 6.8
fs"style_type[image,button,image_button;noclip=true]"
image(x, data.yoffset + 0.8, 3, 2, PNG.bg_content)
fs"style[quick_crafting;font_size=16;textcolor=#ddd]"
button(x, data.yoffset + 0.85, 3.05, 0.55, "quick_crafting", ES"Quick Crafting")
fs(fmt("style[scrbar_%s;noclip=true]", name),
fmt("scrollbaroptions[min=1;max=%u;smallstep=1]", craft_max))
local x = data.inv_width + 8.1
scrollbar(x, data.yoffset, 2.5, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs)
button(x, data.yoffset + 0.4, 2.5, 0.7, fmt("craft_%s", name), ES("Craft (×@1)", stack_fs))
scrollbar(x + 0.2, data.yoffset + 1.45, 2.5, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs)
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)
@ -1265,18 +1312,18 @@ local function get_rcp_extra(fs, data, player, panel, is_recipe, is_usage)
end
if is_recipe and max_stacks_rcp == 0 then
data.export_rcp = nil
data.crafting_rcp = nil
data.scrbar_rcp = 1
elseif is_usage and max_stacks_usg == 0 then
data.export_usg = nil
data.crafting_usg = nil
data.scrbar_usg = 1
end
if max_stacks_rcp > 0 or max_stacks_usg > 0 then
get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg)
get_crafting_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg)
end
get_rcp_lbl(fs, data, panel, rn, is_recipe)
get_rcp_lbl(fs, data, panel, rn, is_recipe, is_usage)
else
local lbl = is_recipe and ES"No recipes" or ES"No usages"
button(data.inv_width + 0.1, data.yoffset + (panel.height / 2) - 0.5, 7.8, 1, "no_rcp", lbl)
@ -1323,31 +1370,53 @@ 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)
fs(fmt("box[%f,0.2;4.05,0.6;#bababa25]", data.inv_width + 0.3),
"set_focus[filter]",
fmt("field[%f,0.2;2.95,0.6;filter;;%s]", data.inv_width + 0.35, ESC(data.filter)),
"field_close_on_enter[filter;false]")
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_button(data.inv_width + 3.35, 0.35, 0.3, 0.3, "", "cancel", "")
image_button(data.inv_width + 3.85, 0.32, 0.35, 0.35, "", "search", "")
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))
button(data.inv_width + 5.6, 0.14, 1.88, 0.7, "pagenum",
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
if next(i3.recipe_filters) and #i3.init_items > 0 and data.filter == "" then
lbl = ES"Collect items to reveal more recipes"
lbl = ES"Collect items to reveal more recipes" -- Progressive mode, etc.
icon, width, offset = PNG.find_more, 2.5, 2.75
end
button(data.inv_width + 0.1, 3, 8, 1, "no_item", lbl)
image(data.inv_width + offset, 3.5, width, width, icon)
button(data.inv_width + 0.1, 7, 8, 1, "no_item", lbl)
else
local first_item = (data.pagenum - 1) * ipp
@ -1362,7 +1431,7 @@ local function get_items_fs(fs, data, player, full_height)
X -= (X * 0.045) + data.inv_width + 0.28
local Y = round((i % ipp - X) / rows + 1, 0)
Y -= (Y * 0.085) + 0.95
Y -= (Y * 0.085) + 0.92
insert(fs, fmt("item_image_button", X, Y, size, size, name, item, ""))
@ -1377,16 +1446,31 @@ 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
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 "#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)
@ -1403,7 +1487,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, "")
@ -1423,7 +1507,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)
@ -1455,11 +1539,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
@ -1469,8 +1560,10 @@ 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) + data.font_size
fs("style_type[image;noclip=true]")
image(X + (tab_len / 2) - ((#desc * 0.1) / 2) - 0.55, Y + 0.05, 0.35, 0.35, def.image)
image(X + (tab_len / 2) - ((desc_len * 0.1) / 2) - 0.55, Y + 0.05, 0.35, 0.35, def.image)
end
c++
@ -1526,7 +1619,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]
@ -1540,11 +1633,11 @@ local function make_fs(player, data)
get_items_fs(fs, data, player, full_height)
end
local visible_tabs = 1
local visible_tabs = #i3.tabs
for _, def in ipairs(i3.tabs) do
if visible_tabs < 2 and def.access and def.access(player, data) then
visible_tabs++
if def.access and not def.access(player, data) then
visible_tabs -= 1
end
end
@ -1558,7 +1651,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

View File

@ -1,10 +1,14 @@
local fmt = string.format
local PNG = {
blank = "i3_blank.png",
bg = "i3_bg.png",
bg_full = "i3_bg_full.png",
bg_goto = "i3_bg_goto.png",
bg_content = "i3_bg_content.png",
bar = "i3_bar.png",
hotbar = "i3_hotbar.png",
highlight = "i3_highlight.png",
search = "i3_search.png",
heart = "i3_heart.png",
heart_half = "i3_heart_half.png",
@ -22,8 +26,9 @@ local PNG = {
book = "i3_book.png",
sign = "i3_sign.png",
cancel = "i3_cancel.png",
export = "i3_export.png",
slot = "i3_slot.png",
crafting = "i3_crafting.png",
slot = "i3_slot.png^\\[resize:128x128",
pagenum_hover = "i3_slot.png^\\[resize:128x128^\\[opacity:130",
tab = "i3_tab.png",
tab_small = "i3_tab_small.png",
tab_top = "i3_tab.png^\\[transformFY",
@ -42,10 +47,14 @@ local PNG = {
home = "i3_home.png",
flag = "i3_flag.png",
edit = "i3_edit.png",
no_result = "i3_no_result.png",
find_more = "i3_find_more.png",
search_outline = "i3_search_outline.png",
search_outline_trim = "i3_search_outline_trim.png",
cancel_hover = "i3_cancel.png^\\[brighten",
search_hover = "i3_search.png^\\[brighten",
export_hover = "i3_export.png^\\[brighten",
crafting_hover = "i3_crafting.png^\\[brighten",
trash_hover = "i3_trash.png^\\[brighten^\\[colorize:#f00:100",
compress_hover = "i3_compress.png^\\[brighten",
sort_hover = "i3_sort.png^\\[brighten",
@ -72,14 +81,17 @@ 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[enable_search:pressed;bgimg=%s^[opacity:178]
style[exit;fgimg=%s;fgimg_hovered=%s;content_offset=0]
style[cancel;fgimg=%s;fgimg_hovered=%s;content_offset=0]
style[search;fgimg=%s;fgimg_hovered=%s;content_offset=0]
style[prev_page,prev_recipe,prev_usage,prev_sort,prev_skin;fgimg=%s;fgimg_hovered=%s]
style[next_page,next_recipe,next_usage,next_sort,next_skin;fgimg=%s;fgimg_hovered=%s]
style[waypoint_add;fgimg=%s;fgimg_hovered=%s;content_offset=0]
@ -94,9 +106,10 @@ 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.search, PNG.search_hover,
PNG.prev, PNG.prev_hover,
PNG.next, PNG.next_hover,
PNG.add, PNG.add_hover,
@ -109,9 +122,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]",

BIN
textures/i3_armor_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

BIN
textures/i3_armor_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

BIN
textures/i3_armor_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

BIN
textures/i3_armor_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

BIN
textures/i3_armor_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
textures/i3_bg_goto.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
textures/i3_crafting.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

BIN
textures/i3_find_more.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
textures/i3_highlight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

BIN
textures/i3_no_result.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB