-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_interface.lua
57 lines (42 loc) · 1.51 KB
/
user_interface.lua
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
-- user_interface.lua -- the user interface
module('user_interface', package.seeall)
class 'MyUI' (UserInterface)
function MyUI:__init()
UserInterface.__init(self)
-- Panel
local atbg = UserInterfaceAnimation(Box(VP(4000, 200)))
atbg:setPosition(VP(0, 0))
self:addElement(atbg)
local atborder = UserInterfaceAnimation(Box(VP(4000, 5), 0x303030))
atborder:setPosition(VP(0, 200))
self:addElement(atborder)
local go = Action("Go to ", 1)
local interact = Action("Interact with ", 1)
local pickup = Action("Pick up ", 1)
local goButton = Button(Image("media/ui/walkto.png"), function() self:setAction(go); return 0 end)
goButton:setPosition(VP(0, 0))
self:addElement(goButton)
local interactButton = Button(Image("media/ui/interact.png"), function() self:setAction(interact); return 0 end)
interactButton:setPosition(VP(150, 0))
self:addElement(interactButton)
local pickupButton = Button(Image("media/ui/pickup.png"), function() self:setAction(pickup); return 0 end)
pickupButton:setPosition(VP(300, 0))
self:addElement(pickupButton)
-- Action text
local at = ActionText(Font("media/fonts/tommy_holloway.ttf", 40, 1))
at:setPosition(VP(600, 120))
at:setAlignmentX(0.0)
at:setAlignmentY(0.5)
self:setAction(go)
self:addElement(at)
end
function MyUI:handleEvent(evt, frameDuration)
local r = UserInterface.handleEvent(self, evt, frameDuration)
if r == EVENT_STATE_HANDLED then
return EVENT_STATE_HANDLED
end
return EVENT_STATE_UNHANDLED
end
function create()
return MyUI()
end