mirror of
https://github.com/minetest-mods/craftguide.git
synced 2025-07-15 06:10:39 +02:00
Compare commits
3 Commits
8c3efefd92
...
0de66b1a09
Author | SHA1 | Date | |
---|---|---|---|
0de66b1a09 | |||
aa46556020 | |||
ce59bd35d4 |
31
init.lua
31
init.lua
@ -819,19 +819,15 @@ local function is_fav(favs, query_item)
|
||||
end
|
||||
|
||||
local function weird_desc(str)
|
||||
return not true_str(str) or find(str, "[\\]*") or not find(str, "%u")
|
||||
return not true_str(str) or find(str, "\n") or not find(str, "%u")
|
||||
end
|
||||
|
||||
local function toupper(str)
|
||||
return str:gsub("%f[%w]%l", upper):gsub("_", " ")
|
||||
end
|
||||
|
||||
local function strip_newline(str)
|
||||
return match(str, "[^\n]*")
|
||||
end
|
||||
|
||||
local function strip_prefix(str)
|
||||
return match(str, ".*@.*%)(.*)()") or str
|
||||
local function nice_strip(str, limit)
|
||||
return #str > limit and fmt("%s...", sub(str, 1, limit - 3)) or str
|
||||
end
|
||||
|
||||
local function get_desc(item)
|
||||
@ -844,9 +840,7 @@ local function get_desc(item)
|
||||
if def then
|
||||
local desc = def.description
|
||||
if true_str(desc) then
|
||||
desc = desc:trim()
|
||||
desc = strip_newline(desc)
|
||||
desc = strip_prefix(desc)
|
||||
desc = desc:trim():match("[^\n]*")
|
||||
|
||||
if not find(desc, "%u") then
|
||||
desc = toupper(desc)
|
||||
@ -1109,13 +1103,7 @@ local function get_grid_fs(fs, rcp, spacing)
|
||||
fs[#fs + 1] = fmt(FMT.image, X, Y, btn_size, btn_size, PNG.selected)
|
||||
end
|
||||
|
||||
local btn_name = ""
|
||||
|
||||
if groups then
|
||||
btn_name = fmt("group|%s|%s", groups[1], item)
|
||||
elseif item ~= "" then
|
||||
btn_name = item
|
||||
end
|
||||
local btn_name = groups and fmt("group|%s|%s", groups[1], item) or item
|
||||
|
||||
fs[#fs + 1] = fmt(FMT.item_image_button,
|
||||
X, Y, btn_size, btn_size, item, btn_name, label)
|
||||
@ -1187,15 +1175,10 @@ local function get_rcp_lbl(fs, data, panel, spacing, rn, is_recipe)
|
||||
end
|
||||
|
||||
local function get_title_fs(query_item, favs, fs, spacing)
|
||||
local desc = ESC(get_desc(query_item))
|
||||
desc = #desc > 33 and fmt("%s...", sub(desc, 1, 30)) or desc
|
||||
local t_desc = query_item
|
||||
t_desc = #t_desc > 35 and fmt("%s...", sub(t_desc, 1, 32)) or t_desc
|
||||
|
||||
fs[#fs + 1] = "style_type[label;font=bold;font_size=22]"
|
||||
fs[#fs + 1] = fmt(FMT.label, 8.75, spacing - 0.1, desc)
|
||||
fs[#fs + 1] = fmt(FMT.label, 8.75, spacing - 0.1, nice_strip(ESC(get_desc(query_item)), 45))
|
||||
fs[#fs + 1] = "style_type[label;font=mono;font_size=16]"
|
||||
fs[#fs + 1] = fmt(FMT.label, 8.75, spacing + 0.3, clr("#7bf", t_desc))
|
||||
fs[#fs + 1] = fmt(FMT.label, 8.75, spacing + 0.3, clr("#7bf", nice_strip(query_item, 35)))
|
||||
fs[#fs + 1] = "style_type[label;font=normal;font_size=16]"
|
||||
|
||||
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||
|
Reference in New Issue
Block a user