Re: Gspöt - retained GUI lib
Posted: Mon Mar 12, 2018 5:53 am
Hey guys, I have been trying to create a little IRC client with Love2D, LuaIRC (https://github.com/JakobOvrum/LuaIRC) and Gspot, but before I go any further, I need some advice, or some clear direction, maybe I am even going off on the wrong path here, but my goal is to have every line input on IRC on its own press-able event, so I can tap it on my tablet, and be able to do something with it (double tap and it'll automatically quote the person I want to respond to, etc).
Can someone give me some bit of guidance on this idea?
Can someone give me some bit of guidance on this idea?
Code: Select all
gui = require('Gspot')
local irc = require "irc"
local sleep = require "socket".sleep
local s = irc.new{nick = "test"}
msgs = ""
nickname = ""
s:hook("OnChat", function(user, channel, message)
print(("[%s] %s: %s"):format(channel, user.nick, message)) --debug
msgs = message
nickname = user.nick
print(msgs)
end)
function love.load()
scrollgroup = gui:scrollgroup(nil, {0, gui.style.unit, 460, 200},group)
s:connect("localhost")
s:join("#test")
end
love.update = function(dt)
if msgs then scrollgroup:addchild(gui:text(msgs, {w = 400}), 'grid')
print(msgs) --debug
msgs=nil
end
gui:update(dt)
s:think()
end
love.draw = function()
--love.graphics.setColor(0, 255, 0, 255)
--love.graphics.print(("%s: %s"):format(nickname, msgs))
gui:draw()
end
love.keypressed = function(key, code, isrepeat)
end
love.textinput = function(key)
end
love.mousepressed = function(x, y, button)
gui:mousepress(x, y, button) -- pretty sure you want to register mouse events
end
love.mousereleased = function(x, y, button)
gui:mouserelease(x, y, button)
end
love.wheelmoved = function(x, y)
gui:mousewheel(x, y)
end
love.quit = function()
s:disconnect("bye")
end