cartographer/formspec.lua

68 lines
1.8 KiB
Lua
Raw Normal View History

local gui = {};
function gui.bg9(args)
return string.format("background9[%f,%f;%f,%f;%s;%s;%s]",
args.x, args.y,
args.w, args.h,
args.skin.texture .. ".png",
args.fullsize or false,
tostring(args.skin.radius));
end
function gui.button(args)
local data = string.format("button[%f,%f;%f,%f;%s;%s]", args.x, args.y, args.w, args.h, args.id, args.text);
if args.tooltip then
data = data .. gui.tooltip {
id = args.id,
text = args.tooltip
};
end
return data;
end
function gui.image_button(args)
local data = string.format("image_button[%f,%f;%f,%f;%s;%s;%s]",
args.x, args.y,
args.w, args.h,
args.image,
args.id,
args.text or "");
if args.tooltip then
data = data .. gui.tooltip {
id = args.id,
text = args.tooltip
};
end
return data;
end
function gui.label(args)
return string.format("label[%f,%f;%s]", args.x, args.y, args.text);
end
function gui.style_internal(selector, properties)
local data = "[" .. selector;
for name,value in pairs(properties) do
data = data .. string.format(";%s=%s", name, tostring(value));
end
return data .. "]";
end
function gui.style(args)
return "style" .. gui.style_internal(args.selector, args.properties);
end
function gui.style_type(args)
return "style_type" .. gui.style_internal(args.selector, args.properties);
end
function gui.tooltip(args)
return string.format("tooltip[%s;%s]", args.id, args.text);
end
return gui;