Page 1 of 1
GUI library with non-mouse navigation?
Posted: Wed Oct 10, 2012 11:38 am
by SFX
I want to add gamepad support to the game I'm making for the
October Challenge, and I've run into a bit of a problem: the GUI library I'm using (gspot) doesn't support non-mouse navigation. Does anybody know of a GUI library that supports non-mouse navigation? I've yet to find one, and I'm trying to avoid reinventing the wheel.
Re: GUI library with non-mouse navigation?
Posted: Wed Oct 10, 2012 12:02 pm
by Roland_Yonaba
If by "non-mouse navigation" you meant being able to cycle though GUI items (buttons, inputs, etc...) using keyboard or/joysticks,
I don't think there's such a Gui lib.
But, you can still pick one of the existing GUis (or stick with Gspöt), require it, and add that feature by yourself.
Re: GUI library with non-mouse navigation?
Posted: Wed Oct 10, 2012 12:10 pm
by bartoleo
you are looking for a complete GUI?
or only basic controls to use in menu and options?
Re: GUI library with non-mouse navigation?
Posted: Wed Oct 10, 2012 12:31 pm
by vrld
Quickie allows keyboard navigation. Because there is still no documentation, here is a shortened example taken from
Spaceout. Cycling order is defined by order of appearance of the widgets.
Code: Select all
function st:init()
gui.keyboard.cycle.prev = {key = 'up'}
gui.keyboard.cycle.next = {key = 'down'}
gui.mouse.disable()
end
function st:update(dt)
love.graphics.setFont(Font.slkscr[40])
gui.group.push{grow = "down", size = {400,40}, spacing = 5, pos = {(W-400)/2, H-230}}
if not show_credits then
if gui.Button{text = "Start"} then
tween(1, fade_color, {0,0,0,255}, 'linear', function() GS.switch(State.game) end)
end
if gui.Button{text = "Highscores"} then
tween(1, fade_color, {0,0,0,255}, 'linear', function() GS.switch(State.highscores) end)
end
if gui.Button{text = "Credits"} then
show_credits = true
end
if gui.Button{text = "Exit"} then
love.event.push("quit")
end
else
-- omitted: credits
if gui.Button{text = "Back"} then
show_credits = false
gui.keyboard.clearFocus() -- necessary so we highlight <Start> when going back
end
end
gui.group.pop{}
end
function st:draw()
-- stuff
gui.core.draw()
-- more stuff
end
function st:keypressed(key, code)
-- propagate keyboard events to quickie
return gui.keyboard.pressed(key, code)
end
For joystick navigation, simply call gui.keyboard.pressed(key, code) in love.joystickpressed.
Edit: just updated quickie to include gui.mouse.disable()
Re: GUI library with non-mouse navigation?
Posted: Wed Oct 10, 2012 2:18 pm
by Zeliarden
Re: GUI library with non-mouse navigation?
Posted: Thu Oct 11, 2012 1:46 pm
by SFX
Thanks for the suggestions. I think I'll just go with vrld's suggestion for now and use Quickie. It has automatic layouts, which will be absurdly useful. If I have time (which seems to be an increasingly large if), I may try to make my own tiny GUI library.
Re: GUI library with non-mouse navigation?
Posted: Thu Oct 11, 2012 3:18 pm
by josefnpat
You can also check out my
LoveMenu if you like, but there isn't any documentation.