Compare commits

...

3 Commits

Author SHA1 Message Date
96f9c85c77 Improve description formatting 2020-07-22 17:28:36 +02:00
9412ac740a Polish 2020-07-20 19:08:51 +02:00
f2a5c4255e Minor cleaning 2020-07-20 15:43:34 +02:00

View File

@ -699,23 +699,22 @@ end
local function cache_recipes(item)
local recipes = get_all_recipes(item)
local _recipes
if replacements[item] then
_recipes = {}
local _recipes = {}
for k, v in ipairs(recipes or {}) do
_recipes[#recipes + 1 - k] = v
end
for k, v in pairs(replacements[item]) do
if v.type ~= "fuel" then
_recipes[k].replacements = v
end
_recipes[k].replacements = v
end
recipes = _recipes
end
recipes_cache[item] = _recipes or recipes
recipes_cache[item] = recipes
end
local function get_recipes(item, data, player)
@ -793,7 +792,7 @@ local function is_fav(favs, query_item)
end
local function weird_desc(str)
return not true_str(str) or find(str, "\n") or not find(str, "%u")
return not true_str(str) or find(str, "[\\]*") or not find(str, "%u")
end
local function toupper(str)
@ -804,6 +803,10 @@ local function strip_newline(str)
return match(str, "[^\n]*")
end
local function strip_prefix(str)
return match(str, ".*@.*%)(.*)()") or str
end
local function get_desc(item, lang_code)
if sub(item, 1, 1) == "_" then
item = sub(item, 2)
@ -814,10 +817,16 @@ local function get_desc(item, lang_code)
if def then
local desc = def.description
if true_str(desc) then
desc = translate(lang_code, desc)
desc = desc:trim()
desc = strip_newline(desc)
desc = strip_prefix(desc)
if not find(desc, "%u") then
return strip_newline(toupper(desc))
desc = toupper(desc)
end
return strip_newline(translate(lang_code, desc))
return desc
elseif true_str(item) then
return toupper(match(item, ":(.*)"))
@ -1164,7 +1173,7 @@ local function get_title_fs(query_item, lang_code, favs, fs, spacing)
local t_desc = 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]",
fs[#fs + 1] = fmt("hypertext[9.05,%f;5.85,1.2;;%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>",
@ -1333,7 +1342,10 @@ local function make_fs(data)
lbl = ES"Collect items to reveal more recipes"
end
fs[#fs + 1] = fmt(FMT.button, -0.25, 3, 8.3, 1, "no_item", lbl)
fs[#fs + 1] = fmt("hypertext[%f,%f;%f,%f;;%s]",
0.05, 3, 8.29, 1,
fmt("<center><style size=20><b>%s</b></style></center>]",
translate(data.lang_code, lbl)))
end
local first_item = (data.pagenum - 1) * IPP