1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
local l = sorcery.lib
local dui = sorcery.data.ui
return {
tooltip = function(a)
local color = a.color
if color == nil then color = l.color(136,158,177) end
local str = a.title
if a.desc then
str = str .. '\n' .. color:fmt(minetest.wrap_text(a.desc,60))
end
if a.props then
-- str = str .. '\n'
for _,prop in pairs(a.props) do
local c
if prop.color and l.color.id(prop.color) then
c = prop.color
elseif dui.colors[prop.affinity] then
c = l.color(dui.colors[prop.affinity])
else
c = l.color(dui.colors.neutral)
end
str = str .. '\n ' .. c:fmt('* ')
if prop.title then
str = str .. c:brighten(1.3):fmt(prop.title) .. ': '
end
local lines = minetest.wrap_text(prop.desc, 50, true)
str = str .. c:fmt(lines[1])
for i=2,#lines do
str = str .. '\n' .. string.rep(' ',5) .. c:fmt(lines[i])
end
end
end
return str
end;
}
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
local l = sorcery.lib
local dui = sorcery.data.ui
return {
tooltip = function(a)
local color = a.color and a.color:readable()
if color == nil then color = l.color(136,158,177) end
local str = a.title
if a.desc then
str = str .. '\n' .. color:fmt(minetest.wrap_text(a.desc,60))
end
if a.props then
-- str = str .. '\n'
for _,prop in pairs(a.props) do
local c
if prop.color and l.color.id(prop.color) then
c = prop.color:readable()
elseif dui.colors[prop.affinity] then
c = l.color(dui.colors[prop.affinity])
else
c = l.color(dui.colors.neutral)
end
str = str .. '\n ' .. c:fmt('* ')
if prop.title then
str = str .. c:brighten(1.3):fmt(prop.title) .. ': '
end
local lines = minetest.wrap_text(prop.desc, 55, true)
str = str .. c:fmt(lines[1])
for i=2,#lines do
str = str .. '\n' .. string.rep(' ',5) .. c:fmt(lines[i])
end
end
end
return color:darken(0.8):bg(str)
end;
}
|