2024-02-11 06:19:54 +00:00
|
|
|
state_menu=klass()
|
|
|
|
function state_menu:init()
|
2024-02-11 22:59:20 +00:00
|
|
|
self.selection=1
|
2024-02-12 00:48:11 +00:00
|
|
|
self.frame=0
|
2024-02-11 22:59:20 +00:00
|
|
|
self.options={
|
|
|
|
menu_option:new(function() return "excavate" end,function()
|
2024-02-11 23:51:56 +00:00
|
|
|
main.state_manager:push(state_excavate_menu:new(self))
|
2024-02-11 22:59:20 +00:00
|
|
|
end),
|
|
|
|
menu_option:new(function() return "archaeology" end,function()
|
2024-02-11 23:51:56 +00:00
|
|
|
main.state_manager:push(state_archaeology:new())
|
2024-02-11 22:59:20 +00:00
|
|
|
end),
|
|
|
|
menu_option:new(),
|
2024-02-12 04:18:01 +00:00
|
|
|
menu_option:new(function()
|
|
|
|
local pref=completion_tracker:get_music_preference()
|
|
|
|
if (pref) return "stop music"
|
|
|
|
return "start music"
|
|
|
|
end,function()
|
|
|
|
completion_tracker:set_music_preference(not completion_tracker:get_music_preference())
|
2024-02-11 22:59:20 +00:00
|
|
|
end),
|
|
|
|
menu_option:new(function() return "reset data" end,function()
|
2024-02-11 23:51:56 +00:00
|
|
|
main.state_manager:push(state_reset_menu:new(self))
|
2024-02-11 22:59:20 +00:00
|
|
|
end)
|
|
|
|
}
|
2024-02-11 06:19:54 +00:00
|
|
|
end
|
|
|
|
function state_menu:enter() end
|
2024-02-11 23:51:56 +00:00
|
|
|
function state_menu:exit() end
|
2024-02-11 06:19:54 +00:00
|
|
|
|
2024-02-11 22:59:20 +00:00
|
|
|
function state_menu:reenter()
|
|
|
|
self.selection=1
|
|
|
|
end
|
2024-02-11 23:51:56 +00:00
|
|
|
function state_menu:suspend()
|
|
|
|
self.selection=nil
|
|
|
|
end
|
2024-02-11 06:19:54 +00:00
|
|
|
|
|
|
|
function state_menu:update()
|
2024-02-12 00:48:11 +00:00
|
|
|
self.frame+=1
|
|
|
|
self.frame%=1024
|
2024-02-12 04:54:01 +00:00
|
|
|
if (btnp(1) or btnp(4)) sounds:menu() self.options[self.selection]:cb()
|
2024-02-11 22:59:20 +00:00
|
|
|
|
|
|
|
local vel=0
|
|
|
|
if (btnp(2)) vel-=1
|
|
|
|
if (btnp(3)) vel+=1
|
|
|
|
if vel!=0 then
|
|
|
|
while true do
|
|
|
|
self.selection=(self.selection+vel-1)%#self.options+1
|
|
|
|
if (self.options[self.selection].cb!=nil) break
|
|
|
|
end
|
|
|
|
end
|
2024-02-11 06:19:54 +00:00
|
|
|
end
|
|
|
|
function state_menu:draw()
|
|
|
|
cls(13)
|
2024-02-12 00:48:11 +00:00
|
|
|
self:draw_bg()
|
2024-02-11 22:59:20 +00:00
|
|
|
local optionsh=1
|
|
|
|
for o in all(self.options) do
|
|
|
|
optionsh+=2
|
|
|
|
if (o.cb) optionsh+=4
|
|
|
|
end
|
|
|
|
local totalh=optionsh+32
|
|
|
|
local y=128-totalh-1--64-totalh\2
|
2024-02-12 00:48:11 +00:00
|
|
|
-- rectfill(68,y,126,y+totalh-1,13)
|
2024-02-12 01:58:34 +00:00
|
|
|
local y0=y
|
2024-02-11 22:59:20 +00:00
|
|
|
spr(64,68,y,7,3)
|
|
|
|
y+=22
|
|
|
|
line(68,y,126,y,15)
|
|
|
|
y+=2
|
|
|
|
local optionsy=y+1
|
|
|
|
rectfill(68,y,126,y+optionsh-1,4)
|
|
|
|
y+=optionsh+1
|
|
|
|
line(68,y,126,y,15)
|
|
|
|
y+=2
|
|
|
|
print("by pyrex & nyeo",68,y,15)
|
|
|
|
|
|
|
|
local y1=y
|
|
|
|
|
|
|
|
local x=69
|
|
|
|
y=optionsy
|
|
|
|
for i=1,#self.options do
|
|
|
|
local o=self.options[i]
|
|
|
|
if (self.selection==i) spr(71,x-7+cos(time())*0.5,y)
|
|
|
|
local fg=13
|
|
|
|
if (o.cb) fg=15
|
|
|
|
if o.name then
|
|
|
|
print(o.name(),x,y,fg)
|
|
|
|
y+=6
|
|
|
|
else
|
|
|
|
line(x-1,y,x+57,y,fg)
|
|
|
|
y+=2
|
|
|
|
end
|
|
|
|
end
|
2024-02-12 01:58:34 +00:00
|
|
|
|
|
|
|
-- metascore
|
|
|
|
local metascore=completion_tracker:get_metascore()
|
|
|
|
if metascore>0 then
|
|
|
|
spr(72,66,y0-9,2,1)
|
|
|
|
print("="..tostr(metascore,2),79,y0-6,6)
|
|
|
|
end
|
2024-02-11 22:59:20 +00:00
|
|
|
end
|
|
|
|
|
2024-02-12 00:48:11 +00:00
|
|
|
function state_menu:draw_bg()
|
|
|
|
pal(7,1)
|
|
|
|
pal(13,1)
|
|
|
|
local m=128-(self.frame/2)%128
|
|
|
|
for col=-8,7 do
|
|
|
|
for row=-3,7 do
|
|
|
|
local realx=flr(col*32-row*16)+m
|
|
|
|
local realy=flr(row*30-col*12)
|
|
|
|
spr(76,realx,realy,4,4)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
pal()
|
|
|
|
end
|
|
|
|
|
2024-02-11 22:59:20 +00:00
|
|
|
menu_option=klass()
|
|
|
|
function menu_option:init(name,cb)
|
|
|
|
self.name=name
|
|
|
|
self.cb=cb
|
2024-02-11 06:19:54 +00:00
|
|
|
end
|