Skip to content

Commit

Permalink
Fetch event callbacks from love instead of hardcoding it
Browse files Browse the repository at this point in the history
  • Loading branch information
vrld committed May 30, 2015
1 parent c06e8e6 commit 5c9d51d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions gamestate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ end

function GS.pop(...)
assert(#stack > 1, "No more states to pop!")
local pre, to = stack[#stack], stack[#stack-1]
local pre, to = stack[#stack], stack[#stack-1]
stack[#stack] = nil
;(pre.leave or __NULL__)(pre)
return (to.resume or __NULL__)(to, pre, ...)
Expand All @@ -67,13 +67,11 @@ function GS.current()
return stack[#stack]
end

local all_callbacks = {
'draw', 'errhand', 'focus', 'keypressed', 'keyreleased', 'mousefocus',
'mousemoved', 'mousepressed', 'mousereleased', 'quit', 'resize',
'textinput', 'threaderror', 'update', 'visible', 'gamepadaxis',
'gamepadpressed', 'gamepadreleased', 'joystickadded', 'joystickaxis',
'joystickhat', 'joystickpressed', 'joystickreleased', 'joystickremoved'
}
-- fetch event callbacks from love.handlers
local all_callbacks = { 'draw', 'errhand', 'update' }
for k in pairs(love.handlers) do
all_callbacks[#all_callbacks+1] = k
end

function GS.registerEvents(callbacks)
local registry = {}
Expand Down

0 comments on commit 5c9d51d

Please sign in to comment.