/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27

« back to all changes in this revision

Viewing changes to zoetrope/init.lua

  • Committer: Josh C
  • Date: 2014-07-06 22:51:43 UTC
  • Revision ID: josh@9ix.org-20140706225143-q72jn0va7v4ssvyy
ignore lovebird, inspect

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        -- initial view, doesn't work
37
37
 
38
38
        love.errhand = function (message)
39
 
                if debugger._crashed then
40
 
                        debugger._originalErrhand(message)
41
 
                        return
42
 
                end
43
 
 
44
 
                if the.console and the.keys then
45
 
                        debugger._crashed = true
46
 
                        print(string.rep('=', 40))
47
 
                        print('\nCrash, ' .. message .. '\n')
48
 
                        print(debug.traceback())
49
 
                        print('\n' .. string.rep('=', 40) .. '\n')
50
 
                        the.console:show()
51
 
                        love.audio.stop()
52
 
 
53
 
                        -- enter a mini event loop, just updating the
54
 
                        -- console and keys
55
 
 
56
 
                        local elapsed = 0
57
 
 
58
 
                        while true do
59
 
                                if love.event then
60
 
                                        love.event.pump()
61
 
                                        
62
 
                                        for e, a, b, c, d in love.event.poll() do
63
 
                                                if e == 'quit' then
64
 
                                                        if not love.quit or not love.quit() then return end
65
 
                                                end
66
 
 
67
 
                                                love.handlers[e](a, b, c, d)
68
 
                                        end
69
 
                                end
70
 
 
71
 
                                if love.timer then
72
 
                                        love.timer.step()
73
 
                                        elapsed = love.timer.getDelta()
74
 
                                end
75
 
 
76
 
                                the.keys:startFrame(elapsed)
77
 
                                the.console:startFrame(elapsed)
78
 
                                the.keys:update(elapsed)
79
 
                                the.console:update(elapsed)
80
 
                                the.keys:endFrame(elapsed)
81
 
                                the.console:endFrame(elapsed)
82
 
 
83
 
                                if the.keys:pressed('escape') then
84
 
                                        if not love.quit or not love.quit() then return end
85
 
                                end
86
 
 
87
 
                                if love.graphics then
88
 
                                        love.graphics.clear()
89
 
                                        if love.draw then
90
 
                                                the.console:draw()
91
 
                                        end
92
 
                                end
93
 
 
94
 
                                if love.timer then love.timer.sleep(0.02) end
95
 
                                if love.graphics then love.graphics.present() end
96
 
                        end
97
 
                else
98
 
                        debugger._originalErrhand(message)
99
 
                end
 
39
                if debugger._handleCrash then debugger._handleCrash(message) end
100
40
        end
101
41
end
102
42
 
106
46
        setmetatable(_G, {
107
47
                __index = function (table, key)
108
48
                        local info = debug.getinfo(2, 'Sl')
 
49
                        local print = debugger.unsourcedPrint or print
109
50
                        print('Warning: accessing undefined global ' .. key .. ', ' ..
110
51
                                  info.short_src .. ' line ' .. info.currentline)
111
52
                end
140
81
require 'zoetrope.ui.cursor'
141
82
require 'zoetrope.ui.textinput'
142
83
 
143
 
require 'zoetrope.utils.debug'
144
84
require 'zoetrope.utils.factory'
145
85
require 'zoetrope.utils.recorder'
146
86
require 'zoetrope.utils.storage'
147
87
require 'zoetrope.utils.subview'
148
88
 
 
89
if DEBUG then
 
90
        require 'zoetrope.debug.instrument'
 
91
        require 'zoetrope.debug.console'
 
92
        require 'zoetrope.debug.locals'
 
93
        require 'zoetrope.debug.performance'
 
94
        require 'zoetrope.debug.shortcuts'
 
95
        require 'zoetrope.debug.stack'
 
96
        require 'zoetrope.debug.stepper'
 
97
        require 'zoetrope.debug.watch'
 
98
        require 'zoetrope.debug.debugger'
 
99
end
 
100
 
149
101
-- simple load function to bootstrap the app if love.load() hasn't already been defined;
150
102
-- defining it again after this works fine as well
151
103