Fix replace tooltip

This commit is contained in:
Jean-Patrick Guerrero 2019-09-09 19:29:36 +02:00
parent 11da33ca76
commit 12e35f80f0
3 changed files with 12 additions and 8 deletions

@ -406,6 +406,12 @@ local function groups_to_items(groups, get_all)
return #names > 0 and concat(names, ",") or "" return #names > 0 and concat(names, ",") or ""
end end
local function get_description(item, def)
return def and def.description or
(def and match(item, ":.*"):gsub("%W%l", upper):sub(2):gsub("_", " ") or
S("Unknown Item (@1)", item))
end
local function get_tooltip(item, burntime, groups, cooktime, replace) local function get_tooltip(item, burntime, groups, cooktime, replace)
local tooltip local tooltip
@ -421,10 +427,7 @@ local function get_tooltip(item, burntime, groups, cooktime, replace)
tooltip = S("Any item belonging to the group(s): @1", groupstr) tooltip = S("Any item belonging to the group(s): @1", groupstr)
else else
local def = reg_items[item] local def = reg_items[item]
tooltip = get_description(item, def)
tooltip = def and def.description or
(def and match(item, ":.*"):gsub("%W%l", upper):sub(2):gsub("_", " ") or
S("Unknown Item (@1)", item))
end end
if cooktime then if cooktime then
@ -440,7 +443,8 @@ local function get_tooltip(item, burntime, groups, cooktime, replace)
if replace then if replace then
local def = reg_items[replace] local def = reg_items[replace]
tooltip = tooltip .. "\n" .. tooltip = tooltip .. "\n" ..
S("Replaced by: @1", colorize("yellow", def.description)) S("Replaced by @1 on crafting",
colorize("yellow", get_description(replace, def)))
end end
return fmt("tooltip[%s;%s]", item, ESC(tooltip)) return fmt("tooltip[%s;%s]", item, ESC(tooltip))
@ -531,7 +535,7 @@ local function get_recipe_fs(data)
local burntime = fuel_cache[item] and fuel_cache[item].burntime local burntime = fuel_cache[item] and fuel_cache[item].burntime
if groups or cooktime or burntime then if groups or cooktime or burntime or replace then
fs[#fs + 1] = get_tooltip(item, burntime, groups, cooktime, replace) fs[#fs + 1] = get_tooltip(item, burntime, groups, cooktime, replace)
end end
end end

@ -6,7 +6,7 @@ Usage @1 of @2=Usage @1 de @2
Recipe @1 of @2=Recette @1 de @2 Recipe @1 of @2=Recette @1 de @2
Burning time: @1=Temps de combustion : @1 Burning time: @1=Temps de combustion : @1
Cooking time: @1=Temps de cuisson : @1 Cooking time: @1=Temps de cuisson : @1
Replaced by: @1=Remplacé par : @1 Replaced by @1 on crafting=Remplacé par @1 lors de la fabrication
Any item belonging to the group(s): @1=Tout item appartenant au(x) groupe(s) : @1 Any item belonging to the group(s): @1=Tout item appartenant au(x) groupe(s) : @1
Recipe's too big to be displayed (@1x@2)=La recette est trop grande pour être affichée (@1x@2) Recipe's too big to be displayed (@1x@2)=La recette est trop grande pour être affichée (@1x@2)
Shapeless=Sans forme Shapeless=Sans forme

@ -7,7 +7,7 @@ Usage @1 of @2=
Recipe @1 of @2= Recipe @1 of @2=
Burning time: @1= Burning time: @1=
Cooking time: @1= Cooking time: @1=
Replaced by: @1= Replaced by @1 on crafting=
Any item belonging to the group(s): @1= Any item belonging to the group(s): @1=
Recipe's too big to be displayed (@1x@2)= Recipe's too big to be displayed (@1x@2)=
Shapeless= Shapeless=