1
TradeView = Subview:extend {
2
drawParent = true, --default?
3
onNew = function (self)
4
-- create all the interface bits from the planet
5
-- and add them to the view
7
local boxL = the.app.width / 2 - 200
8
local boxT = the.app.height / 2 - 200
9
local boxR = boxL + 400
11
local lh = 17 -- line height
29
for i, good in ipairs(self.planet.goods) do
33
y = boxT + 10 + (i-1) * lh,
42
y = boxT + 10 + (i-1) * lh,
50
y = boxT + 10 + (i-1) * lh - 1,
51
label = Text:new{ text = 'BUY', x = 1 },
52
onMouseDown = function (self)
53
the.player:buy(good[1], good[2])
56
local tw, th = b.label:getSize()
57
b.background = Fill:new{
66
y = boxT + 10 + (i-1) * lh - 1,
67
label = Text:new{ text = 'SELL', x = 1 },
68
onMouseDown = function (self)
69
the.player:sell(good[1], good[2])
72
local tw, th = b.label:getSize()
73
b.background = Fill:new{
83
label = Text:new{ text = 'Close', x = 3, y = 2 },
84
onMouseDown = function()
89
local tw, th = b.label:getSize()
90
b.background = Fill:new{
95
b.x = boxR - b.background.width - 10
96
b.y = boxT + 400 - b.background.height - 10
100
self.playerMoney = Text:new{
101
text = 'Your money: ',
104
y = boxT + 400 - th - 10
106
self:add(self.playerMoney)
108
-- give the buttons a cycle to get out of the T/L corner
111
activate = function (self)
112
the.cursor.visible = false
113
love.mouse.setVisible(true)
114
love.mouse.setGrab(false)
116
Subview.activate(self)
118
close = function (self)
119
the.cursor.visible = true
120
love.mouse.setVisible(false)
121
love.mouse.setGrab(true)
125
onUpdate = function (self)
126
if the.keys:justPressed('escape') then
130
self.playerMoney.text = 'Your money: ' .. the.player.money
b'\\ No newline at end of file'