1 menu_elements
= { -- relative to playfield size and position
4 x
= .2, y
= 0, w
= .6, h
= .2,
5 content
= function () return level_labels
[game
.currentlevel
] .. ' ' .. game
.currentlevel
end,
6 onclick
= function () game
:change_screen('playfield') end,
9 x
= 0, y
= 0, w
= .2, h
= .2,
11 onclick
= function() setuplevel(game
.currentlevel
- 1) end
14 x
= .8, y
= 0, w
= .2, h
= .2,
16 onclick
= function () setuplevel(game
.currentlevel
+ 1) end
20 x
= 0, y
= 0, w
= 1, h
= .2,
21 content
= function () return trinkets
.selected
.. '. ' .. trinkets
[trinkets
.held
[trinkets
.selected]]
.name
end,
24 x
= .25, y
= .25, w
= .5, h
= .5,
28 x
= 0, y
= .4, w
= .2, h
= .2,
30 onclick
= function () trinkets
:show(-1) end,
33 x
= .8, y
= .4, w
= .2, h
= .2,
35 onclick
= function () trinkets
:show(1) end,
39 x
= 0, y
= .8, w
= .2, h
= .2,
41 onclick
= function () game
:change_screen('menu_levels') end,
44 x
= .2, y
= .8, w
= .2, h
= .2,
46 onclick
= function () game
:change_screen('playfield') end,
49 x
= .4, y
= .8, w
= .2, h
= .2,
51 onclick
= function () game
:change_screen('menu_objects') end,
54 x
= .8, y
= .8, w
= .2, h
= .2,
56 onclick
= function () game
:change_screen('playfield') end,
59 x
= 0, y
= 0, w
= 1, h
= 1,
60 content
= 'My journey began when arrows invaded every room of my apartment, including my bedroom.',
61 onclick
= function () game
:change_screen('playfield') end,
63 story_adventurer_map
= {
64 x
= 0, y
= 0, w
= 1, h
= 1,
65 content
= 'You search the remains of a dead adventurer and find a map.',
66 onclick
= function () game
:change_screen('playfield') end,
68 story_adventurer_nothing
= {
69 x
= 0, y
= 0, w
= 1, h
= 1,
70 content
= 'You search the remains of a dead adventurer and find nothing special.',
71 onclick
= function () game
:change_screen('playfield') end,
76 function get_absolute_dimensions(e
)
78 e
.x
* screen
.playfieldsize
+ screen
.playfieldx
* screen
.tilesize
,
79 e
.y
* screen
.playfieldsize
+ screen
.playfieldy
* screen
.tilesize
,
80 e
.w
* screen
.playfieldsize
,
81 e
.h
* screen
.playfieldsize
85 function draw_menu_elements()
86 for i
, e
in ipairs(menu_elements
.drawn
) do
87 local x
, y
, w
, h
= get_absolute_dimensions(e
)
88 local content
= e
.content
89 love
.graphics
.setColor(0,0,1)
90 love
.graphics
.rectangle('fill', x
, y
, w
, h
)
91 love
.graphics
.setColor(0,1,1)
92 love
.graphics
.rectangle('line', x
+ 2, y
+ 2, w
- 4, h
- 4)
93 love
.graphics
.setColor(1,1,1)
95 if type(content
) == 'function' then content
= content() end
96 love
.graphics
.setFont(screen
.defaultfont
)
97 local lines
= select(2, screen
.defaultfont
:getWrap(content
, w
- 4))
98 local offsety
= (h
- screen
.defaultfont
:getHeight() * #lines
) / 2
99 love
.graphics
.printf(content
, x
+ 2, y
+ 2 + offsety
, w
- 4 ,'center')
106 love
.graphics
.setColor(.5,.5,.5)
107 love
.graphics
.draw(screen
.bgcanvas
)
108 local e
= menu_elements
109 if game
.screen
== 'menu_levels' then
110 menu_elements
.drawn
= e
.drawn
or {
111 e
.current_level
, e
.next_level
, e
.previous_level
,
112 e
.levels
, e
.knowledge
, e
.objects
, e
.play
,
114 elseif game
.screen
== 'menu_objects' then
115 menu_elements
.drawn
= e
.drawn
or {
117 e
.big_object
, e
.previous_object
, e
.next_object
,
118 e
.levels
, e
.knowledge
, e
.objects
, e
.play
,
120 elseif game
.screen
== 'story_beginning' then
121 menu_elements
.drawn
= e
.drawn
or {
124 elseif game
.screen
== 'story_adventurer_map' then
125 menu_elements
.drawn
= e
.drawn
or {
126 e
.story_adventurer_map
128 elseif game
.screen
== 'story_adventurer_nothing' then
129 menu_elements
.drawn
= e
.drawn
or {
130 e
.story_adventurer_nothing
137 function menu_click(mx
, my
)
138 for i
, e
in ipairs(menu_elements
.drawn
) do
139 if e
.onclick
and isin(mx
, my
, get_absolute_dimensions(e
)) then