|
|
@ -64,9 +64,11 @@ local vec_add, vec_mul = vector.add, vector.multiply
|
|
|
|
local FORMSPEC_MINIMAL_VERSION = 3
|
|
|
|
local FORMSPEC_MINIMAL_VERSION = 3
|
|
|
|
|
|
|
|
|
|
|
|
local ROWS = 9
|
|
|
|
local ROWS = 9
|
|
|
|
local LINES = sfinv_only and 5 or 9
|
|
|
|
local LINES = sfinv_only and 5 or 10
|
|
|
|
local IPP = ROWS * LINES
|
|
|
|
local IPP = ROWS * LINES
|
|
|
|
local WH_LIMIT = 8
|
|
|
|
local WH_LIMIT = 5
|
|
|
|
|
|
|
|
local MAX_FAVS = 6
|
|
|
|
|
|
|
|
local ITEM_BTN_SIZE = 1.1
|
|
|
|
|
|
|
|
|
|
|
|
local XOFFSET = sfinv_only and 3.83 or 11.2
|
|
|
|
local XOFFSET = sfinv_only and 3.83 or 11.2
|
|
|
|
local YOFFSET = sfinv_only and 4.9 or 1
|
|
|
|
local YOFFSET = sfinv_only and 4.9 or 1
|
|
|
@ -778,26 +780,44 @@ local function get_tooltip(name, info)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if info.rarity then
|
|
|
|
if info.rarity then
|
|
|
|
local chance = (1 / info.rarity) * 100
|
|
|
|
local chance = (1 / max(1, info.rarity)) * 100
|
|
|
|
tooltip = add(S("@1 of chance to drop", clr("#ff0", chance .. "%")))
|
|
|
|
tooltip = add(S("@1 of chance to drop", clr("#ff0", chance .. "%")))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if info.tools then
|
|
|
|
|
|
|
|
local several = #info.tools > 1
|
|
|
|
|
|
|
|
local names = several and "\n" or ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if several then
|
|
|
|
|
|
|
|
for i = 1, #info.tools do
|
|
|
|
|
|
|
|
names = fmt("%s\t\t- %s\n",
|
|
|
|
|
|
|
|
names, clr("#ff0", get_desc(info.tools[i])))
|
|
|
|
|
|
|
|
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]))))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return fmt("tooltip[%s;%s]", name, ESC(tooltip))
|
|
|
|
return fmt("tooltip[%s;%s]", name, ESC(tooltip))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function get_output_fs(data, fs, L)
|
|
|
|
local function get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_size, spacing)
|
|
|
|
local custom_recipe = craft_types[L.recipe.type]
|
|
|
|
local custom_recipe = craft_types[rcp.type]
|
|
|
|
|
|
|
|
|
|
|
|
if custom_recipe or L.shapeless or L.recipe.type == "cooking" then
|
|
|
|
if custom_recipe or shapeless or rcp.type == "cooking" then
|
|
|
|
local icon = custom_recipe and custom_recipe.icon or
|
|
|
|
local icon = custom_recipe and custom_recipe.icon or
|
|
|
|
L.shapeless and "shapeless" or "furnace"
|
|
|
|
shapeless and "shapeless" or "furnace"
|
|
|
|
|
|
|
|
|
|
|
|
if not custom_recipe then
|
|
|
|
if not custom_recipe then
|
|
|
|
icon = fmt("craftguide_%s.png^[resize:16x16", icon)
|
|
|
|
icon = fmt("craftguide_%s.png^[resize:16x16", icon)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local pos_x = L.rightest + L.btn_size + 0.1
|
|
|
|
local pos_x = right + btn_size + 0.1
|
|
|
|
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45) + L.spacing
|
|
|
|
local pos_y = YOFFSET + (sfinv_only and 1.55 or -0.45) + spacing
|
|
|
|
|
|
|
|
|
|
|
|
if sub(icon, 1, 18) == "craftguide_furnace" then
|
|
|
|
if sub(icon, 1, 18) == "craftguide_furnace" then
|
|
|
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
|
|
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
|
|
@ -807,30 +827,32 @@ local function get_output_fs(data, fs, L)
|
|
|
|
end
|
|
|
|
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"
|
|
|
|
shapeless and S"Shapeless" or S"Cooking"
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
|
|
|
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local arrow_X = L.rightest + (L._btn_size or 1.1)
|
|
|
|
local arrow_X = right + (_btn_size or ITEM_BTN_SIZE)
|
|
|
|
local output_X = arrow_X + 0.9
|
|
|
|
local output_X = arrow_X + 0.9
|
|
|
|
local Y = YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing
|
|
|
|
local Y = YOFFSET + (sfinv_only and 2 or 0) + spacing
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
|
|
|
|
|
|
|
|
|
|
|
|
if L.recipe.type == "fuel" then
|
|
|
|
if rcp.type == "fuel" then
|
|
|
|
fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y, 1.1, 1.1, PNG.fire_anim, 8, 180)
|
|
|
|
fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y,
|
|
|
|
|
|
|
|
ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.fire_anim, 8, 180)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
local item = L.recipe.output
|
|
|
|
local item = rcp.output
|
|
|
|
item = clean_name(item)
|
|
|
|
item = clean_name(item)
|
|
|
|
local name = match(item, "%S*")
|
|
|
|
local name = match(item, "%S*")
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, output_X, Y, 1.1, 1.1, PNG.selected)
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, output_X, Y,
|
|
|
|
|
|
|
|
ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.selected)
|
|
|
|
|
|
|
|
|
|
|
|
local _name = sfinv_only and name or fmt("_%s", name)
|
|
|
|
local _name = sfinv_only and name or fmt("_%s", name)
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
|
|
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
|
|
|
output_X, Y, 1.1, 1.1, item, _name, "")
|
|
|
|
output_X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, _name, "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local def = reg_items[name]
|
|
|
|
local def = reg_items[name]
|
|
|
@ -839,7 +861,8 @@ local function get_output_fs(data, fs, L)
|
|
|
|
unknown = not def or nil,
|
|
|
|
unknown = not def or nil,
|
|
|
|
burntime = fuel_cache[name],
|
|
|
|
burntime = fuel_cache[name],
|
|
|
|
repair = repairable(name),
|
|
|
|
repair = repairable(name),
|
|
|
|
rarity = L.rarity,
|
|
|
|
rarity = rcp.rarity,
|
|
|
|
|
|
|
|
tools = rcp.tools,
|
|
|
|
newline = check_newline(def),
|
|
|
|
newline = check_newline(def),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -849,11 +872,11 @@ local function get_output_fs(data, fs, L)
|
|
|
|
|
|
|
|
|
|
|
|
if infos.burntime then
|
|
|
|
if infos.burntime then
|
|
|
|
fs[#fs + 1] = fmt(FMT.image,
|
|
|
|
fs[#fs + 1] = fmt(FMT.image,
|
|
|
|
output_X + 1, YOFFSET + (sfinv_only and 0.7 or 0.1) + L.spacing,
|
|
|
|
output_X + 1, YOFFSET + (sfinv_only and 2 or 0.1) + spacing,
|
|
|
|
0.6, 0.4, PNG.arrow)
|
|
|
|
0.6, 0.4, PNG.arrow)
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
|
|
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
|
|
|
output_X + 1.6, YOFFSET + (sfinv_only and 0.55 or 0) + L.spacing,
|
|
|
|
output_X + 1.6, YOFFSET + (sfinv_only and 1.85 or 0) + spacing,
|
|
|
|
0.6, 0.6, PNG.fire_anim, 8, 180)
|
|
|
|
0.6, 0.6, PNG.fire_anim, 8, 180)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -861,9 +884,7 @@ 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
|
|
|
|
local replacements = rcp.replacements
|
|
|
|
local right, btn_size, _btn_size = 0, ITEM_BTN_SIZE
|
|
|
|
local rarity = rcp.rarity
|
|
|
|
|
|
|
|
local rightest, btn_size, _btn_size = 0, 1.1
|
|
|
|
|
|
|
|
local cooktime, shapeless
|
|
|
|
local cooktime, shapeless
|
|
|
|
|
|
|
|
|
|
|
|
if rcp.type == "cooking" then
|
|
|
|
if rcp.type == "cooking" then
|
|
|
@ -900,22 +921,15 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|
|
|
local Y = ceil(i / width) + YOFFSET - min(2, rows) + spacing
|
|
|
|
local Y = ceil(i / width) + YOFFSET - min(2, rows) + spacing
|
|
|
|
|
|
|
|
|
|
|
|
if large_recipe then
|
|
|
|
if large_recipe then
|
|
|
|
local xof = 1 - 4 / width
|
|
|
|
btn_size = width > 3 and 3 / width or 3 / rows
|
|
|
|
local yof = 1 - 4 / rows
|
|
|
|
|
|
|
|
local x_y = width > rows and xof or yof
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btn_size = width > rows and
|
|
|
|
|
|
|
|
(3.5 + (xof * 2)) / width or (3.5 + (yof * 2)) / rows
|
|
|
|
|
|
|
|
_btn_size = btn_size
|
|
|
|
_btn_size = btn_size
|
|
|
|
|
|
|
|
|
|
|
|
X = (btn_size * ((i - 1) % width) + XOFFSET -
|
|
|
|
X = btn_size * ((i - 1) % width) + XOFFSET - 2.65
|
|
|
|
(sfinv_only and 2.83 or 0)) * (0.83 - (x_y / 5))
|
|
|
|
Y = btn_size * floor((i - 1) / width) + spacing + (sfinv and 4 or 0)
|
|
|
|
Y = (btn_size * floor((i - 1) / width) +
|
|
|
|
|
|
|
|
(sfinv_only and 5.81 or 3.92) + x_y) * (0.86 - (x_y / 5))
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if X > rightest then
|
|
|
|
if X > right then
|
|
|
|
rightest = X
|
|
|
|
right = X
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local groups
|
|
|
|
local groups
|
|
|
@ -928,9 +942,9 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|
|
|
local label = groups and "\nG" or ""
|
|
|
|
local label = groups and "\nG" or ""
|
|
|
|
local replace
|
|
|
|
local replace
|
|
|
|
|
|
|
|
|
|
|
|
if replacements then
|
|
|
|
if rcp.replacements then
|
|
|
|
for j = 1, #replacements do
|
|
|
|
for j = 1, #rcp.replacements do
|
|
|
|
local replacement = replacements[j]
|
|
|
|
local replacement = rcp.replacements[j]
|
|
|
|
if replacement[1] == name then
|
|
|
|
if replacement[1] == name then
|
|
|
|
label = (label ~= "" and "\n" or "") .. label .. "\nR"
|
|
|
|
label = (label ~= "" and "\n" or "") .. label .. "\nR"
|
|
|
|
replace = replacement[2]
|
|
|
|
replace = replacement[2]
|
|
|
@ -938,7 +952,7 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
Y = Y + (sfinv_only and 0.7 or 0)
|
|
|
|
Y = Y + (sfinv_only and 2 or 0)
|
|
|
|
|
|
|
|
|
|
|
|
if not large_recipe then
|
|
|
|
if not large_recipe then
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, btn_size, btn_size, PNG.selected)
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, btn_size, btn_size, PNG.selected)
|
|
|
@ -967,79 +981,13 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|
|
|
fs[#fs + 1] = "style_type[item_image_button;border=false]"
|
|
|
|
fs[#fs + 1] = "style_type[item_image_button;border=false]"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
get_output_fs(data, fs, {
|
|
|
|
get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_size, spacing)
|
|
|
|
recipe = rcp,
|
|
|
|
|
|
|
|
shapeless = shapeless,
|
|
|
|
|
|
|
|
rightest = rightest,
|
|
|
|
|
|
|
|
btn_size = btn_size,
|
|
|
|
|
|
|
|
_btn_size = _btn_size,
|
|
|
|
|
|
|
|
spacing = spacing,
|
|
|
|
|
|
|
|
rarity = rarity,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function get_panels(data, fs)
|
|
|
|
local function get_rcp_lbl(data, fs, panel, spacing, rn, is_recipe)
|
|
|
|
local start_y = sfinv_only and 0.33 or 0
|
|
|
|
local lbl
|
|
|
|
|
|
|
|
|
|
|
|
local panels = {
|
|
|
|
if (not sfinv_only and is_recipe) or
|
|
|
|
{dat = data.usages or {}, height = 3.5},
|
|
|
|
|
|
|
|
{dat = data.recipes or {}, height = 3.5},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not sfinv_only then
|
|
|
|
|
|
|
|
panels.favs = {height = 2.19}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
panels = data.show_usages and {{dat = data.usages}} or {{dat = data.recipes}}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for k, v in pairs(panels) do
|
|
|
|
|
|
|
|
start_y = start_y + 1
|
|
|
|
|
|
|
|
local spacing = (start_y - 1) * 3.6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not sfinv_only then
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("background9[8.1,%f;6.6,%f;%s;false;%d]",
|
|
|
|
|
|
|
|
-0.2 + spacing, v.height, PNG.bg_full, 10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if k == 2 then
|
|
|
|
|
|
|
|
local fav = is_fav(data)
|
|
|
|
|
|
|
|
local nfavs = #data.favs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(
|
|
|
|
|
|
|
|
"style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
|
|
|
|
|
|
|
fmt("craftguide_fav%s.png", fav and "" or "_off"),
|
|
|
|
|
|
|
|
fmt("craftguide_fav%s.png", fav and "_off" or ""),
|
|
|
|
|
|
|
|
fmt("craftguide_fav%s.png", fav and "_off" or ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if nfavs < 6 or (nfavs >= 6 and fav) then
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image_button,
|
|
|
|
|
|
|
|
14, spacing, 0.5, 0.45, "", "fav", "")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("tooltip[fav;%s]",
|
|
|
|
|
|
|
|
fav and ES"Unmark this item" or ES"Mark this item")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local rn = v.dat and #v.dat or -1
|
|
|
|
|
|
|
|
local _rn = tostring(rn)
|
|
|
|
|
|
|
|
local xu = tostring(data.unum) .. _rn
|
|
|
|
|
|
|
|
local xr = tostring(data.rnum) .. _rn
|
|
|
|
|
|
|
|
xu = max(-0.3, -((#xu - 3) * 0.05))
|
|
|
|
|
|
|
|
xr = max(-0.3, -((#xr - 3) * 0.05))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local is_recipe = sfinv_only and not data.show_usages or k == 2
|
|
|
|
|
|
|
|
local lbl = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not sfinv_only and rn == 0 then
|
|
|
|
|
|
|
|
local X = XOFFSET - 0.7
|
|
|
|
|
|
|
|
local Y = YOFFSET - 0.4 + spacing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 2, 2, PNG.nothing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.tooltip,
|
|
|
|
|
|
|
|
X, Y, 2, 2, is_recipe and ES"No recipes" or ES"No usages")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif (not sfinv_only and is_recipe) or
|
|
|
|
|
|
|
|
(sfinv_only and not data.show_usages) then
|
|
|
|
(sfinv_only and not data.show_usages) then
|
|
|
|
lbl = ES("Recipe @1 of @2", data.rnum, rn)
|
|
|
|
lbl = ES("Recipe @1 of @2", data.rnum, rn)
|
|
|
|
|
|
|
|
|
|
|
@ -1052,6 +1000,12 @@ local function get_panels(data, fs)
|
|
|
|
ES("Recipe @1 of @2", data.rnum, rn)
|
|
|
|
ES("Recipe @1 of @2", data.rnum, rn)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local _rn = tostring(rn)
|
|
|
|
|
|
|
|
local xu = tostring(data.unum) .. _rn
|
|
|
|
|
|
|
|
local xr = tostring(data.rnum) .. _rn
|
|
|
|
|
|
|
|
xu = max(-0.3, -((#xu - 3) * 0.05))
|
|
|
|
|
|
|
|
xr = max(-0.3, -((#xr - 3) * 0.05))
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.label,
|
|
|
|
fs[#fs + 1] = fmt(FMT.label,
|
|
|
|
XOFFSET + (sfinv_only and 2.3 or 1.6) + (is_recipe and xr or xu),
|
|
|
|
XOFFSET + (sfinv_only and 2.3 or 1.6) + (is_recipe and xr or xu),
|
|
|
|
YOFFSET + (sfinv_only and 3.4 or 1.5 + spacing), lbl)
|
|
|
|
YOFFSET + (sfinv_only and 3.4 or 1.5 + spacing), lbl)
|
|
|
@ -1063,31 +1017,122 @@ local function get_panels(data, fs)
|
|
|
|
local x_arrow = XOFFSET + (sfinv_only and 1.7 or 1)
|
|
|
|
local x_arrow = XOFFSET + (sfinv_only and 1.7 or 1)
|
|
|
|
local y_arrow = YOFFSET + (sfinv_only and 3.3 or 1.4 + spacing)
|
|
|
|
local y_arrow = YOFFSET + (sfinv_only and 3.3 or 1.4 + spacing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt([[
|
|
|
|
|
|
|
|
style[%s;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
|
|
|
|
|
|
|
style[%s;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]
|
|
|
|
|
|
|
|
]],
|
|
|
|
|
|
|
|
prev_name, PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
|
|
|
|
|
|
|
next_name, PNG.next, PNG.next_hover, PNG.next_hover)
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
|
|
|
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
|
|
|
x_arrow + (is_recipe and xr or xu), y_arrow,
|
|
|
|
x_arrow + (is_recipe and xr or xu), y_arrow,
|
|
|
|
PNG.prev, prev_name, "",
|
|
|
|
PNG.prev, prev_name, "",
|
|
|
|
x_arrow + 1.8, y_arrow, PNG.next, next_name, "")
|
|
|
|
x_arrow + 1.8, y_arrow, PNG.next, next_name, "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local rcp = v.dat and (is_recipe and v.dat[data.rnum] or v.dat[data.unum])
|
|
|
|
local rcp = is_recipe and panel.rcp[data.rnum] or panel.rcp[data.unum]
|
|
|
|
if rcp then
|
|
|
|
|
|
|
|
get_grid_fs(data, fs, rcp, spacing)
|
|
|
|
get_grid_fs(data, fs, rcp, spacing)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if k == "favs" and not sfinv_only then
|
|
|
|
local function get_title_fs(data, fs, spacing)
|
|
|
|
fs[#fs + 1] = fmt(FMT.label, 8.3, spacing - 0.1, ES"Bookmarks")
|
|
|
|
local desc = ESC(get_desc(data.query_item))
|
|
|
|
|
|
|
|
desc = #desc > 33 and fmt("%s...", sub(desc, 1, 30)) or desc
|
|
|
|
|
|
|
|
local t_desc = data.query_item
|
|
|
|
|
|
|
|
t_desc = #t_desc > 40 and fmt("%s...", sub(t_desc, 1, 37)) or t_desc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("hypertext[9.05,%f;5.85,1.2;item_title;%s]",
|
|
|
|
|
|
|
|
spacing - 0.1,
|
|
|
|
|
|
|
|
fmt("<item name=%s float=right width=64 height=64 rotate=yes>" ..
|
|
|
|
|
|
|
|
"<big><b>%s</b></big>\n<style color=#7bf font=mono>%s</style>",
|
|
|
|
|
|
|
|
data.query_item, desc, t_desc))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local fav = is_fav(data)
|
|
|
|
|
|
|
|
local nfavs = #data.favs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if nfavs < MAX_FAVS or (nfavs == MAX_FAVS and fav) then
|
|
|
|
|
|
|
|
local fav_marked = fmt("craftguide_fav%s.png", fav and "_off" or "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(
|
|
|
|
|
|
|
|
"style[fav;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
|
|
|
|
|
|
|
fmt("craftguide_fav%s.png", fav and "" or "_off"), fav_marked, fav_marked)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image_button, 8.25, spacing + 0.15, 0.5, 0.45, "", "fav", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("tooltip[fav;%s]",
|
|
|
|
|
|
|
|
fav and ES"Unmark this item" or ES"Mark this item")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(
|
|
|
|
|
|
|
|
"style[fav_no;fgimg=%s;fgimg_hovered=%s;fgimg_pressed=%s]",
|
|
|
|
|
|
|
|
"craftguide_fav_off.png", PNG.nothing, PNG.nothing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image_button,
|
|
|
|
|
|
|
|
8.25, spacing + 0.15, 0.5, 0.45, "", "fav_no", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("tooltip[fav_no;%s]",
|
|
|
|
|
|
|
|
ES"Cannot mark this item. Limit of bookmarks reached.")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function get_panels(data, fs)
|
|
|
|
|
|
|
|
local title = {name = "title", height = 1.2}
|
|
|
|
|
|
|
|
local favs = {name = "favs", height = 1.91}
|
|
|
|
|
|
|
|
local recipes = {name = "recipes", rcp = data.recipes, height = 3.5}
|
|
|
|
|
|
|
|
local usages = {name = "usages", rcp = data.usages, height = 3.5}
|
|
|
|
|
|
|
|
local panels = {title, recipes, usages, favs}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sfinv_only then
|
|
|
|
|
|
|
|
panels = {data.show_usages and usages or recipes}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for idx = 1, #panels do
|
|
|
|
|
|
|
|
local panel, spacing = panels[idx], 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if idx > 1 then
|
|
|
|
|
|
|
|
for _idx = idx - 1, 1, -1 do
|
|
|
|
|
|
|
|
spacing = spacing + panels[_idx].height + 0.1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local rn = panel.rcp and #panel.rcp
|
|
|
|
|
|
|
|
local is_recipe = sfinv_only and not data.show_usages or panel.name == "recipes"
|
|
|
|
|
|
|
|
local recipe_or_usage = panel.name == "recipes" or panel.name == "usages"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if rn then
|
|
|
|
|
|
|
|
get_rcp_lbl(data, fs, panel, spacing, rn, is_recipe)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sfinv_only then return end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("background9[8.1,%f;6.6,%f;%s;false;%d]",
|
|
|
|
|
|
|
|
-0.2 + spacing, panel.height, PNG.bg_full, 10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if recipe_or_usage and not rn then
|
|
|
|
|
|
|
|
local X = XOFFSET - 0.7
|
|
|
|
|
|
|
|
local Y = YOFFSET - 0.4 + spacing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 2, 2, PNG.nothing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.tooltip,
|
|
|
|
|
|
|
|
X, Y, 2, 2, is_recipe and ES"No recipes" or ES"No usages")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif panel.name == "title" then
|
|
|
|
|
|
|
|
get_title_fs(data, fs, spacing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elseif panel.name == "favs" then
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.label, 8.3, spacing - 0.15, ES"Bookmarks")
|
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #data.favs do
|
|
|
|
for i = 1, #data.favs do
|
|
|
|
local item = data.favs[i]
|
|
|
|
local item = data.favs[i]
|
|
|
|
local X = 7.85 + (i - 0.5)
|
|
|
|
local X = 7.85 + (i - 0.5)
|
|
|
|
local Y = spacing + 0.45
|
|
|
|
local Y = spacing + 0.4
|
|
|
|
|
|
|
|
|
|
|
|
if data.query_item == item then
|
|
|
|
if data.query_item == item then
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 1.1, 1.1, PNG.selected)
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y,
|
|
|
|
|
|
|
|
ITEM_BTN_SIZE, ITEM_BTN_SIZE, PNG.selected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.item_image_button,
|
|
|
|
fs[#fs + 1] = fmt(FMT.item_image_button,
|
|
|
|
X, Y, 1.1, 1.1, item, item, "")
|
|
|
|
X, Y, ITEM_BTN_SIZE, ITEM_BTN_SIZE, item, item, "")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1110,9 +1155,9 @@ local function make_fs(data)
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt([[
|
|
|
|
fs[#fs + 1] = fmt([[
|
|
|
|
style[filter;border=false]
|
|
|
|
style[filter;border=false]
|
|
|
|
field[0.4,0.2;2.5,1;filter;;%s]
|
|
|
|
field[0.4,0.2;2.6,1;filter;;%s]
|
|
|
|
field_close_on_enter[filter;false]
|
|
|
|
field_close_on_enter[filter;false]
|
|
|
|
box[0,0;2.4,0.6;#bababa25]
|
|
|
|
box[0,0;2.5,0.6;#bababa25]
|
|
|
|
]],
|
|
|
|
]],
|
|
|
|
ESC(data.filter))
|
|
|
|
ESC(data.filter))
|
|
|
|
|
|
|
|
|
|
|
@ -1131,17 +1176,27 @@ local function make_fs(data)
|
|
|
|
PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
|
|
|
PNG.prev, PNG.prev_hover, PNG.prev_hover,
|
|
|
|
PNG.next, PNG.next_hover, PNG.next_hover)
|
|
|
|
PNG.next, PNG.next_hover, PNG.next_hover)
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 4),
|
|
|
|
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 2),
|
|
|
|
sfinv_only and 2.6 or 2.54, -0.06, 0.85, 0.85, "", "search", "",
|
|
|
|
2.6, -0.06, 0.85, 0.85, "", "search", "",
|
|
|
|
sfinv_only and 3.3 or 3.25, -0.06, 0.85, 0.85, "", "clear", "",
|
|
|
|
3.3, -0.06, 0.85, 0.85, "", "clear", "")
|
|
|
|
sfinv_only and 5.45 or (9 * 6.83) / 11, -0.06, 0.85, 0.85, "", "prev_page", "",
|
|
|
|
|
|
|
|
sfinv_only and 7.2 or (9 * 8.75) / 11, -0.06, 0.85, 0.85, "", "next_page", "")
|
|
|
|
if sfinv_only then
|
|
|
|
|
|
|
|
fs[#fs + 1] = "container[0.2,0]"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 2),
|
|
|
|
|
|
|
|
5.35, -0.06, 0.85, 0.85, "", "prev_page", "",
|
|
|
|
|
|
|
|
7.1, -0.06, 0.85, 0.85, "", "next_page", "")
|
|
|
|
|
|
|
|
|
|
|
|
data.pagemax = max(1, ceil(#data.items / IPP))
|
|
|
|
data.pagemax = max(1, ceil(#data.items / IPP))
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt(FMT.button,
|
|
|
|
fs[#fs + 1] = fmt(FMT.button,
|
|
|
|
sfinv_only and 5.85 or 6, -0.1, sfinv_only and 1.82 or 1.62, 1, "pagenum",
|
|
|
|
5.97, -0.06, 1.36, 0.85, "pagenum",
|
|
|
|
fmt("%u / %u", data.pagenum, data.pagemax))
|
|
|
|
fmt("%s / %u", clr("#ff0", data.pagenum), data.pagemax))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sfinv_only then
|
|
|
|
|
|
|
|
fs[#fs + 1] = "container_end[]"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if #data.items == 0 then
|
|
|
|
if #data.items == 0 then
|
|
|
|
local no_item = ES"No item to show"
|
|
|
|
local no_item = ES"No item to show"
|
|
|
@ -1170,7 +1225,8 @@ local function make_fs(data)
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
|
|
|
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;1,1;%s;%s_inv;]", X, Y, item, item)
|
|
|
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s_inv;]",
|
|
|
|
|
|
|
|
X, Y, 1, 1, item, item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then
|
|
|
|
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then
|
|
|
@ -1195,7 +1251,7 @@ craftguide.register_craft_type("digging", {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
craftguide.register_craft_type("digging_chance", {
|
|
|
|
craftguide.register_craft_type("digging_chance", {
|
|
|
|
description = ES"Digging Chance",
|
|
|
|
description = ES"Digging (by chance)",
|
|
|
|
icon = "craftguide_mesepick.png",
|
|
|
|
icon = "craftguide_mesepick.png",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
@ -1382,12 +1438,16 @@ local function handle_drops_table(name, drop)
|
|
|
|
if not dstack:is_empty() and dname ~= name then
|
|
|
|
if not dstack:is_empty() and dname ~= name then
|
|
|
|
local dcount = dstack:get_count()
|
|
|
|
local dcount = dstack:get_count()
|
|
|
|
|
|
|
|
|
|
|
|
if #di.items == 1 and di.rarity == 1 and max_start then
|
|
|
|
if #di.items == 1 and max_start and
|
|
|
|
|
|
|
|
(not di.rarity or di.rarity <= 1) then
|
|
|
|
if not drop_sure[dname] then
|
|
|
|
if not drop_sure[dname] then
|
|
|
|
drop_sure[dname] = 0
|
|
|
|
drop_sure[dname] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
drop_sure[dname] = drop_sure[dname] + dcount
|
|
|
|
drop_sure[dname] = {
|
|
|
|
|
|
|
|
output = (drop_sure[dname].output or 0) + dcount,
|
|
|
|
|
|
|
|
tools = di.tools,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if max_items_left then
|
|
|
|
if max_items_left then
|
|
|
|
max_items_left = max_items_left - 1
|
|
|
|
max_items_left = max_items_left - 1
|
|
|
@ -1402,24 +1462,22 @@ local function handle_drops_table(name, drop)
|
|
|
|
drop_maybe[dname] = {}
|
|
|
|
drop_maybe[dname] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if not drop_maybe[dname].output then
|
|
|
|
|
|
|
|
drop_maybe[dname].output = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drop_maybe[dname] = {
|
|
|
|
drop_maybe[dname] = {
|
|
|
|
output = drop_maybe[dname].output + dcount,
|
|
|
|
output = (drop_maybe[dname].output or 0) + dcount,
|
|
|
|
rarity = di.rarity,
|
|
|
|
rarity = di.rarity,
|
|
|
|
|
|
|
|
tools = di.tools,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
for item, count in pairs(drop_sure) do
|
|
|
|
for item, data in pairs(drop_sure) do
|
|
|
|
craftguide.register_craft{
|
|
|
|
craftguide.register_craft{
|
|
|
|
type = "digging",
|
|
|
|
type = "digging",
|
|
|
|
items = {name},
|
|
|
|
items = {name},
|
|
|
|
output = fmt("%s %u", item, count),
|
|
|
|
output = fmt("%s %u", item, data.output),
|
|
|
|
|
|
|
|
tools = data.tools,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -1429,19 +1487,21 @@ local function handle_drops_table(name, drop)
|
|
|
|
items = {name},
|
|
|
|
items = {name},
|
|
|
|
output = fmt("%s %u", item, data.output),
|
|
|
|
output = fmt("%s %u", item, data.output),
|
|
|
|
rarity = data.rarity,
|
|
|
|
rarity = data.rarity,
|
|
|
|
|
|
|
|
tools = data.tools,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function register_drops(name, drop)
|
|
|
|
local function register_drops(name, drop)
|
|
|
|
|
|
|
|
if true_str(drop) then
|
|
|
|
local dstack = ItemStack(drop)
|
|
|
|
local dstack = ItemStack(drop)
|
|
|
|
|
|
|
|
|
|
|
|
if not dstack:is_empty() and dstack:get_name() ~= name then
|
|
|
|
if not dstack:is_empty() and dstack:get_name() ~= name then
|
|
|
|
craftguide.register_craft{
|
|
|
|
craftguide.register_craft{
|
|
|
|
type = "digging",
|
|
|
|
type = "digging",
|
|
|
|
items = {name},
|
|
|
|
items = {name},
|
|
|
|
output = drop,
|
|
|
|
output = drop,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
elseif is_table(drop) then
|
|
|
|
elseif is_table(drop) then
|
|
|
|
handle_drops_table(name, drop)
|
|
|
|
handle_drops_table(name, drop)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1501,10 +1561,12 @@ local function get_init_items()
|
|
|
|
recipes_cache = dslz(storage:get "recipes_cache")
|
|
|
|
recipes_cache = dslz(storage:get "recipes_cache")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print "[craftguide] Caching data (this may take a while)"
|
|
|
|
print "[craftguide] Caching data (this may take a while)"
|
|
|
|
local hash = {}
|
|
|
|
local _select, _preselect = {}, {}
|
|
|
|
|
|
|
|
|
|
|
|
for name, def in pairs(reg_items) do
|
|
|
|
for name, def in pairs(reg_items) do
|
|
|
|
if show_item(def) then
|
|
|
|
if name ~= "" and show_item(def) then
|
|
|
|
|
|
|
|
register_drops(name, def.drop)
|
|
|
|
|
|
|
|
|
|
|
|
if not fuel_cache[name] then
|
|
|
|
if not fuel_cache[name] then
|
|
|
|
cache_fuel(name)
|
|
|
|
cache_fuel(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -1514,16 +1576,19 @@ local function get_init_items()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
cache_usages(name)
|
|
|
|
cache_usages(name)
|
|
|
|
register_drops(name, def.drop)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if name ~= "" and recipes_cache[name] or usages_cache[name] then
|
|
|
|
_preselect[name] = true
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for name in pairs(_preselect) do
|
|
|
|
|
|
|
|
if recipes_cache[name] or usages_cache[name] then
|
|
|
|
init_items[#init_items + 1] = name
|
|
|
|
init_items[#init_items + 1] = name
|
|
|
|
hash[name] = true
|
|
|
|
_select[name] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
handle_aliases(hash)
|
|
|
|
handle_aliases(_select)
|
|
|
|
sort(init_items)
|
|
|
|
sort(init_items)
|
|
|
|
|
|
|
|
|
|
|
|
storage:set_string("init_items", slz(init_items))
|
|
|
|
storage:set_string("init_items", slz(init_items))
|
|
|
@ -1608,7 +1673,7 @@ local function fields(player, _f)
|
|
|
|
data.pagenum = 1
|
|
|
|
data.pagenum = 1
|
|
|
|
search(data)
|
|
|
|
search(data)
|
|
|
|
|
|
|
|
|
|
|
|
elseif _f.prev_page or _f.next_page then
|
|
|
|
elseif _f.prev_page or _f.next_page or _f.pagenum then
|
|
|
|
if data.pagemax == 1 then return end
|
|
|
|
if data.pagemax == 1 then return end
|
|
|
|
data.pagenum = data.pagenum - (_f.prev_page and 1 or -1)
|
|
|
|
data.pagenum = data.pagenum - (_f.prev_page and 1 or -1)
|
|
|
|
|
|
|
|
|
|
|
@ -1622,7 +1687,7 @@ local function fields(player, _f)
|
|
|
|
local fav, i = is_fav(data)
|
|
|
|
local fav, i = is_fav(data)
|
|
|
|
local total = #data.favs
|
|
|
|
local total = #data.favs
|
|
|
|
|
|
|
|
|
|
|
|
if total < 6 and not fav then
|
|
|
|
if total < MAX_FAVS and not fav then
|
|
|
|
data.favs[total + 1] = data.query_item
|
|
|
|
data.favs[total + 1] = data.query_item
|
|
|
|
elseif fav then
|
|
|
|
elseif fav then
|
|
|
|
remove(data.favs, i)
|
|
|
|
remove(data.favs, i)
|
|
|
|