2020-06-02 14:01:11 +02:00
|
|
|
local gui = {};
|
|
|
|
|
|
|
|
function gui.bg9(args)
|
2020-06-03 01:36:33 +02:00
|
|
|
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));
|
2020-06-02 14:01:11 +02:00
|
|
|
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)
|
2020-06-03 01:36:33 +02:00
|
|
|
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 "");
|
2020-06-02 14:01:11 +02:00
|
|
|
|
|
|
|
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;
|