Page 7 of 8

Re: Quickie [was: Immediate Mode Gui]

Posted: Mon Jun 30, 2014 8:24 am
by Marypop
Hi,

I am very new to Löve, so this question is probably silly - but I could not find an answer in the discussion above.

I would like to be able to customize differently each button (for instance set the button 1 background to image1, the button 2 background to image2, etc).
So I can't really change the style-default file.

Is there any way to do something like that :

Code: Select all


function love.load()
	image1 = love.graphics.newImage("Images/Button1.png")
end

function love.update(dt)
      if gui.Button ({text = "Blabla",image1, pos = {300, 200}, size = {200, 50}}) 
         	then -- do something
      end
end

Thanks a lot !

Re: Quickie [was: Immediate Mode Gui]

Posted: Mon Jun 30, 2014 3:15 pm
by murks
As far as I can tell you need to write your own button class. You can base it on the default button class.
You also need to add your new class to init.lua and style-default.lua.

Re: Quickie [was: Immediate Mode Gui]

Posted: Fri Jul 18, 2014 7:44 pm
by Lolocks
I like this and I'd love to use it.

But can you provide instructions on how to add it to one's current project?

Re: Quickie [was: Immediate Mode Gui]

Posted: Fri Jul 18, 2014 10:11 pm
by Lolocks
No seriously there's like nothing anywhere with instructions on how I can add Quickie to my current project. Could anyone help?

Re: Quickie [was: Immediate Mode Gui]

Posted: Sat Jul 19, 2014 7:37 am
by flyingjam
You load the library by adding something like

Code: Select all

gui = require "Quickie"
to the top of your main/game lua (in this case, move the folder with all the library files into where main.lua is and name it 'Quickie'.). From then on, you can just call the function to add a button or whatever form you want in update. Make sure to draw it. Here's some super simple example code

Code: Select all

gui = require "Quickie"

function love.load()
end

function love.update(dt)
gui.Button{text = "foo"} --this creates a button that does nothing with the text "foo"
if gui.Button{text = "bar", pos = {50, 50}} then --this creates a button that has the text "bar", a position of 50,50, and prints "foobar" when you click on it. The functions you call return true if they are activated.
print("foobar")
end

end

function love.draw()
gui.core.draw()
end

You can generally get how to use most of them from looking at the example code on github.

Re: Quickie [was: Immediate Mode Gui]

Posted: Sat Jul 19, 2014 8:34 am
by murks
I wish I could release my game (still waiting for a single asset to be replaced). There you could see how it is used in a real game and also how I solved some of the problems I encountered along the way (keyboard focus with multiple menu screens, sound on button mouseover).

From my experience I'd say only use quickie if what you need is really simple, like a single menu screen for example. Mind you, I don't have any experience with the ohter Löve GUIs, but I'll try one of those for my next project.

Re: Quickie [was: Immediate Mode Gui]

Posted: Sat Jul 19, 2014 2:56 pm
by Lolocks
flyingjam wrote:You load the library by adding something like

Code: Select all

gui = require "Quickie"
to the top of your main/game lua (in this case, move the folder with all the library files into where main.lua is and name it 'Quickie'.). From then on, you can just call the function to add a button or whatever form you want in update. Make sure to draw it. Here's some super simple example code

Code: Select all

gui = require "Quickie"

function love.load()
end

function love.update(dt)
gui.Button{text = "foo"} --this creates a button that does nothing with the text "foo"
if gui.Button{text = "bar", pos = {50, 50}} then --this creates a button that has the text "bar", a position of 50,50, and prints "foobar" when you click on it. The functions you call return true if they are activated.
print("foobar")
end

end

function love.draw()
gui.core.draw()
end

You can generally get how to use most of them from looking at the example code on github.
Thanks!
Also, I don't have to keep the .gitignore file, correct?

Re: Quickie [was: Immediate Mode Gui]

Posted: Sat Jul 19, 2014 9:50 pm
by murks
You don't need to keep a .gitignore file or .git directory if all you want to do is use quickie. Both are just related to version control and are not necessary for quickie to work.

Re: Quickie [was: Immediate Mode Gui]

Posted: Fri Sep 12, 2014 6:30 pm
by danbo
Hi there! I hope I haven't missed an answer to this question, but I'd like to override the mouse position getter for Quickie. I don't really know much about metatables etc, but given that it's mentioned in this commit, how do I do this?

https://github.com/vrld/Quickie/blob/master/mouse.lua

Love the library btw

Re: Quickie [was: Immediate Mode Gui]

Posted: Fri Jan 23, 2015 4:25 pm
by Snuux
Good day! How can I change the color of a separate block of text (label for example)?