/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-09 01:26:36 UTC
  • Revision ID: josh@9ix.org-20130509012636-1hgzcgai2xtj0lfw
dead zone with no acceleration

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
 
                 onMouseUp = function()
79
 
                                self:close()
80
 
                                the.app.view = GameView:new{newWorld = true}
81
 
                             end
82
 
              }
83
 
 
84
 
              self:add(b)
85
 
 
86
 
              b = Button:new{
87
 
                 x = boxL + boxW / 2 - buttonWidth / 2,
88
 
                 y = boxT + 40 + 2 * lh,
89
 
                 label = Text:new{
90
 
                    text = 'Quit',
91
 
                    --x = 3, y = 1,
92
 
                    align = 'center',
93
 
                    font = 16,
94
 
                    width = buttonWidth
95
 
                 },
96
 
                 background = Fill:new{
97
 
                    fill = {100,100,100},
98
 
                    width = buttonWidth,
99
 
                    height = buttonHeight,
100
 
                 },
101
 
                 onMouseUp = function()
102
 
                                the.app:quit()
103
 
                             end
104
 
              }
105
 
 
106
 
              self:add(b)
107
 
 
108
 
              -- give the buttons a cycle to get out of the T/L corner
109
 
              self:update(0)
110
 
           end,
111
 
   activate = function (self)
112
 
                 the.cursor.visible = false
113
 
                 love.mouse.setVisible(true)
114
 
                 love.mouse.setGrab(false)
115
 
                 love.mouse.setPosition(the.app.width / 2, self.boxT + 10 )
116
 
 
117
 
                 Subview.activate(self)
118
 
              end,
119
 
   close = function (self)
120
 
              the.cursor.visible = true
121
 
              love.mouse.setVisible(false)
122
 
              love.mouse.setGrab(true)
123
 
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
124
 
 
125
 
              self:deactivate()
126
 
           end,
127
 
   onUpdate = function (self)
128
 
                 if the.keys:justPressed('escape') then
129
 
                    self:close()
130
 
                 elseif the.keys:justPressed('q') then
131
 
                    the.app:quit()
132
 
                 end
133
 
              end
134
 
}
 
 
b'\\ No newline at end of file'