mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-24 18:00:38 +01:00
🚀 Greatly improve Progressive Mode look
This commit is contained in:
parent
05995a22df
commit
325d6f30be
7
init.lua
7
init.lua
@ -38,7 +38,6 @@ i3 = {
|
||||
|
||||
damage_enabled = core.settings:get_bool"enable_damage",
|
||||
progressive_mode = core.settings:get_bool"i3_progressive_mode",
|
||||
item_compression = core.settings:get_bool("i3_item_compression", true),
|
||||
},
|
||||
|
||||
categories = {
|
||||
@ -52,6 +51,7 @@ i3 = {
|
||||
saves = { -- Metadata to save
|
||||
bag = true,
|
||||
home = true,
|
||||
collapse = true,
|
||||
font_size = true,
|
||||
hide_tabs = true,
|
||||
waypoints = true,
|
||||
@ -61,6 +61,11 @@ i3 = {
|
||||
legacy_inventory = true,
|
||||
},
|
||||
|
||||
default_enabled = {
|
||||
collapse = true,
|
||||
inv_compress = true,
|
||||
},
|
||||
|
||||
files = {
|
||||
api = lf"/src/api.lua",
|
||||
bags = lf"/src/bags.lua",
|
||||
|
@ -1,5 +1,2 @@
|
||||
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
||||
i3_progressive_mode (Learn crafting recipes progressively) bool false
|
||||
|
||||
# Regroup the items of the same type in the item list.
|
||||
i3_item_compression (Regroup items of the same type) bool true
|
||||
|
BIN
sounds/i3_achievement.ogg
Normal file
BIN
sounds/i3_achievement.ogg
Normal file
Binary file not shown.
@ -3,7 +3,7 @@ local make_fs, get_inventory_fs = i3.files.gui()
|
||||
|
||||
IMPORT("gmatch", "split")
|
||||
IMPORT("S", "err", "fmt", "reg_items")
|
||||
IMPORT("sorter", "sort_inventory")
|
||||
IMPORT("sorter", "sort_inventory", "play_sound")
|
||||
IMPORT("sort", "concat", "copy", "insert", "remove")
|
||||
IMPORT("true_str", "true_table", "is_str", "is_func", "is_table", "clean_name")
|
||||
|
||||
@ -323,8 +323,10 @@ function i3.hud_notif(name, msg, img)
|
||||
data.show_hud = true
|
||||
data.hud_msg = msg
|
||||
|
||||
play_sound(name, "i3_achievement", 1.0)
|
||||
|
||||
if img then
|
||||
data.hud_img = fmt("%s^[resize:16x16", img)
|
||||
data.hud_img = fmt("%s^[resize:64x64", img)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -203,6 +203,17 @@ local function init_data(player, info)
|
||||
local name = player:get_player_name()
|
||||
i3.data[name] = i3.data[name] or {}
|
||||
local data = i3.data[name]
|
||||
local default = {}
|
||||
|
||||
for k in pairs(i3.default_enabled) do
|
||||
default[k] = data[k]
|
||||
|
||||
if data[k] == nil then
|
||||
default[k] = true
|
||||
end
|
||||
|
||||
data[k] = default[k]
|
||||
end
|
||||
|
||||
data.player_name = name
|
||||
data.filter = ""
|
||||
@ -215,7 +226,6 @@ local function init_data(player, info)
|
||||
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
|
||||
|
@ -328,7 +328,7 @@ local function apply_recipe_filters(recipes, player)
|
||||
end
|
||||
|
||||
local function compression_active(data)
|
||||
return i3.settings.item_compression and not next(i3.recipe_filters) and data.filter == ""
|
||||
return data.collapse and not next(i3.recipe_filters) and data.filter == ""
|
||||
end
|
||||
|
||||
local function compressible(item, data)
|
||||
|
@ -2,12 +2,12 @@ local set_fs = i3.set_fs
|
||||
|
||||
IMPORT("min", "max", "vec_round")
|
||||
IMPORT("reg_items", "reg_aliases")
|
||||
IMPORT("S", "random", "translate", "ItemStack")
|
||||
IMPORT("sort", "copy", "insert", "remove", "indexof")
|
||||
IMPORT("S", "random", "translate", "compressible", "ItemStack")
|
||||
IMPORT("fmt", "find", "match", "sub", "lower", "split", "toupper")
|
||||
IMPORT("valid_item", "get_stack", "craft_stack", "clean_name", "check_privs", "safe_teleport")
|
||||
IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "reset_data")
|
||||
IMPORT("search", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv", "update_inv_size")
|
||||
IMPORT("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
|
||||
|
||||
local function inv_fields(player, data, fields)
|
||||
local name = data.player_name
|
||||
@ -40,6 +40,8 @@ local function inv_fields(player, data, fields)
|
||||
|
||||
if str == "legacy_inventory" then
|
||||
update_inv_size(player, data)
|
||||
elseif str == "collapse" then
|
||||
search(data)
|
||||
end
|
||||
|
||||
elseif sub(field, 1, 8) == "setting_" then
|
||||
|
61
src/gui.lua
61
src/gui.lua
@ -12,8 +12,8 @@ IMPORT("find", "match", "sub", "upper")
|
||||
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("reg_items", "reg_nodes", "reg_tools", "reg_entities")
|
||||
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")
|
||||
@ -435,7 +435,7 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
||||
|
||||
for i = 1, 10 do
|
||||
image(heart_x + ((i - 1) * (heart_size + 0.1)), heart_h,
|
||||
heart_size, heart_size, PNG.heart_grey)
|
||||
heart_size, heart_size, PNG.heart .. "^[colorize:#232428")
|
||||
end
|
||||
|
||||
for i = 1, hearts do
|
||||
@ -583,7 +583,8 @@ local function show_settings(fs, data)
|
||||
image_button(6.17, 10.75, 1, 0.5, "", "confirm_trash_no", "No")
|
||||
|
||||
elseif data.show_settings then
|
||||
image(2.2, 9, 6, 2.35, PNG.bg_content)
|
||||
fs"container[-0.06,0]"
|
||||
image(2.2, 9, 6.1, 2.35, PNG.bg_content)
|
||||
|
||||
local show_home = data.show_setting == "home"
|
||||
local show_style = data.show_setting == "style"
|
||||
@ -606,9 +607,9 @@ local function show_settings(fs, data)
|
||||
|
||||
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", "")
|
||||
button(X + 1.7, 9.1, 1.6, 0.55, "setting_style", "Style")
|
||||
button(X + 3.38, 9.1, 1.6, 0.55, "setting_sorting", "Sorting")
|
||||
image_button(X + 5.12, 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"
|
||||
@ -622,20 +623,24 @@ local function show_settings(fs, data)
|
||||
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")
|
||||
hypertext(2.2, 9.9, 6, 0.6, "home_pos", fmt("<global size=16><center>%s</center>", str))
|
||||
image_button(4.3, 10.4, 1.8, 0.7, "", "set_home", "Set home")
|
||||
|
||||
elseif show_style then
|
||||
checkbox(2.6, 9.95, "cb_hide_tabs", "Hide tabs", tostring(data.hide_tabs))
|
||||
checkbox(2.6, 10.4, "cb_legacy_inventory", "Legacy inventory", tostring(data.legacy_inventory))
|
||||
checkbox(2.6, 10.85, "cb_wielditem_hud", "HUD description", tostring(data.wielditem_hud))
|
||||
|
||||
if not next(i3.recipe_filters) then
|
||||
checkbox(5.3, 10.85, "cb_collapse", "Collapse inventory", tostring(data.collapse))
|
||||
end
|
||||
|
||||
local sign = (data.font_size > 0 and "+") or (data.font_size > 0 and "-") or ""
|
||||
label(5.3, 9.95, ES"Font size" .. fmt(": %s", sign .. data.font_size))
|
||||
|
||||
local range = 5
|
||||
fs("scrollbaroptions[min=-%u;max=%u;smallstep=1;largestep=1;thumbsize=2]", range, range)
|
||||
fs("scrollbar[5.3,10.25;2.45,0.3;horizontal;sb_font_size;%d]", data.font_size)
|
||||
fs("scrollbar[5.3,10.2;2.45,0.3;horizontal;sb_font_size;%d]", data.font_size)
|
||||
|
||||
fs("tooltip[cb_hide_tabs;%s;#707070;#fff]",
|
||||
ES"Enable this option to change the style of the right panel")
|
||||
@ -643,12 +648,14 @@ local function show_settings(fs, data)
|
||||
ES"Enable this option to set the classic inventory size in Minetest")
|
||||
fs("tooltip[cb_wielditem_hud;%s;#707070;#fff]",
|
||||
ES"Enable this option to show the wielded item description in your HUD")
|
||||
fs("tooltip[cb_collapse;%s;#707070;#fff]",
|
||||
ES"Enable this option to collapse certain items in your inventory")
|
||||
|
||||
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.4, 9.95, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
||||
checkbox(5.3, 9.95, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
||||
|
||||
local methods = {}
|
||||
|
||||
@ -657,13 +664,13 @@ local function show_settings(fs, data)
|
||||
insert(methods, name)
|
||||
end
|
||||
|
||||
label(5.4, 10.4, ES"Sorting method:")
|
||||
fs("dropdown[%f,%f;2.4,0.5;dd_sorting_method;%s;%u;true]",
|
||||
5.4, 10.6, concat(methods, ","), data.sort)
|
||||
label(5.3, 10.4, ES"Sorting method:")
|
||||
fs("dropdown[%f,%f;2.6,0.5;dd_sorting_method;%s;%u;true]",
|
||||
5.3, 10.6, concat(methods, ","), data.sort)
|
||||
|
||||
local desc = i3.sorting_methods[data.sort].description
|
||||
if desc then
|
||||
tooltip(5.4, 10.6, 2.4, 0.5, ESC(desc))
|
||||
tooltip(5.3, 10.6, 2.4, 0.5, ESC(desc))
|
||||
end
|
||||
|
||||
fs("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
||||
@ -675,6 +682,8 @@ local function show_settings(fs, data)
|
||||
fs("tooltip[cb_auto_sorting;%s;#707070;#fff]",
|
||||
ES"Enable this option to sort your inventory automatically")
|
||||
end
|
||||
|
||||
fs"container_end[]"
|
||||
end
|
||||
end
|
||||
|
||||
@ -1356,7 +1365,7 @@ local function hide_items(player, data)
|
||||
data.items = new
|
||||
end
|
||||
|
||||
if not core.is_creative_enabled(data.player_name) then
|
||||
if not core.is_creative_enabled(data.player_name) and not next(i3.recipe_filters) then
|
||||
local new = {}
|
||||
|
||||
for i = 1, #data.items do
|
||||
@ -1509,7 +1518,24 @@ local function get_items_fs(fs, data, player, full_height)
|
||||
local Y = round((i % ipp - X) / rows + 1, 0)
|
||||
Y -= (Y * 0.085) + 0.92
|
||||
|
||||
insert(fs, fmt("item_image_button", X, Y, size, size, name, item, ""))
|
||||
local item_btn = fmt("item_image_button", X, Y, size, size, name, item, "")
|
||||
|
||||
if next(i3.recipe_filters) then
|
||||
if data.items_progress[item] then
|
||||
insert(fs, item_btn)
|
||||
else
|
||||
local col = "^\\[colorize:#232428^\\[opacity:245"
|
||||
local img = reg_items[item].inventory_image .. col
|
||||
|
||||
if reg_nodes[item] then
|
||||
img = PNG.cube .. col
|
||||
end
|
||||
|
||||
insert(fs, fmt("image", X, Y, size, size, img))
|
||||
end
|
||||
else
|
||||
insert(fs, item_btn)
|
||||
end
|
||||
|
||||
if compressible(item, data) then
|
||||
local expand = data.expand == name
|
||||
@ -1652,10 +1678,9 @@ local function make_fs(player, data)
|
||||
__call = function(t, ...)
|
||||
local args = {...}
|
||||
|
||||
if select("#", ...) > 1 then
|
||||
if #args > 1 then
|
||||
local arg1 = args[1]
|
||||
local elem = fs_elements[arg1]
|
||||
|
||||
insert(t, fmt(elem or arg1, select(2, ...)))
|
||||
else
|
||||
insert(t, concat(args))
|
||||
|
@ -26,7 +26,7 @@ local function init_hud(player)
|
||||
hud_elem_type = "image",
|
||||
position = {x = 0.79, y = 1.02},
|
||||
alignment = {x = 1, y = 1},
|
||||
scale = {x = 4, y = 4},
|
||||
scale = {x = 1, y = 1},
|
||||
text = "",
|
||||
z_index = 0xDEAD,
|
||||
},
|
||||
@ -59,7 +59,7 @@ local function show_hud(player, data)
|
||||
-- 2 calls for the notification's back and forth.
|
||||
|
||||
local hud_info_bg = player:hud_get(data.hud.bg)
|
||||
local dt = 0.016
|
||||
local dt = 0.025
|
||||
|
||||
if hud_info_bg.position.y <= 0.9 then
|
||||
data.show_hud = false
|
||||
|
@ -2,11 +2,12 @@ local set_fs = i3.set_fs
|
||||
local hud_notif = i3.hud_notif
|
||||
local POLL_FREQ = 0.25
|
||||
|
||||
IMPORT("reg_items", "reg_nodes")
|
||||
IMPORT("fmt", "search", "table_merge", "array_diff")
|
||||
IMPORT("is_group", "extract_groups", "item_has_groups", "apply_recipe_filters")
|
||||
|
||||
local function get_filtered_items(player, data)
|
||||
local items, known, c = {}, 0, 0
|
||||
local items, known = {}, 0
|
||||
|
||||
for i = 1, #i3.init_items do
|
||||
local item = i3.init_items[i]
|
||||
@ -17,8 +18,7 @@ local function get_filtered_items(player, data)
|
||||
usages = #apply_recipe_filters(usages or {}, player)
|
||||
|
||||
if recipes > 0 or usages > 0 then
|
||||
c++
|
||||
items[c] = item
|
||||
items[item] = true
|
||||
known += recipes + usages
|
||||
end
|
||||
end
|
||||
@ -133,10 +133,18 @@ local function poll_new_items(player, data, join)
|
||||
|
||||
if data.discovered > 0 then
|
||||
local msg = fmt("%u new recipe%s unlocked!", data.discovered, data.discovered > 1 and "s" or "")
|
||||
hud_notif(data.player_name, msg, "i3_book.png")
|
||||
local last_discovered = diff[1]
|
||||
local img = reg_items[last_discovered].inventory_image
|
||||
|
||||
if reg_nodes[last_discovered] then
|
||||
local id = core.get_content_id(last_discovered)
|
||||
img = i3.cubes[id] or img
|
||||
end
|
||||
|
||||
data.items_raw = items
|
||||
hud_notif(data.player_name, msg, img)
|
||||
end
|
||||
|
||||
data.items_progress = items
|
||||
data.itab = 1
|
||||
|
||||
search(data)
|
||||
|
@ -12,7 +12,6 @@ local PNG = {
|
||||
search = "i3_search.png",
|
||||
heart = "i3_heart.png",
|
||||
heart_half = "i3_heart_half.png",
|
||||
heart_grey = "i3_heart_grey.png",
|
||||
prev = "i3_next.png^\\[transformFX",
|
||||
next = "i3_next.png",
|
||||
arrow = "i3_arrow.png",
|
||||
@ -54,6 +53,7 @@ local PNG = {
|
||||
all = "i3_all.png",
|
||||
node = "i3_node.png",
|
||||
item = "i3_item.png",
|
||||
cube = "i3_cube.png",
|
||||
|
||||
cancel_hover = "i3_cancel.png^\\[brighten",
|
||||
search_hover = "i3_search.png^\\[brighten",
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 262 B |
BIN
textures/i3_cube.png
Normal file
BIN
textures/i3_cube.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 404 B |
Binary file not shown.
Before Width: | Height: | Size: 147 B |
Loading…
Reference in New Issue
Block a user