Github: https://github.com/meric/loveui.love
I've begun work on a new gui library for the LÖVE 2D game engine.
The ideal will be to provide a concise way and easily customizable way to include GUI widgets such as buttons, textfields, progress bars in their game.
One of the killer features is the ability to tag widgets with strings. You can then apply styles to widgets with that tag, or select widgets containing some set of tags.
Currently there is only the base class "widget" partially implemented. If anyone would like to assist in the library's implementation please do not hesitate to reply to this thread. Also please comment on the example code below, in regards to readability, usability, and conciseness.
Thanks
Example code:
Code: Select all
ui = require 'loveui/ui'
local context = ui.context()
function love.load()
context:add(
ui.style("ui.button tag1", {
left = 100, top = 100,
width = 50, height = 50,
bordercolor = {255, 0, 0, 255},
borderwidth = 4,
borderradius= 4,
backgroundcolor = {255, 255, 255, 255},
backgroundimage = "./button.png"}),
ui.button("ui.button tag1 tag2 tag3", {value = "Click"})
:onmousedown(
function(self, x, y, button)
print("mousedown", x, y, button)
end)
:onclick(
function(self, x, y, button)
print("click", x, y, button)
end))
end
function love.update(dt)
context:update(dt)
end
function love.draw()
context:draw()
end
function love.keypressed(key, unicode)
context:keypressed(key, unicode)
end
function love.keyreleased(key, unicode)
context:keyreleased(key, unicode)
end
function love.mousepressed(x, y, button)
context:mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
context:mousereleased(x, y, button)
end
Implement widget:drawbackground.
Implement widget border images in widget:drawborder function.
Complete button, textfield, progress bar widgets.
P.S A fun thing to try would be to set the border left color of the widget in the example code.
Change the relevant code to:
Code: Select all
context:add(
ui.style("ui.button tag1", {
left = 100, top = 100,
width = 50, height = 50,
borderleftcolor = {255, 255, 0, 255}, -- Sets border left color.
borderleftwidth = 8, -- Sets border left width.
bordercolor = {255, 0, 0, 255},
borderwidth = 4,
borderradius= 4,
backgroundcolor = {255, 255, 255, 255},
backgroundimage = "./button.png"}),