/ld27

To get this branch, use:
bzr branch /bzr/ld27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
-- copy references to existing globals so that
-- debug.reload() will have a correct initial starting point.

if DEBUG then
	-- remember initial state

	local _initialGlobals = {}
	local _initialPackages = {}

	for key, value in pairs(_G) do
		_initialGlobals[key] = value
	end

	for key, value in pairs(package.loaded) do
		-- it looks as though the type of a module
		-- that is currently being loaded, but hasn't
		-- completed is userdata

		if type(value) ~= 'userdata' then
			_initialPackages[key] = value
		end
	end

	debugger =
	{
		_initialGlobals = _initialGlobals,
		_initialPackages = _initialPackages,
		_originalErrhand = love.errhand,
		_crashed = false
	}

	-- replace crash handler
	-- we have to do this at this stage; there seems to be
	-- some magic that happens to connect to this function
	-- such that changing it later, even when creating the
	-- initial view, doesn't work

	love.errhand = function (message)
		if debugger._handleCrash then debugger._handleCrash(message) end
	end
end

-- Warn about accessing undefined globals in strict mode

if STRICT then
	setmetatable(_G, {
		__index = function (table, key)
			local info = debug.getinfo(2, 'Sl')
			local print = debugger.unsourcedPrint or print
			print('Warning: accessing undefined global ' .. key .. ', ' ..
				  info.short_src .. ' line ' .. info.currentline)
		end
	})
end

require 'zoetrope.core.class'

require 'zoetrope.core.app'
require 'zoetrope.core.cached'
require 'zoetrope.core.collision'
require 'zoetrope.core.globals'
require 'zoetrope.core.sprite'
require 'zoetrope.core.group'
require 'zoetrope.core.promise'
require 'zoetrope.core.timer'
require 'zoetrope.core.tween'
require 'zoetrope.core.view'

require 'zoetrope.input.gamepad'
require 'zoetrope.input.keys'
require 'zoetrope.input.mouse'

require 'zoetrope.sprites.animation'
require 'zoetrope.sprites.emitter'
require 'zoetrope.sprites.fill'
require 'zoetrope.sprites.map'
require 'zoetrope.sprites.text'
require 'zoetrope.sprites.tile'

require 'zoetrope.ui.button'
require 'zoetrope.ui.cursor'
require 'zoetrope.ui.textinput'

require 'zoetrope.utils.factory'
require 'zoetrope.utils.recorder'
require 'zoetrope.utils.storage'
require 'zoetrope.utils.subview'

if DEBUG then
	require 'zoetrope.debug.instrument'
	require 'zoetrope.debug.console'
	require 'zoetrope.debug.locals'
	require 'zoetrope.debug.performance'
	require 'zoetrope.debug.shortcuts'
	require 'zoetrope.debug.stack'
	require 'zoetrope.debug.stepper'
	require 'zoetrope.debug.watch'
	require 'zoetrope.debug.debugger'
end

-- simple load function to bootstrap the app if love.load() hasn't already been defined;
-- defining it again after this works fine as well

if not love.load then
	love.load = function()
		if the.app then
			-- if we only extended an app, instantiate it
			if not (the.app.view and the.app.meta) then the.app = the.app:new() end
			the.app:run()
		end
	end
end