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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
PauseView = Subview:extend {
drawParent = true, --default?
onNew = function (self)
local boxW = 200
local boxH = 130
local boxL = the.app.width / 2 - boxW / 2
local boxT = the.app.height / 2 - boxH / 2
local boxR = boxL + boxW
local boxB = boxT + boxH
self.boxT = boxT
local lh = 26 -- line height
local buttonHeight = lh - 6
local buttonWidth = 150
self:add(Fill:new{
fill = {255,255,255},
x = boxL - 1,
y = boxT - 1,
width = boxW + 2,
height = boxH + 2,
})
self:add(Fill:new{
fill = {0,0,0},
x = boxL,
y = boxT,
width = boxW,
height = boxH,
})
self:add(Text:new{
text = 'Paused',
x = boxL,
y = boxT + 10,
width = boxW,
font = 16,
align = 'center'
})
local b = Button:new{
x = boxL + boxW / 2 - buttonWidth / 2,
y = boxT + 40,
label = Text:new{
text = 'Resume',
--x = 3, y = 1,
align = 'center',
font = 16,
width = buttonWidth
},
background = Fill:new{
fill = {100,100,100},
width = buttonWidth,
height = buttonHeight,
},
onMouseUp = function()
self:close()
end
}
self:add(b)
b = Button:new{
x = boxL + boxW / 2 - buttonWidth / 2,
y = boxT + 40 + lh,
label = Text:new{
text = 'Start new game',
--x = 3, y = 1,
align = 'center',
font = 16,
width = buttonWidth
},
background = Fill:new{
fill = {100,100,100},
width = buttonWidth,
height = buttonHeight,
},
onMouseUp = function()
self:close()
the.app.view = GameView:new{newWorld = true}
end
}
self:add(b)
b = Button:new{
x = boxL + boxW / 2 - buttonWidth / 2,
y = boxT + 40 + 2 * lh,
label = Text:new{
text = 'Quit',
--x = 3, y = 1,
align = 'center',
font = 16,
width = buttonWidth
},
background = Fill:new{
fill = {100,100,100},
width = buttonWidth,
height = buttonHeight,
},
onMouseUp = function()
the.app:quit()
end
}
self:add(b)
-- give the buttons a cycle to get out of the T/L corner
self:update(0)
end,
activate = function (self)
the.cursor.visible = false
love.mouse.setVisible(true)
love.mouse.setGrab(false)
love.mouse.setPosition(the.app.width / 2, self.boxT + 10 )
Subview.activate(self)
end,
close = function (self)
the.cursor.visible = true
love.mouse.setVisible(false)
love.mouse.setGrab(true)
love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
self:deactivate()
end,
onUpdate = function (self)
if the.keys:justPressed('escape') then
self:close()
elseif the.keys:justPressed('q') then
the.app:quit()
end
end
}
|