/traderous

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

« back to all changes in this revision

Viewing changes to trade_view.lua

  • Committer: Josh C
  • Date: 2013-06-15 19:58:24 UTC
  • Revision ID: josh@9ix.org-20130615195824-62r7gwrujgyijmh9
prices, buttons

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
                    x = boxR - 80,
50
50
                    y = boxT + 10 + (i-1) * lh - 1,
51
51
                    label = Text:new{ text = 'BUY', x = 1 },
52
 
                    onMouseDown = function (self)
53
 
                                     the.player:buy(good[1], good[2])
54
 
                                  end
55
52
                 }
56
53
                 local tw, th = b.label:getSize()
57
54
                 b.background = Fill:new{
65
62
                    x = boxR - 40,
66
63
                    y = boxT + 10 + (i-1) * lh - 1,
67
64
                    label = Text:new{ text = 'SELL', x = 1 },
68
 
                    onMouseDown = function (self)
69
 
                                     the.player:sell(good[1], good[2])
70
 
                                  end
71
65
                 }
72
66
                 local tw, th = b.label:getSize()
73
67
                 b.background = Fill:new{
76
70
                    height = th
77
71
                 }
78
72
                 self:add(b)
 
73
 
79
74
              end
80
 
 
81
 
              local b = Button:new{
82
 
                 x = boxL, y = boxT,
83
 
                 label = Text:new{ text = 'Close', x = 3, y = 2 },
84
 
                 onMouseDown = function()
85
 
                                  self:close()
86
 
                               end
87
 
              }
88
 
 
89
 
              local tw, th = b.label:getSize()
90
 
              b.background = Fill:new{
91
 
                 fill = {100,100,100},
92
 
                 width = tw + 7,
93
 
                 height = th + 4
94
 
              }
95
 
              b.x = boxR - b.background.width - 10
96
 
              b.y = boxT + 400 - b.background.height - 10
97
 
 
98
 
              self:add(b)
99
 
 
100
 
              self.playerMoney = Text:new{
101
 
                 text = 'Your money: ',
102
 
                 width = 200,
103
 
                 x = boxL + 10,
104
 
                 y = boxT + 400 - th - 10
105
 
              }
106
 
              self:add(self.playerMoney)
107
 
 
108
 
              -- give the buttons a cycle to get out of the T/L corner
109
 
              self:update(0)
110
75
           end,
111
76
   activate = function (self)
112
77
                 the.cursor.visible = false
115
80
 
116
81
                 Subview.activate(self)
117
82
              end,
118
 
   close = function (self)
119
 
              the.cursor.visible = true
120
 
              love.mouse.setVisible(false)
121
 
              love.mouse.setGrab(true)
122
 
 
123
 
              self:deactivate()
124
 
           end,
125
 
   onUpdate = function (self)
126
 
                 if the.keys:justPressed('escape') then
127
 
                    self:close()
128
 
                 end
129
 
 
130
 
                 self.playerMoney.text = 'Your money: ' .. the.player.money
131
 
              end
 
83
 
132
84
}
 
 
b'\\ No newline at end of file'