Subversion Repositories fei

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 3
Line 44... Line 44...
44
end
44
end
45
 
45
 
46
local function parse_formspec_information(formspec)
46
local function parse_formspec_information(formspec)
47
	local width = 0
47
	local width = 0
48
	local height = 0
48
	local height = 0
49
	local _,size_end = string.find(formspec, "size%[")
49
	local _, size_end = string.find(formspec, "size%[")
50
	if size_end then
50
	if size_end then
51
		local size_pattern = string.sub(formspec, size_end)
51
		local size_pattern = string.sub(formspec, size_end)
52
		width, size_pattern = scan_number(size_pattern)
52
		width, size_pattern = scan_number(size_pattern)
53
		height, size_pattern = scan_number(size_pattern)
53
		height, size_pattern = scan_number(size_pattern)
54
	end
54
	end
55
 
55
 
-
 
56
	local version = 1
-
 
57
	local _, version_end = string.find(formspec, "formspec_version%[")
-
 
58
	if version_end then
-
 
59
		local version_pattern = string.sub(formspec, version_end)
-
 
60
		version, _ = scan_number(version_pattern)
-
 
61
	end
-
 
62
 
-
 
63
	local real_coordinates = false
-
 
64
	local _, real_coordinates_end = string.find(formspec, "real_coordinates%[")
-
 
65
	if real_coordinates_end then
-
 
66
		-- Check for true keyword
-
 
67
		local real_coordinates_pattern = string.sub(formspec, real_coordinates_end, real_coordinates_end+4)
-
 
68
		real_coordinates = real_coordinates_pattern=="true"
-
 
69
	end
-
 
70
 
56
	return {
71
	return {
57
		width = width,
72
		width = width,
58
		height = height,
73
		height = height,
59
		-- TODO: Look for real_coordinates and formspec_version elements to determine this
-
 
60
		legacy_coordinates = true
74
		legacy_coordinates = version==1 and not real_coordinates
61
	}
75
	}
62
end
76
end
63
 
77
 
64
local function determine_anchor(window_info, inv_formspec_info)
78
local function determine_anchor(window_info, inv_formspec_info)
65
	local element_spacing = inv_formspec_info.legacy_coordinates and 0.25 or 0
79
	local element_spacing = inv_formspec_info.legacy_coordinates and 0.25 or 0