Mods update
parent
ba28e54422
commit
22c05b5923
|
@ -1,6 +1,6 @@
|
|||
|
||||
origin https://github.com/minetest/minetest_game.git (fetch)
|
||||
* master c6171a8 [origin/master] Add Esperanto translation (#2739)
|
||||
* master 79e63a8 [origin/master] Check for required engine features on startup
|
||||
Mod: minetest_game/mods/beds
|
||||
Mod: minetest_game/mods/binoculars
|
||||
Mod: minetest_game/mods/boats
|
||||
|
@ -77,7 +77,7 @@ origin https://notabug.org/tenplus1/farming (fetch)
|
|||
Mod: flora/farming
|
||||
|
||||
origin https://github.com/minetest-mods/i3.git (fetch)
|
||||
* main 859feb4 [origin/main] Minor cleaning
|
||||
* main ca5cd92 [origin/main] Update Screenshot
|
||||
Mod: gui/i3
|
||||
|
||||
origin https://repo.or.cz/minetest_hbarmor.git (fetch)
|
||||
|
|
|
@ -27,12 +27,6 @@ i3.new_tab {
|
|||
fields = function(player, data, fields)
|
||||
|
||||
end,
|
||||
|
||||
-- Determine if the recipe panels must be hidden or not (must return a boolean)
|
||||
hide_panels = function(player, data)
|
||||
local name = player:get_player_name()
|
||||
return core.is_creative_enabled(name)
|
||||
end,
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -48,4 +48,4 @@ Love this mod? Donations are appreciated: https://www.paypal.me/jpg84240
|
|||
|
||||
Demo video (outdated): https://www.youtube.com/watch?v=25nCAaqeacU
|
||||
|
||||
![Preview](https://user-images.githubusercontent.com/7883281/115294125-7827cb80-a158-11eb-89f1-1f533621a9fe.png)
|
||||
![Preview](https://user-images.githubusercontent.com/7883281/116791813-0edf7b00-aabd-11eb-90b3-11c604af34dc.png)
|
||||
|
|
|
@ -75,9 +75,6 @@ local pairs, ipairs, next, type, setmetatable, tonum, unpack, select =
|
|||
|
||||
local vec_add, vec_mul = vector.add, vector.multiply
|
||||
|
||||
local ROWS = 9
|
||||
local LINES = 10
|
||||
local IPP = ROWS * LINES
|
||||
local MAX_FAVS = 6
|
||||
local ITEM_BTN_SIZE = 1.1
|
||||
|
||||
|
@ -142,6 +139,7 @@ local PNG = {
|
|||
refresh = "i3_refresh.png",
|
||||
visible = "i3_visible.png^\\[brighten",
|
||||
nonvisible = "i3_non_visible.png",
|
||||
exit = "i3_exit.png",
|
||||
|
||||
cancel_hover = "i3_cancel.png^\\[brighten",
|
||||
search_hover = "i3_search.png^\\[brighten",
|
||||
|
@ -162,6 +160,7 @@ local PNG = {
|
|||
teleport_hover = "i3_teleport.png^\\[brighten",
|
||||
add_hover = "i3_add.png^\\[brighten",
|
||||
refresh_hover = "i3_refresh.png^\\[brighten",
|
||||
exit_hover = "i3_exit.png^\\[brighten",
|
||||
}
|
||||
|
||||
local fs_elements = {
|
||||
|
@ -188,6 +187,7 @@ local styles = sprintf([[
|
|||
style_type[item_image_button;bgimg_hovered=%s]
|
||||
|
||||
style[pagenum,no_item,no_rcp;font=bold;font_size=18]
|
||||
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;fgimg=%s;fgimg_hovered=%s]
|
||||
|
@ -203,6 +203,7 @@ local styles = sprintf([[
|
|||
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6]
|
||||
]],
|
||||
PNG.slot,
|
||||
PNG.exit, PNG.exit_hover,
|
||||
PNG.cancel, PNG.cancel_hover,
|
||||
PNG.search, PNG.search_hover,
|
||||
PNG.prev, PNG.prev_hover,
|
||||
|
@ -354,6 +355,11 @@ local function clean_name(item)
|
|||
return item
|
||||
end
|
||||
|
||||
local function round(num, decimal)
|
||||
local mul = 10 ^ decimal
|
||||
return floor(num * mul + 0.5) / mul
|
||||
end
|
||||
|
||||
local function array_diff(t1, t2)
|
||||
local hash = {}
|
||||
|
||||
|
@ -1489,7 +1495,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
|||
local count = item:get_count()
|
||||
|
||||
local X = ceil((i - 1) % width - width)
|
||||
X = X + (X * 0.2) + data.xoffset + 3.9
|
||||
X = X + (X * 0.2) + data.inv_width + 3.9
|
||||
|
||||
local Y = ceil(i / width) - min(2, rows)
|
||||
Y = Y + (Y * 0.15) + data.yoffset + 1.4
|
||||
|
@ -1501,7 +1507,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
|||
local xi = (i - 1) % width
|
||||
local yi = floor((i - 1) / width)
|
||||
|
||||
X = btn_size * xi + data.xoffset + 0.3 + (xi * 0.05)
|
||||
X = btn_size * xi + data.inv_width + 0.3 + (xi * 0.05)
|
||||
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05)
|
||||
end
|
||||
|
||||
|
@ -1587,7 +1593,7 @@ local function get_rcp_lbl(fs, data, panel, rn, is_recipe)
|
|||
local rcp = is_recipe and panel.rcp[data.rnum] or panel.rcp[data.unum]
|
||||
|
||||
if rcp.custom then
|
||||
fs("hypertext", data.xoffset + 4.8, data.yoffset + 0.2, 3, 0.6, "custom_rcp",
|
||||
fs("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"))
|
||||
end
|
||||
|
||||
|
@ -1600,7 +1606,7 @@ local function get_rcp_lbl(fs, data, panel, rn, is_recipe)
|
|||
local one = rn == 1
|
||||
local y = data.yoffset + 3.3
|
||||
|
||||
fs("hypertext", data.xoffset + (one and 4.7 or 3.95), y, 3, 0.6, "rcp_num",
|
||||
fs("hypertext", data.inv_width + (one and 4.7 or 3.95), y, 3, 0.6, "rcp_num",
|
||||
fmt("<global size=16><right>%s</right>", lbl))
|
||||
|
||||
if not one then
|
||||
|
@ -1609,8 +1615,8 @@ local function get_rcp_lbl(fs, data, panel, rn, is_recipe)
|
|||
local next_name = fmt("next_%s", btn_suffix)
|
||||
local size = 0.3
|
||||
|
||||
fs("image_button", data.xoffset + 7.05, y, size, size, "", prev_name, "")
|
||||
fs("image_button", data.xoffset + 7.5, y, size, size, "", next_name, "")
|
||||
fs("image_button", data.inv_width + 7.05, y, size, size, "", prev_name, "")
|
||||
fs("image_button", data.inv_width + 7.5, y, size, size, "", next_name, "")
|
||||
end
|
||||
|
||||
get_grid_fs(fs, data, rcp, is_recipe)
|
||||
|
@ -1658,7 +1664,7 @@ local function get_model_fs(fs, data, def, model_alias)
|
|||
t[#t + 1] = t[#t]
|
||||
end
|
||||
|
||||
fs("model", data.xoffset + 6.6, data.yoffset + 0.05, 1.3, 1.3, "preview",
|
||||
fs("model", data.inv_width + 6.6, data.yoffset + 0.05, 1.3, 1.3, "preview",
|
||||
def.mesh, concat(t, ","), "0,0", "true", "true",
|
||||
model_alias and model_alias.frames or "")
|
||||
end
|
||||
|
@ -1666,27 +1672,30 @@ end
|
|||
local function get_header(fs, data)
|
||||
local fav = is_fav(data.favs, data.query_item)
|
||||
local nfavs = #data.favs
|
||||
local star_x, star_y, star_size = data.xoffset + 0.4, data.yoffset + 0.5, 0.4
|
||||
local star_x, star_y, size = data.inv_width + 0.3, data.yoffset + 0.2, 0.4
|
||||
|
||||
if nfavs < MAX_FAVS or (nfavs == MAX_FAVS and fav) then
|
||||
local fav_marked = fmt("i3_fav%s.png", fav and "_off" or "")
|
||||
|
||||
fs(fmt("style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
||||
fmt("i3_fav%s.png", fav and "" or "_off"), fav_marked, fav_marked))
|
||||
fs("image_button", star_x, star_y, star_size, star_size, "", "fav", "")
|
||||
fs("image_button", star_x, star_y, size, size, "", "fav", "")
|
||||
fs(fmt("tooltip[fav;%s]", fav and ES"Unmark this item" or ES"Mark this item"))
|
||||
else
|
||||
fs(fmt("style[nofav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
||||
"i3_fav_off.png", PNG.cancel, PNG.cancel))
|
||||
fs("image_button", star_x, star_y, star_size, star_size, "", "nofav", "")
|
||||
fs("image_button", star_x, star_y, size, size, "", "nofav", "")
|
||||
fs(fmt("tooltip[nofav;%s]", ES"Cannot mark this item. Bookmark limit reached."))
|
||||
end
|
||||
|
||||
local desc_lim, name_lim = 33, 34
|
||||
fs("image_button", star_x + 0.05, star_y + 0.6, size, size, "", "exit", "")
|
||||
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))
|
||||
desc = ESC(desc)
|
||||
local tech_name = data.query_item
|
||||
local X = data.xoffset + 1.05
|
||||
local X = data.inv_width + 0.95
|
||||
local Y1 = data.yoffset + 0.47
|
||||
local Y2 = Y1 + 0.5
|
||||
|
||||
|
@ -1712,7 +1721,7 @@ local function get_header(fs, data)
|
|||
if def.drawtype == "mesh" or model_alias then
|
||||
get_model_fs(fs, data, def, model_alias)
|
||||
else
|
||||
fs("item_image", data.xoffset + 6.8, data.yoffset + 0.17, 1.1, 1.1, data.query_item)
|
||||
fs("item_image", data.inv_width + 6.8, data.yoffset + 0.17, 1.1, 1.1, data.query_item)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1722,7 +1731,7 @@ local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_
|
|||
|
||||
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))
|
||||
fs("image_button", data.xoffset + 7.35, data.yoffset + 0.2, 0.45, 0.45, "", fmt("export_%s", name), "")
|
||||
fs("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"))
|
||||
|
||||
if not show_export then return end
|
||||
|
@ -1742,12 +1751,13 @@ local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_
|
|||
|
||||
fs(fmt("style[scrbar_%s;noclip=true]", name),
|
||||
fmt("scrollbaroptions[min=1;max=%u;smallstep=1]", craft_max))
|
||||
fs("scrollbar", data.xoffset + 8.1, data.yoffset, 3, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs)
|
||||
fs("button", data.xoffset + 8.1, data.yoffset + 0.4, 3, 0.7, fmt("craft_%s", name),
|
||||
fs("scrollbar", data.inv_width + 8.1, data.yoffset, 3, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs)
|
||||
fs("button", data.inv_width + 8.1, data.yoffset + 0.4, 3, 0.7, fmt("craft_%s", name),
|
||||
ES("Craft (x@1)", stack_fs))
|
||||
end
|
||||
|
||||
local function get_rcp_extra(player, data, fs, panel, is_recipe, is_usage)
|
||||
local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
||||
fs("container[0,0.075]")
|
||||
local rn = panel.rcp and #panel.rcp
|
||||
|
||||
if rn then
|
||||
|
@ -1779,17 +1789,66 @@ local function get_rcp_extra(player, data, fs, panel, is_recipe, is_usage)
|
|||
get_rcp_lbl(fs, data, panel, rn, is_recipe)
|
||||
else
|
||||
local lbl = is_recipe and ES"No recipes" or ES"No usages"
|
||||
fs("button", data.xoffset + 0.1, data.yoffset + (panel.height / 2) - 0.5,
|
||||
fs("button", data.inv_width + 0.1, data.yoffset + (panel.height / 2) - 0.5,
|
||||
7.8, 1, "no_rcp", lbl)
|
||||
end
|
||||
|
||||
fs("container_end[]")
|
||||
end
|
||||
|
||||
local function get_items_fs(fs, data, extend)
|
||||
local rows = 8
|
||||
local lines = extend and 12 or 9
|
||||
local ipp = rows * lines
|
||||
local size = 0.85
|
||||
|
||||
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]")
|
||||
|
||||
fs("image_button", data.inv_width + 3.35, 0.35, 0.3, 0.3, "", "cancel", "")
|
||||
fs("image_button", data.inv_width + 3.85, 0.32, 0.35, 0.35, "", "search", "")
|
||||
fs("image_button", data.inv_width + 5.27, 0.3, 0.35, 0.35, "", "prev_page", "")
|
||||
fs("image_button", data.inv_width + 7.45, 0.3, 0.35, 0.35, "", "next_page", "")
|
||||
|
||||
data.pagemax = max(1, ceil(#data.items / ipp))
|
||||
|
||||
fs("button", data.inv_width + 5.6, 0.14, 1.88, 0.7, "pagenum",
|
||||
fmt("%s / %u", clr("#ff0", data.pagenum), data.pagemax))
|
||||
|
||||
if #data.items == 0 then
|
||||
local lbl = ES"No item to show"
|
||||
|
||||
if next(recipe_filters) and #init_items > 0 and data.filter == "" then
|
||||
lbl = ES"Collect items to reveal more recipes"
|
||||
end
|
||||
|
||||
fs("button", data.inv_width + 0.1, 3, 8, 1, "no_item", lbl)
|
||||
end
|
||||
|
||||
local first_item = (data.pagenum - 1) * ipp
|
||||
|
||||
for i = first_item, first_item + ipp - 1 do
|
||||
local item = data.items[i + 1]
|
||||
if not item then break end
|
||||
|
||||
local X = i % rows
|
||||
X = X - (X * 0.045) + data.inv_width + 0.28
|
||||
|
||||
local Y = round((i % ipp - X) / rows + 1, 0)
|
||||
Y = Y - (Y * (extend and 0.085 or 0.035)) + 0.95
|
||||
|
||||
fs[#fs + 1] = fmt("item_image_button", X, Y, size, size, item, fmt("%s_inv", item), "")
|
||||
end
|
||||
end
|
||||
|
||||
local function get_favs(fs, data)
|
||||
fs("label", data.xoffset + 0.4, data.yoffset + 0.4, ES"Bookmarks")
|
||||
fs("label", data.inv_width + 0.4, data.yoffset + 0.4, ES"Bookmarks")
|
||||
|
||||
for i = 1, #data.favs do
|
||||
local item = data.favs[i]
|
||||
local X = data.xoffset - 0.7 + (i * 1.2)
|
||||
local X = data.inv_width - 0.7 + (i * 1.2)
|
||||
local Y = data.yoffset + 0.8
|
||||
|
||||
if data.query_item == item then
|
||||
|
@ -1800,12 +1859,25 @@ local function get_favs(fs, data)
|
|||
end
|
||||
end
|
||||
|
||||
local function get_panels(player, data, fs)
|
||||
local function get_panels(player, data, fs, full_height)
|
||||
local _title = {name = "title", height = 1.4}
|
||||
local _favs = {name = "favs", height = 2.23}
|
||||
local _recipes = {name = "recipes", rcp = data.recipes, height = 3.9}
|
||||
local _usages = {name = "usages", rcp = data.usages, height = 3.9}
|
||||
local panels = {_title, _recipes, _usages, _favs}
|
||||
local _items = {name = "items", height = 9.69}
|
||||
local _recipes = {name = "recipes", rcp = data.recipes, height = 4.045}
|
||||
local _usages = {name = "usages", rcp = data.usages, height = 4.045}
|
||||
local panels, extend
|
||||
|
||||
if data.query_item then
|
||||
panels = {_title, _recipes, _usages, _favs}
|
||||
else
|
||||
panels = {_items, _favs}
|
||||
|
||||
if #data.favs == 0 then
|
||||
extend = true
|
||||
remove(panels, 2)
|
||||
_items.height = full_height
|
||||
end
|
||||
end
|
||||
|
||||
for idx = 1, #panels do
|
||||
local panel = panels[idx]
|
||||
|
@ -1817,12 +1889,14 @@ local function get_panels(player, data, fs)
|
|||
end
|
||||
end
|
||||
|
||||
fs("bg9", data.xoffset + 0.1, data.yoffset, 7.9, panel.height, PNG.bg_full, 10)
|
||||
fs("bg9", data.inv_width + 0.1, data.yoffset, 7.9, panel.height, PNG.bg_full, 10)
|
||||
|
||||
local is_recipe, is_usage = panel.name == "recipes", panel.name == "usages"
|
||||
|
||||
if is_recipe or is_usage then
|
||||
get_rcp_extra(player, data, fs, panel, is_recipe, is_usage)
|
||||
get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
||||
elseif panel.name == "items" then
|
||||
get_items_fs(fs, data, extend)
|
||||
elseif panel.name == "title" then
|
||||
get_header(fs, data)
|
||||
elseif panel.name == "favs" then
|
||||
|
@ -1955,7 +2029,7 @@ local function get_waypoint_fs(fs, data, name, yextra, ctn_len)
|
|||
fs("image_button", ctn_len - 1.5, yi, icon_size, icon_size, "", vsb, "")
|
||||
fs(fmt("tooltip[%s;%s]", vsb, v.hide and ES"Show waypoint" or ES"Hide waypoint"))
|
||||
|
||||
if core.is_creative_enabled(name) then
|
||||
if check_privs(name, {teleport = true}) then
|
||||
local tp = fmt("waypoint_%u_teleport", i)
|
||||
|
||||
fs(fmt("style[%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]",
|
||||
|
@ -2104,7 +2178,7 @@ local function get_tabs_fs(player, data, fs, full_height)
|
|||
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 X = (data.xoffset / 2) + (c * (tab_len + 0.1)) - ((tab_len + 0.05) * (shift / 2))
|
||||
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
|
||||
|
||||
fs("style_type[image_button:hovered;textcolor=#fff]")
|
||||
|
@ -2125,16 +2199,16 @@ end
|
|||
local function get_debug_grid(data, fs, full_height)
|
||||
local spacing = 0.2
|
||||
|
||||
for x = 0, data.xoffset, spacing do
|
||||
for x = 0, data.inv_width + 8, spacing do
|
||||
fs("box", x, 0, 0.01, full_height, "#ff0")
|
||||
end
|
||||
|
||||
for y = 0, full_height, spacing do
|
||||
fs("box", 0, y, data.xoffset, 0.01, "#ff0")
|
||||
fs("box", 0, y, data.inv_width + 8, 0.01, "#ff0")
|
||||
end
|
||||
|
||||
fs("box", data.xoffset / 2, 0, 0.01, full_height, "#f00")
|
||||
fs("box", 0, full_height / 2, data.xoffset, 0.01, "#f00")
|
||||
fs("box", data.inv_width / 2, 0, 0.01, full_height, "#f00")
|
||||
fs("box", 0, full_height / 2, data.inv_width, 0.01, "#f00")
|
||||
end
|
||||
|
||||
local function make_fs(player, data)
|
||||
|
@ -2153,27 +2227,25 @@ local function make_fs(player, data)
|
|||
end
|
||||
})
|
||||
|
||||
data.xoffset = ROWS + 1.23
|
||||
local full_height = LINES + 1.73
|
||||
data.inv_width = 10.23
|
||||
local full_height = 12
|
||||
|
||||
local tab = tabs[data.current_tab]
|
||||
local hide_panels = tab and tab.hide_panels and tab.hide_panels(player, data)
|
||||
local show_panels = data.query_item and tab and not hide_panels
|
||||
|
||||
fs(fmt("formspec_version[%u]size[%f,%f]no_prepend[]bgcolor[#0000]",
|
||||
MIN_FORMSPEC_VERSION, data.xoffset + (show_panels and 8 or 0), full_height), styles)
|
||||
MIN_FORMSPEC_VERSION, data.inv_width + 8, full_height), styles)
|
||||
|
||||
fs("bg9", 0, 0, data.xoffset, full_height, PNG.bg_full, 10)
|
||||
fs("bg9", 0, 0, data.inv_width, full_height, PNG.bg_full, 10)
|
||||
|
||||
if tab then
|
||||
tab.formspec(player, data, fs)
|
||||
end
|
||||
|
||||
if show_panels then
|
||||
get_panels(player, data, fs)
|
||||
end
|
||||
get_panels(player, data, fs, full_height)
|
||||
|
||||
get_tabs_fs(player, data, fs, full_height)
|
||||
if #tabs > 1 then
|
||||
get_tabs_fs(player, data, fs, full_height)
|
||||
end
|
||||
|
||||
--get_debug_grid(data, fs, full_height)
|
||||
--print("make_fs()", fmt("%.2f ms", (os.clock() - start) * 1000))
|
||||
|
@ -2315,11 +2387,41 @@ local function reset_data(data)
|
|||
data.items = data.items_raw
|
||||
end
|
||||
|
||||
local function panel_fields(player, data, fields)
|
||||
local function rcp_fields(player, data, fields)
|
||||
local name = player:get_player_name()
|
||||
local sb_rcp, sb_usg = fields.scrbar_rcp, fields.scrbar_usg
|
||||
|
||||
if fields.prev_recipe or fields.next_recipe then
|
||||
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
|
||||
if fields.filter == "" then
|
||||
reset_data(data)
|
||||
return set_fs(player)
|
||||
end
|
||||
|
||||
local str = lower(fields.filter)
|
||||
if data.filter == str then return end
|
||||
|
||||
data.filter = str
|
||||
data.pagenum = 1
|
||||
|
||||
search(data)
|
||||
|
||||
elseif fields.prev_page or fields.next_page then
|
||||
if data.pagemax == 1 then return end
|
||||
data.pagenum = data.pagenum - (fields.prev_page and 1 or -1)
|
||||
|
||||
if data.pagenum > data.pagemax then
|
||||
data.pagenum = 1
|
||||
elseif data.pagenum == 0 then
|
||||
data.pagenum = data.pagemax
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -2368,7 +2470,7 @@ local function panel_fields(player, data, fields)
|
|||
end
|
||||
|
||||
local function get_inv_slots(data, fs)
|
||||
local inv_x, inv_y = 0.22, 6.6
|
||||
local inv_x, inv_y = 0.22, 6.9
|
||||
local width, size, spacing = HOTBAR_COUNT, 1, 0.1
|
||||
local bag = data.bag_size
|
||||
|
||||
|
@ -2407,7 +2509,7 @@ local function get_inventory_fs(player, data, fs)
|
|||
local props = player:get_properties()
|
||||
local name = player:get_player_name()
|
||||
|
||||
local ctn_len, ctn_hgt = 5.7, 6
|
||||
local ctn_len, ctn_hgt = 5.7, 6.3
|
||||
local yoffset = 0
|
||||
|
||||
if props.mesh ~= "" then
|
||||
|
@ -2422,7 +2524,7 @@ local function get_inventory_fs(player, data, fs)
|
|||
local textures = concat(t, ","):gsub("!", ",")
|
||||
|
||||
--fs("style[player_model;bgcolor=black]")
|
||||
fs("model", 0.2, 0.2, armor_skin and 4 or 3.4, armor_skin and ctn_hgt or 5.8,
|
||||
fs("model", 0.2, 0.2, armor_skin and 4 or 3.4, armor_skin and ctn_hgt or 6.1,
|
||||
"player_model", props.mesh, textures, "0,-150", "false", "false",
|
||||
fmt("%u,%u", anim.x, anim.y))
|
||||
else
|
||||
|
@ -2432,7 +2534,7 @@ local function get_inventory_fs(player, data, fs)
|
|||
|
||||
local award_list, award_list_nb
|
||||
local awards_unlocked = 0
|
||||
local max_val = 15
|
||||
local max_val = 12
|
||||
|
||||
if __3darmor and data.subcat == 2 then
|
||||
if data.scrbar_inv >= max_val then
|
||||
|
@ -2491,56 +2593,11 @@ local function get_inventory_fs(player, data, fs)
|
|||
fs(fmt("style[%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]",
|
||||
btn_name, PNG[btn_name], PNG[fmt("%s_hover", btn_name)]))
|
||||
|
||||
fs("image_button", i + 3.447 - (i * 0.4), 11.13, 0.35, 0.35, "", btn_name, "")
|
||||
fs("image_button", i + 3.447 - (i * 0.4), 11.43, 0.35, 0.35, "", btn_name, "")
|
||||
fs(fmt("tooltip[%s;%s]", btn_name, tooltip))
|
||||
end
|
||||
end
|
||||
|
||||
local function get_items_fs(_, data, fs)
|
||||
fs("box[0.2,0.2;4.55,0.6;#bababa25]", "set_focus[filter]",
|
||||
fmt("field[0.3,0.2;3.45,0.6;filter;;%s]", ESC(data.filter)),
|
||||
"field_close_on_enter[filter;false]")
|
||||
|
||||
fs("image_button", 3.75, 0.35, 0.3, 0.3, "", "cancel", "")
|
||||
fs("image_button", 4.25, 0.32, 0.35, 0.35, "", "search", "")
|
||||
fs("image_button", data.xoffset - 2.73, 0.3, 0.35, 0.35, "", "prev_page", "")
|
||||
fs("image_button", data.xoffset - 0.55, 0.3, 0.35, 0.35, "", "next_page", "")
|
||||
|
||||
data.pagemax = max(1, ceil(#data.items / IPP))
|
||||
|
||||
fs("button", data.xoffset - 2.4, 0.14, 1.88, 0.7, "pagenum",
|
||||
fmt("%s / %u", clr("#ff0", data.pagenum), data.pagemax))
|
||||
|
||||
if #data.items == 0 then
|
||||
local lbl = ES"No item to show"
|
||||
|
||||
if next(recipe_filters) and #init_items > 0 and data.filter == "" then
|
||||
lbl = ES"Collect items to reveal more recipes"
|
||||
end
|
||||
|
||||
fs("button", 0, 3, data.xoffset, 1, "no_item", lbl)
|
||||
end
|
||||
|
||||
local first_item = (data.pagenum - 1) * IPP
|
||||
|
||||
for i = first_item, first_item + IPP - 1 do
|
||||
local item = data.items[i + 1]
|
||||
if not item then break end
|
||||
|
||||
local X = i % ROWS
|
||||
X = X + (X * 0.1) + 0.2
|
||||
|
||||
local Y = floor((i % IPP - X) / ROWS + 1)
|
||||
Y = Y + (Y * 0.06) + 1
|
||||
|
||||
if data.query_item == item then
|
||||
fs("image", X, Y, 1, 1, PNG.slot)
|
||||
end
|
||||
|
||||
fs[#fs + 1] = fmt("item_image_button", X, Y, 1, 1, item, fmt("%s_inv", item), "")
|
||||
end
|
||||
end
|
||||
|
||||
i3.new_tab {
|
||||
name = "inventory",
|
||||
description = S"Inventory",
|
||||
|
@ -2550,10 +2607,6 @@ i3.new_tab {
|
|||
local name = player:get_player_name()
|
||||
local sb_inv = fields.scrbar_inv
|
||||
|
||||
if not core.is_creative_enabled(name) then
|
||||
panel_fields(player, data, fields)
|
||||
end
|
||||
|
||||
if fields.skins and data.skin_id ~= tonum(fields.skins) then
|
||||
data.skin_id = tonum(fields.skins)
|
||||
local _skins = skins.get_skinlist_for_player(name)
|
||||
|
@ -2650,51 +2703,6 @@ i3.new_tab {
|
|||
|
||||
return set_fs(player)
|
||||
end,
|
||||
|
||||
hide_panels = function(player)
|
||||
local name = player:get_player_name()
|
||||
return core.is_creative_enabled(name)
|
||||
end,
|
||||
}
|
||||
|
||||
i3.new_tab {
|
||||
name = "items",
|
||||
description = S"Items",
|
||||
formspec = get_items_fs,
|
||||
|
||||
fields = function(player, data, fields)
|
||||
panel_fields(player, data, fields)
|
||||
|
||||
if fields.cancel then
|
||||
reset_data(data)
|
||||
|
||||
elseif fields.key_enter_field == "filter" or fields.search then
|
||||
if fields.filter == "" then
|
||||
reset_data(data)
|
||||
return set_fs(player)
|
||||
end
|
||||
|
||||
local str = lower(fields.filter)
|
||||
if data.filter == str then return end
|
||||
|
||||
data.filter = str
|
||||
data.pagenum = 1
|
||||
|
||||
search(data)
|
||||
|
||||
elseif fields.prev_page or fields.next_page then
|
||||
if data.pagemax == 1 then return end
|
||||
data.pagenum = data.pagenum - (fields.prev_page and 1 or -1)
|
||||
|
||||
if data.pagenum > data.pagemax then
|
||||
data.pagenum = 1
|
||||
elseif data.pagenum == 0 then
|
||||
data.pagenum = data.pagemax
|
||||
end
|
||||
end
|
||||
|
||||
return set_fs(player)
|
||||
end,
|
||||
}
|
||||
|
||||
local trash = create_inventory("i3_trash", {
|
||||
|
@ -2764,7 +2772,20 @@ if rawget(_G, "awards") then
|
|||
core.register_on_dieplayer(set_fs)
|
||||
end
|
||||
|
||||
core.register_on_chatcommand(function(name)
|
||||
core.register_on_chatcommand(function(name, command, params)
|
||||
if sub(command, 1, 5) == "grant" then
|
||||
params = split(params, " ")
|
||||
|
||||
for _, v in ipairs(params) do
|
||||
if find(v, "creative") then
|
||||
local data = pdata[name]
|
||||
reset_data(data)
|
||||
data.favs = {}
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local player = core.get_player_by_name(name)
|
||||
after(0, set_fs, player)
|
||||
end)
|
||||
|
@ -3096,6 +3117,8 @@ on_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
end
|
||||
|
||||
rcp_fields(player, data, fields)
|
||||
|
||||
local tab = tabs[data.current_tab]
|
||||
|
||||
if tab and tab.fields then
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
|
@ -12,6 +12,20 @@ default = {}
|
|||
default.LIGHT_MAX = 14
|
||||
default.get_translator = S
|
||||
|
||||
-- Check for engine features required by MTG
|
||||
-- This provides clear error behaviour when MTG is newer than the installed engine
|
||||
-- and avoids obscure, hard to debug runtime errors.
|
||||
-- This section should be updated before release and older checks can be dropped
|
||||
-- when newer ones are introduced.
|
||||
if not minetest.is_creative_enabled or not minetest.has_feature({
|
||||
direct_velocity_on_players = true,
|
||||
use_texture_alpha_string_modes = true,
|
||||
}) then
|
||||
error("\nThis version of Minetest Game is incompatible with your engine version "..
|
||||
"(which is too old). You should download a version of Minetest Game that "..
|
||||
"matches the installed engine version.\n")
|
||||
end
|
||||
|
||||
-- GUI related stuff
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
-- Set formspec prepend
|
||||
|
|
|
@ -262,3 +262,7 @@ Mod: LessDirt/default
|
|||
origin https://github.com/Treer/LessDirt.git (fetch)
|
||||
* master 59d4434 [origin/master] Update forum link in README.md
|
||||
Mod: LessDirt/default
|
||||
|
||||
origin https://github.com/Treer/LessDirt.git (fetch)
|
||||
* master 59d4434 [origin/master] Update forum link in README.md
|
||||
Mod: LessDirt/default
|
||||
|
|
Loading…
Reference in New Issue