/traderous

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

« back to all changes in this revision

Viewing changes to pause_view.lua

  • Committer: Josh C
  • Date: 2013-05-05 00:41:10 UTC
  • Revision ID: josh@9ix.org-20130505004110-hmcvz9payau6q0io
maxVelocity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
PauseView = Subview:extend {
2
 
   drawParent = true, --default?
3
 
   onNew = function (self)
4
 
              local boxW = 200
5
 
              local boxH = 130
6
 
              local boxL = the.app.width / 2 - boxW / 2
7
 
              local boxT = the.app.height / 2 - boxH / 2
8
 
              local boxR = boxL + boxW
9
 
              local boxB = boxT + boxH
10
 
              self.boxT = boxT
11
 
 
12
 
              local lh = 26 -- line height
13
 
              local buttonHeight = lh - 6
14
 
              local buttonWidth = 150
15
 
 
16
 
              self:add(Fill:new{
17
 
                          fill = {255,255,255},
18
 
                          x = boxL - 1,
19
 
                          y = boxT - 1,
20
 
                          width = boxW + 2,
21
 
                          height = boxH + 2,
22
 
                       })
23
 
 
24
 
              self:add(Fill:new{
25
 
                          fill = {0,0,0},
26
 
                          x = boxL,
27
 
                          y = boxT,
28
 
                          width = boxW,
29
 
                          height = boxH,
30
 
                       })
31
 
 
32
 
              self:add(Text:new{
33
 
                          text = 'Paused',
34
 
                          x = boxL,
35
 
                          y = boxT + 10,
36
 
                          width = boxW,
37
 
                          font = 16,
38
 
                          align = 'center'
39
 
                       })
40
 
 
41
 
              local b = Button:new{
42
 
                 x = boxL + boxW / 2 - buttonWidth / 2,
43
 
                 y = boxT + 40,
44
 
                 label = Text:new{
45
 
                    text = 'Resume',
46
 
                    --x = 3, y = 1,
47
 
                    align = 'center',
48
 
                    font = 16,
49
 
                    width = buttonWidth
50
 
                 },
51
 
                 background = Fill:new{
52
 
                    fill = {100,100,100},
53
 
                    width = buttonWidth,
54
 
                    height = buttonHeight,
55
 
                 },
56
 
                 onMouseUp = function()
57
 
                                  self:close()
58
 
                               end
59
 
              }
60
 
 
61
 
              self:add(b)
62
 
 
63
 
              b = Button:new{
64
 
                 x = boxL + boxW / 2 - buttonWidth / 2,
65
 
                 y = boxT + 40 + lh,
66
 
                 label = Text:new{
67
 
                    text = 'Start new game',
68
 
                    --x = 3, y = 1,
69
 
                    align = 'center',
70
 
                    font = 16,
71
 
                    width = buttonWidth
72
 
                 },
73
 
                 background = Fill:new{
74
 
                    fill = {100,100,100},
75
 
                    width = buttonWidth,
76
 
                    height = buttonHeight,
77
 
                 },
78
 
                 onMouseDown = function()
79
 
                                  self:close()
80
 
                                  print('hi')
81
 
                                  the.app.view = GameView:new()
82
 
                               end
83
 
              }
84
 
 
85
 
              self:add(b)
86
 
 
87
 
              b = Button:new{
88
 
                 x = boxL + boxW / 2 - buttonWidth / 2,
89
 
                 y = boxT + 40 + 2 * lh,
90
 
                 label = Text:new{
91
 
                    text = 'Quit',
92
 
                    --x = 3, y = 1,
93
 
                    align = 'center',
94
 
                    font = 16,
95
 
                    width = buttonWidth
96
 
                 },
97
 
                 background = Fill:new{
98
 
                    fill = {100,100,100},
99
 
                    width = buttonWidth,
100
 
                    height = buttonHeight,
101
 
                 },
102
 
                 onMouseDown = function()
103
 
                                  the.app:quit()
104
 
                               end
105
 
              }
106
 
 
107
 
              self:add(b)
108
 
 
109
 
              -- give the buttons a cycle to get out of the T/L corner
110
 
              self:update(0)
111
 
           end,
112
 
   activate = function (self)
113
 
                 the.cursor.visible = false
114
 
                 love.mouse.setVisible(true)
115
 
                 love.mouse.setGrab(false)
116
 
                 love.mouse.setPosition(the.app.width / 2, self.boxT + 10 )
117
 
 
118
 
                 Subview.activate(self)
119
 
              end,
120
 
   close = function (self)
121
 
              the.cursor.visible = true
122
 
              love.mouse.setVisible(false)
123
 
              love.mouse.setGrab(true)
124
 
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
125
 
 
126
 
              self:deactivate()
127
 
           end,
128
 
   onUpdate = function (self)
129
 
                 if the.keys:justPressed('escape') then
130
 
                    self:close()
131
 
                 elseif the.keys:justPressed('q') then
132
 
                    the.app:quit()
133
 
                 end
134
 
              end
135
 
}
 
 
b'\\ No newline at end of file'