Compare commits

...

11 Commits

Author SHA1 Message Date
5fc7e7c087 Style 2020-02-09 02:08:24 +01:00
aa61333ee3 Fix 2020-02-09 02:01:51 +01:00
e2cdfc28b0 Fix 2020-02-09 01:53:35 +01:00
aa9f7d6da3 Fix crash in sfinv mode 2020-02-09 01:46:15 +01:00
d87c64618c Don't show chances to drop for usages 2020-02-04 23:42:47 +01:00
3455257df5 Code cleaning 2020-02-03 01:01:00 +01:00
251a8b1bc9 Show fav icon only once 2020-02-03 00:31:14 +01:00
4dd40e06f5 New favorite icons 2020-02-02 21:39:56 +01:00
f9f9988868 Fix crash in progressive mode 2020-01-23 00:22:05 +01:00
dcb479dc44 Fix color in HUD 2020-01-22 00:06:47 +01:00
82bb95387e style 2020-01-12 23:30:57 +01:00
3 changed files with 32 additions and 34 deletions

View File

@ -644,6 +644,10 @@ local function is_fav(data)
end
local function get_desc(name)
if sub(name, 1, 1) == "_" then
name = sub(name, 2)
end
local def = reg_items[name]
return def and (match(def.description, "%)([%w%s]*)") or def.description) or
@ -748,9 +752,11 @@ local function get_output_fs(data, fs, L)
1.1, 1.1, PNG.selected)
end
fs[#fs + 1] = fmt(FMT.item_image_button,
local _name = sfinv_only and name or fmt("_%s", name)
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
1.1, 1.1, item, name, "")
1.1, 1.1, item, _name, "")
local infos = {
unknown = not reg_items[name] or nil,
@ -760,7 +766,7 @@ local function get_output_fs(data, fs, L)
}
if next(infos) then
fs[#fs + 1] = get_tooltip(name, infos)
fs[#fs + 1] = get_tooltip(_name, infos)
end
if infos.burntime then
@ -892,17 +898,7 @@ local function get_grid_fs(data, fs, rcp, spacing)
end
local function get_panels(data, fs)
local start_y
if data.fs_version >= 3 then
if sfinv_only then
start_y = 0.33
else
start_y = 0
end
else
start_y = 0.33
end
local start_y = data.fs_version >= 3 and (sfinv_only and 0.33 or 0) or 0.33
local panels = {
{dat = data.usages or {}, height = 3.5},
@ -925,7 +921,7 @@ local function get_panels(data, fs)
fs[#fs + 1] = fmt("background9[8.1,%f;6.6,%f;%s;false;%d]",
-0.2 + spacing, v.height, PNG.bg_full, 10)
if data.fs_version >= 3 and k ~= "favs" then
if data.fs_version >= 3 and k == 2 then
local fav = is_fav(data)
local nfavs = #data.favs
@ -952,7 +948,7 @@ local function get_panels(data, fs)
xu = max(-0.3, -((#xu - 3) * 0.05))
xr = max(-0.3, -((#xr - 3) * 0.05))
local is_recipe = k == 2
local is_recipe = sfinv_only and not data.show_usages or k == 2
local lbl
if not sfinv_only and rn == 0 then
@ -1020,7 +1016,7 @@ local function get_panels(data, fs)
end
end
local function make_formspec(data)
local function make_fs(data)
local fs = {}
fs[#fs + 1] = fmt([[
@ -1128,7 +1124,7 @@ local show_fs = function(player, name)
if sfinv_only then
sfinv.set_player_inventory_formspec(player)
else
show_formspec(name, "craftguide", make_formspec(data))
show_formspec(name, "craftguide", make_fs(data))
end
end
@ -1550,22 +1546,25 @@ end)
local function fields(player, _f)
local name = player:get_player_name()
local data = pdata[name]
--print(dump(_f))
if _f.clear then
reset_data(data)
return true, show_fs(player, name)
elseif _f.prev_recipe or _f.next_recipe then
local num = data.rnum + (_f.prev_recipe and -1 or 1)
data.rnum = data.recipes[num] and num or (_f.prev_recipe and #data.recipes or 1)
return true, show_fs(player, name)
elseif _f.prev_usage or _f.next_usage then
local num = data.unum + (_f.prev_usage and -1 or 1)
data.unum = data.usages[num] and num or (_f.prev_usage and #data.usages or 1)
return true, show_fs(player, name)
elseif (_f.key_enter_field == "filter" or _f.search) and _f.filter ~= "" then
elseif _f.key_enter_field == "filter" or _f.search then
if _f.filter == "" then
reset_data(data)
return true, show_fs(player, name)
end
local str = lower(_f.filter)
if data.filter == str then return end
@ -1573,8 +1572,6 @@ local function fields(player, _f)
data.pagenum = 1
search(data)
return true, show_fs(player, name)
elseif _f.prev_page or _f.next_page then
if data.pagemax == 1 then return end
data.pagenum = data.pagenum - (_f.prev_page and 1 or -1)
@ -1585,8 +1582,6 @@ local function fields(player, _f)
data.pagenum = data.pagemax
end
return true, show_fs(player, name)
elseif _f.fav then
local fav, i = is_fav(data)
local total = #data.favs
@ -1596,8 +1591,6 @@ local function fields(player, _f)
elseif fav then
remove(data.favs, i)
end
return true, show_fs(player, name)
else
local item
for field in pairs(_f) do
@ -1611,6 +1604,8 @@ local function fields(player, _f)
return
elseif sub(item, -4) == "_inv" then
item = sub(item, 1, -5)
elseif sub(item, 1, 1) == "_" then
item = sub(item, 2)
end
item = reg_aliases[item] or item
@ -1621,19 +1616,22 @@ local function fields(player, _f)
else
data.show_usages = not data.show_usages
end
elseif item == data.query_item then
return
end
local recipes, usages = get_recipes(item, data, player)
if not recipes and not usages then return end
if data.show_usages and not usages then return end
data.query_item = item
data.recipes = recipes
data.usages = usages
data.rnum = 1
data.unum = 1
end
return true, show_fs(player, name)
end
end
if sfinv_only then
@ -1648,7 +1646,7 @@ if sfinv_only then
get = function(self, player, context)
local name = player:get_player_name()
local data = pdata[name]
local formspec = make_formspec(data)
local formspec = make_fs(data)
return sfinv.make_formspec(player, context, formspec)
end,
@ -1688,7 +1686,7 @@ else
search(data)
end
show_formspec(name, "craftguide", make_formspec(data))
show_formspec(name, "craftguide", make_fs(data))
end
core.register_craftitem("craftguide:book", {
@ -1982,7 +1980,7 @@ if progressive_mode then
hud_elem_type = "text",
position = {x = 0.84, y = 1.04},
alignment = {x = 1, y = 1},
number = 0xfff,
number = 0xffffff,
text = "",
},
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB