sorcery  Diff

Differences From Artifact [787cef01b1]:

To Artifact [70c6c0143a]:


1
2
3
4


































5
6
7
8
9
10
11
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




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
40
41
42
43
44
45
local l = sorcery.lib
local dui = sorcery.data.ui

return {
	form = function()
		return {
			src = "";
			width = 8;
			pad = 0;
			curs = {x = 0, y = 0, maxh = 0};
			nl = function(self, h)
				h = h or 0
				self.curs.x = 0
				self.curs.y = math.max(h, self.curs.y + self.curs.maxh)
				self.curs.maxh = 0
			end;
			atttach = function(self, elt, x, y, w, h, ...)
				local content = ''
				if self.width - self.curs.x < w then self:nl() end
				for _, v in pairs{...} do
					content = content .. ';' .. minetest.formspec_escape(tostring(v))
				end
				self.src = self.src .. string.format('%s[%f,%f;%f,%f%s]', elt, x,y, w,h, content)
				if h > self.curs.maxh then self.curs.maxh = h end
			end;
			add = function(self, elt, w, h, ...)
				local ax, ay = self.curs.x, self.curs.y
				self:attach(elt, ax,ay, w,h, ...)
				self.curs.x = self.curs.x + w + self.pad
				if self.curs.x > self.width then self:nl() end
				return ax, ay
			end;
			render = function()
				return string.format("size[%f,%f]%s", self.width, self.curs.y + self.pad + self.curs.maxh, self.src)
			end;
		}
	end;

	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