mirror of
https://github.com/minetest-mods/craftguide.git
synced 2025-06-29 14:40:49 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
189a3ff971 | |||
ca723202d6 | |||
a3e7031c04 |
50
init.lua
50
init.lua
@ -76,9 +76,11 @@ local PNG = {
|
|||||||
next = "craftguide_next_icon.png",
|
next = "craftguide_next_icon.png",
|
||||||
arrow = "craftguide_arrow.png",
|
arrow = "craftguide_arrow.png",
|
||||||
fire = "craftguide_fire.png",
|
fire = "craftguide_fire.png",
|
||||||
|
fire_anim = "craftguide_fire_anim.png",
|
||||||
book = "craftguide_book.png",
|
book = "craftguide_book.png",
|
||||||
sign = "craftguide_sign.png",
|
sign = "craftguide_sign.png",
|
||||||
selected = "craftguide_selected.png",
|
selected = "craftguide_selected.png",
|
||||||
|
furnace_anim = "craftguide_furnace_anim.png",
|
||||||
|
|
||||||
search_hover = "craftguide_search_icon_hover.png",
|
search_hover = "craftguide_search_icon_hover.png",
|
||||||
clear_hover = "craftguide_clear_icon_hover.png",
|
clear_hover = "craftguide_clear_icon_hover.png",
|
||||||
@ -94,6 +96,7 @@ local FMT = {
|
|||||||
tooltip = "tooltip[%f,%f;%f,%f;%s]",
|
tooltip = "tooltip[%f,%f;%f,%f;%s]",
|
||||||
item_image = "item_image[%f,%f;%f,%f;%s]",
|
item_image = "item_image[%f,%f;%f,%f;%s]",
|
||||||
image_button = "image_button[%f,%f;%f,%f;%s;%s;%s]",
|
image_button = "image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
|
animated_image = "animated_image[%f,%f;%f,%f;%s:%u,%u]",
|
||||||
item_image_button = "item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
item_image_button = "item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
arrow = "image_button[%f,%f;0.8,0.8;%s;%s;;;false;%s]",
|
arrow = "image_button[%f,%f;0.8,0.8;%s;%s;;;false;%s]",
|
||||||
}
|
}
|
||||||
@ -722,7 +725,12 @@ local function get_output_fs(data, fs, L)
|
|||||||
local pos_x = L.rightest + L.btn_size + 0.1
|
local pos_x = L.rightest + L.btn_size + 0.1
|
||||||
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45)
|
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45)
|
||||||
|
|
||||||
|
if data.fs_version >= 3 and sub(icon, 1, 18) == "craftguide_furnace" then
|
||||||
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
||||||
|
pos_x, pos_y + L.spacing, 0.5, 0.5, PNG.furnace_anim, 8, 180)
|
||||||
|
else
|
||||||
fs[#fs + 1] = fmt(FMT.image, pos_x, pos_y + L.spacing, 0.5, 0.5, icon)
|
fs[#fs + 1] = fmt(FMT.image, pos_x, pos_y + L.spacing, 0.5, 0.5, icon)
|
||||||
|
end
|
||||||
|
|
||||||
local tooltip = custom_recipe and custom_recipe.description or
|
local tooltip = custom_recipe and custom_recipe.description or
|
||||||
L.shapeless and S"Shapeless" or S"Cooking"
|
L.shapeless and S"Shapeless" or S"Cooking"
|
||||||
@ -738,9 +746,15 @@ local function get_output_fs(data, fs, L)
|
|||||||
0.9, 0.7, PNG.arrow)
|
0.9, 0.7, PNG.arrow)
|
||||||
|
|
||||||
if L.recipe.type == "fuel" then
|
if L.recipe.type == "fuel" then
|
||||||
|
if data.fs_version >= 3 then
|
||||||
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
||||||
|
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
|
||||||
|
1.1, 1.1, PNG.fire_anim, 8, 180)
|
||||||
|
else
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.image,
|
||||||
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
|
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
|
||||||
1.1, 1.1, PNG.fire)
|
1.1, 1.1, PNG.fire)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local item = L.recipe.output
|
local item = L.recipe.output
|
||||||
item = clean_name(item)
|
item = clean_name(item)
|
||||||
@ -774,12 +788,18 @@ local function get_output_fs(data, fs, L)
|
|||||||
output_X + 1, YOFFSET + (sfinv_only and 0.7 or 0.1) + L.spacing,
|
output_X + 1, YOFFSET + (sfinv_only and 0.7 or 0.1) + L.spacing,
|
||||||
0.6, 0.4, PNG.arrow)
|
0.6, 0.4, PNG.arrow)
|
||||||
|
|
||||||
|
if data.fs_version >= 3 then
|
||||||
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
||||||
|
output_X + 1.6, YOFFSET + (sfinv_only and 0.55 or 0) + L.spacing,
|
||||||
|
0.6, 0.6, PNG.fire_anim, 8, 180)
|
||||||
|
else
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.image,
|
||||||
output_X + 1.6, YOFFSET + (sfinv_only and 0.55 or 0) + L.spacing,
|
output_X + 1.6, YOFFSET + (sfinv_only and 0.55 or 0) + L.spacing,
|
||||||
0.6, 0.6, PNG.fire)
|
0.6, 0.6, PNG.fire)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function get_grid_fs(data, fs, rcp, spacing)
|
local function get_grid_fs(data, fs, rcp, spacing)
|
||||||
local width = rcp.width or 1
|
local width = rcp.width or 1
|
||||||
@ -1032,10 +1052,12 @@ local function make_fs(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = fmt([[
|
||||||
field[0.25,0.2;%f,1;filter;;%s]
|
style[filter;border=false]
|
||||||
|
field[0.4,0.2;2.5,1;filter;;%s]
|
||||||
field_close_on_enter[filter;false]
|
field_close_on_enter[filter;false]
|
||||||
|
box[0,0;2.4,0.6;#ffffff25]
|
||||||
]],
|
]],
|
||||||
sfinv_only and 2.76 or 2.72, ESC(data.filter))
|
ESC(data.filter))
|
||||||
|
|
||||||
if data.fs_version >= 3 then
|
if data.fs_version >= 3 then
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = fmt([[
|
||||||
@ -1138,16 +1160,6 @@ craftguide.register_craft_type("digging_chance", {
|
|||||||
icon = "default_tool_mesepick.png",
|
icon = "default_tool_mesepick.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
local function sfind(str, filter)
|
|
||||||
if filter == "" then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if find(str, filter, 1, true) then
|
|
||||||
return #str - #filter
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function search(data)
|
local function search(data)
|
||||||
local filter = data.filter
|
local filter = data.filter
|
||||||
|
|
||||||
@ -1169,28 +1181,30 @@ local function search(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local filtered_list, order, c = {}, {}, 0
|
local filtered_list, c = {}, 0
|
||||||
|
|
||||||
for i = 1, #data.items_raw do
|
for i = 1, #data.items_raw do
|
||||||
local item = data.items_raw[i]
|
local item = data.items_raw[i]
|
||||||
local def = reg_items[item]
|
local def = reg_items[item]
|
||||||
local desc = (def and def.description) and lower(def.description) or ""
|
local desc = (def and def.description) and lower(def.description) or ""
|
||||||
|
local search_in = fmt("%s %s", item, desc)
|
||||||
local to_add
|
local to_add
|
||||||
|
|
||||||
if search_filter then
|
if search_filter then
|
||||||
for filter_name, values in pairs(filters) do
|
for filter_name, values in pairs(filters) do
|
||||||
|
if values then
|
||||||
local func = search_filters[filter_name]
|
local func = search_filters[filter_name]
|
||||||
to_add = func(item, values) and (search_filter == "" or
|
to_add = func(item, values) and (search_filter == "" or
|
||||||
(sfind(item, search_filter) or sfind(desc, search_filter)))
|
find(search_in, search_filter, 1, true))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
to_add = sfind(item, filter) or sfind(desc, filter)
|
to_add = find(search_in, filter, 1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if to_add then
|
if to_add then
|
||||||
c = c + 1
|
c = c + 1
|
||||||
filtered_list[c] = item
|
filtered_list[c] = item
|
||||||
order[item] = to_add
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1203,10 +1217,6 @@ local function search(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sort(filtered_list, function(a, b)
|
|
||||||
return order[a] < order[b]
|
|
||||||
end)
|
|
||||||
|
|
||||||
data.items = filtered_list
|
data.items = filtered_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
BIN
textures/craftguide_fire_anim.png
Normal file
BIN
textures/craftguide_fire_anim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
BIN
textures/craftguide_furnace_anim.png
Normal file
BIN
textures/craftguide_furnace_anim.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Reference in New Issue
Block a user