Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d98c6a5cc | |||
87d65439a1 | |||
4309b3575a | |||
bb13ba6d7c | |||
3d5ba32fa0 | |||
0847176bdb | |||
4fb53b67e8 | |||
e5f73438ce |
79
api.lua
@ -467,6 +467,15 @@ signs_lib.charwidth_wide32 = build_char_db(32)
|
|||||||
|
|
||||||
local math_max = math.max
|
local math_max = math.max
|
||||||
|
|
||||||
|
local function fill_line(x, y, w, c, font_size, colorbgw)
|
||||||
|
c = c or "0"
|
||||||
|
local tex = { }
|
||||||
|
for xx = x, w, colorbgw do
|
||||||
|
table.insert(tex, (":%d,%d=signs_lib_color_"..font_size.."px_%s.png"):format(xx, y, c))
|
||||||
|
end
|
||||||
|
return table.concat(tex)
|
||||||
|
end
|
||||||
|
|
||||||
-- make char texture file name
|
-- make char texture file name
|
||||||
-- if texture file does not exist use fallback texture instead
|
-- if texture file does not exist use fallback texture instead
|
||||||
local function char_tex(font_name, ch)
|
local function char_tex(font_name, ch)
|
||||||
@ -502,26 +511,6 @@ local function char_tex_wide(font_name, ch)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- sign colour table
|
|
||||||
local colgrid = {
|
|
||||||
["0"] = "000000", -- black
|
|
||||||
["1"] = "000080", -- blue
|
|
||||||
["2"] = "008000", -- dark green
|
|
||||||
["3"] = "008080", -- dark cyan
|
|
||||||
["4"] = "800000", -- red
|
|
||||||
["5"] = "800080", -- purple
|
|
||||||
["6"] = "804000", -- brown
|
|
||||||
["7"] = "808080", -- light grey
|
|
||||||
["8"] = "404040", -- dark grey
|
|
||||||
["9"] = "8080ff", -- light blue
|
|
||||||
["A"] = "80ff80", -- green
|
|
||||||
["B"] = "80ffff", -- cyan
|
|
||||||
["C"] = "ff8080", -- skin pink
|
|
||||||
["D"] = "ff80ff", -- pink
|
|
||||||
["E"] = "ffff00", -- yellow
|
|
||||||
["F"] = "ffffff" -- white
|
|
||||||
}
|
|
||||||
|
|
||||||
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw, cwidth_tab_wide, force_unicode_font)
|
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw, cwidth_tab_wide, force_unicode_font)
|
||||||
local width = 0
|
local width = 0
|
||||||
local maxw = 0
|
local maxw = 0
|
||||||
@ -595,7 +584,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||||||
end
|
end
|
||||||
if w then
|
if w then
|
||||||
width = width + w
|
width = width + w
|
||||||
if width >= (line_width - cwidth_tab[" "]) then
|
if width > line_width then
|
||||||
width = 0
|
width = 0
|
||||||
else
|
else
|
||||||
maxw = math_max(width, maxw)
|
maxw = math_max(width, maxw)
|
||||||
@ -618,6 +607,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||||||
off = ch_offs,
|
off = ch_offs,
|
||||||
tex = tex,
|
tex = tex,
|
||||||
col = ("%X"):format(cur_color),
|
col = ("%X"):format(cur_color),
|
||||||
|
w = w,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
ch_offs = ch_offs + w
|
ch_offs = ch_offs + w
|
||||||
@ -627,7 +617,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||||||
local w = cwidth_tab[c]
|
local w = cwidth_tab[c]
|
||||||
if w then
|
if w then
|
||||||
width = width + w
|
width = width + w
|
||||||
if width >= (line_width - cwidth_tab[" "]) then
|
if width > line_width then
|
||||||
width = 0
|
width = 0
|
||||||
else
|
else
|
||||||
maxw = math_max(width, maxw)
|
maxw = math_max(width, maxw)
|
||||||
@ -637,6 +627,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||||||
off = ch_offs,
|
off = ch_offs,
|
||||||
tex = char_tex(font_name, c),
|
tex = char_tex(font_name, c),
|
||||||
col = ("%X"):format(cur_color),
|
col = ("%X"):format(cur_color),
|
||||||
|
w = w,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
ch_offs = ch_offs + w
|
ch_offs = ch_offs + w
|
||||||
@ -653,29 +644,43 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||||||
|
|
||||||
local texture = { }
|
local texture = { }
|
||||||
|
|
||||||
local start_xpos = math.floor((line_width - maxw) / 2) + def.x_offset
|
local start_xpos = math.max(0, math.floor((line_width - maxw) / 2)) + def.x_offset
|
||||||
|
local end_xpos = math.min(start_xpos + maxw, line_width)
|
||||||
|
|
||||||
local xpos = start_xpos
|
local xpos = start_xpos
|
||||||
local ypos = (line_height + def.line_spacing)* lineno + def.y_offset
|
local ypos = (line_height + def.line_spacing)* lineno + def.y_offset
|
||||||
|
|
||||||
|
cur_color = nil
|
||||||
|
|
||||||
for word_i, word in ipairs(words) do
|
for word_i, word in ipairs(words) do
|
||||||
local xoffs = (xpos - start_xpos)
|
local xoffs = (xpos - start_xpos)
|
||||||
if (xoffs > 0) and ((xoffs + word.w) > maxw) then
|
if (xoffs > 0) and ((xoffs + word.w) > end_xpos) then
|
||||||
|
table.insert(texture, fill_line(xpos, ypos, end_xpos, "n", font_size, colorbgw))
|
||||||
xpos = start_xpos
|
xpos = start_xpos
|
||||||
ypos = ypos + line_height + def.line_spacing
|
ypos = ypos + line_height + def.line_spacing
|
||||||
lineno = lineno + 1
|
lineno = lineno + 1
|
||||||
if lineno >= def.number_of_lines then break end
|
if lineno >= def.number_of_lines then break end
|
||||||
|
table.insert(texture, fill_line(xpos, ypos, end_xpos, cur_color, font_size, colorbgw))
|
||||||
end
|
end
|
||||||
for ch_i, ch in ipairs(word.chars) do
|
for ch_i, ch in ipairs(word.chars) do
|
||||||
|
if xpos + ch.off + ch.w > end_xpos then
|
||||||
-- colorize character texture
|
table.insert(texture, fill_line(xpos + ch.off, ypos, end_xpos, "n", font_size, colorbgw))
|
||||||
local newtex = ch.tex .. '\\^[colorize\\:#' .. colgrid[ch.col]
|
break
|
||||||
|
|
||||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, newtex))
|
|
||||||
end
|
end
|
||||||
xpos = xpos + word.w + cwidth_tab[" "]
|
if ch.col ~= cur_color then
|
||||||
if xpos >= (line_width + cwidth_tab[" "]) then break end
|
cur_color = ch.col
|
||||||
|
table.insert(texture, fill_line(xpos + ch.off, ypos, end_xpos, cur_color, font_size, colorbgw))
|
||||||
end
|
end
|
||||||
|
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
||||||
|
end
|
||||||
|
xpos = xpos + word.w
|
||||||
|
if xpos < end_xpos then
|
||||||
|
table.insert(texture, (":%d,%d="):format(xpos, ypos) .. char_tex(font_name, " "))
|
||||||
|
xpos = xpos + cwidth_tab[" "]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(texture, fill_line(xpos, ypos, end_xpos, "n", font_size, colorbgw))
|
||||||
|
|
||||||
return table.concat(texture), lineno
|
return table.concat(texture), lineno
|
||||||
end
|
end
|
||||||
@ -721,7 +726,7 @@ function signs_lib.make_sign_texture(lines, pos)
|
|||||||
table.insert(texture, linetex)
|
table.insert(texture, linetex)
|
||||||
lineno = ln + 1
|
lineno = ln + 1
|
||||||
end
|
end
|
||||||
|
table.insert(texture, "^[makealpha:0,0,0")
|
||||||
return table.concat(texture, "")
|
return table.concat(texture, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -813,6 +818,9 @@ function signs_lib.update_sign(pos, fields)
|
|||||||
local ownstr = ""
|
local ownstr = ""
|
||||||
if owner ~= "" then ownstr = S("Locked sign, owned by @1\n", owner) end
|
if owner ~= "" then ownstr = S("Locked sign, owned by @1\n", owner) end
|
||||||
|
|
||||||
|
-- Fix pasting from Windows: CR instead of LF
|
||||||
|
text = string.gsub(text, "\r\n?", "\n")
|
||||||
|
|
||||||
meta:set_string("text", text)
|
meta:set_string("text", text)
|
||||||
meta:set_string("infotext", ownstr..make_infotext(text).." ")
|
meta:set_string("infotext", ownstr..make_infotext(text).." ")
|
||||||
|
|
||||||
@ -938,7 +946,13 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
|
|||||||
local controls = placer:get_player_control()
|
local controls = placer:get_player_control()
|
||||||
|
|
||||||
local signname = itemstack:get_name()
|
local signname = itemstack:get_name()
|
||||||
|
|
||||||
|
-- in case player has sign nodes they shouldn't, remove extensions for normal sign
|
||||||
local no_wall_name = string.gsub(signname, "_wall", "")
|
local no_wall_name = string.gsub(signname, "_wall", "")
|
||||||
|
no_wall_name = string.gsub(no_wall_name, "_yard", "")
|
||||||
|
no_wall_name = string.gsub(no_wall_name, "_hanging", "")
|
||||||
|
no_wall_name = string.gsub(no_wall_name, "_onpole_horiz", "")
|
||||||
|
no_wall_name = string.gsub(no_wall_name, "_onpole", "")
|
||||||
|
|
||||||
local def = minetest.registered_items[signname]
|
local def = minetest.registered_items[signname]
|
||||||
|
|
||||||
@ -1002,6 +1016,7 @@ end
|
|||||||
|
|
||||||
function signs_lib.register_sign(name, raw_def)
|
function signs_lib.register_sign(name, raw_def)
|
||||||
local def = table.copy(raw_def)
|
local def = table.copy(raw_def)
|
||||||
|
def.is_ground_content = false
|
||||||
|
|
||||||
if raw_def.entity_info == "standard" then
|
if raw_def.entity_info == "standard" then
|
||||||
def.entity_info = {
|
def.entity_info = {
|
||||||
|
@ -231,6 +231,7 @@ signs_lib.unicode_install({38,"26"})
|
|||||||
dofile(signs_lib.path.."/nonascii-de.lua")
|
dofile(signs_lib.path.."/nonascii-de.lua")
|
||||||
dofile(signs_lib.path.."/nonascii-fr.lua")
|
dofile(signs_lib.path.."/nonascii-fr.lua")
|
||||||
dofile(signs_lib.path.."/nonascii-pl.lua")
|
dofile(signs_lib.path.."/nonascii-pl.lua")
|
||||||
|
dofile(signs_lib.path.."/nonascii-ua.lua")
|
||||||
|
|
||||||
local nmdc = {
|
local nmdc = {
|
||||||
[36] = "$",
|
[36] = "$",
|
||||||
|
14
locale/signs_lib.uk.tr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# textdomain: signs_lib
|
||||||
|
Signs Lib=Таблички Lib
|
||||||
|
Adds signs with readable text.=Додає таблички з читабельним текстом.
|
||||||
|
Locked sign, owned by @1@n=Захищена табличка (власник @1@n)
|
||||||
|
Skims through all currently-loaded sign-bearing mapblocks, clears away any entities within each sign's node space, and regenerates their text entities, if any.=Перевіряє всі завантажені блоки з табличками, очищає їхній простір від об'єктів і відновлює текст, якщо потрібно.
|
||||||
|
There are no signs in the currently-loaded terrain.=Не знайдено табличок на поточній провантаженій території.
|
||||||
|
Found a total of @1 sign nodes across @2 blocks.=Загалом знайдено @1 табличок в @2 блоках.
|
||||||
|
Regenerating sign entities ...=Регенерація сутностей табличок...
|
||||||
|
Finished.=Завершено.
|
||||||
|
Write=Записати
|
||||||
|
Unicode font=Юнікод
|
||||||
|
Wide font=Широкий
|
||||||
|
Wooden Wall Sign=Дерев'яна табличка
|
||||||
|
Steel Wall Sign=Сталева табличка
|
8
nonascii-ua.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
signs_lib.unicode_install({208,132,"0404"})
|
||||||
|
signs_lib.unicode_install({208,134,"0406"})
|
||||||
|
signs_lib.unicode_install({208,135,"0407"})
|
||||||
|
signs_lib.unicode_install({209,148,"0454"})
|
||||||
|
signs_lib.unicode_install({209,150,"0456"})
|
||||||
|
signs_lib.unicode_install({209,151,"0457"})
|
||||||
|
signs_lib.unicode_install({210,144,"0490"})
|
||||||
|
signs_lib.unicode_install({210,145,"0491"})
|
BIN
textures/signs_lib_color_16px_0.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_1.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_2.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_3.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_4.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_5.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_6.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_7.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_8.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_16px_9.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_A.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_B.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_C.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_D.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_E.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
textures/signs_lib_color_16px_F.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
textures/signs_lib_color_32px_0.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_color_32px_1.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_2.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_3.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_4.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_5.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_6.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_7.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_color_32px_8.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_color_32px_9.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_A.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_B.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_C.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_D.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_E.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
textures/signs_lib_color_32px_F.png
Normal file
After Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 95 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 115 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 115 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 103 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 95 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 122 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 99 B |
BIN
textures/signs_lib_font_16px_0404.png
Normal file
After Width: | Height: | Size: 129 B |
BIN
textures/signs_lib_font_16px_0406.png
Normal file
After Width: | Height: | Size: 86 B |
BIN
textures/signs_lib_font_16px_0407.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
textures/signs_lib_font_16px_0454.png
Normal file
After Width: | Height: | Size: 135 B |
BIN
textures/signs_lib_font_16px_0456.png
Normal file
After Width: | Height: | Size: 94 B |
BIN
textures/signs_lib_font_16px_0457.png
Normal file
After Width: | Height: | Size: 91 B |
BIN
textures/signs_lib_font_16px_0490.png
Normal file
After Width: | Height: | Size: 102 B |
BIN
textures/signs_lib_font_16px_0491.png
Normal file
After Width: | Height: | Size: 103 B |
Before Width: | Height: | Size: 74 B After Width: | Height: | Size: 68 B |
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 95 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 91 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 90 B |