state_menu=klass() function state_menu:init() self.selection=1 self.frame=0 self.options={ menu_option:new(function() return "excavate" end,function() main.state_manager:push(state_excavate_menu:new(self)) end), menu_option:new(function() return "archaeology" end,function() main.state_manager:push(state_archaeology:new()) end), menu_option:new(), 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()) end), menu_option:new(function() return "reset data" end,function() main.state_manager:push(state_reset_menu:new(self)) end) } end function state_menu:enter() end function state_menu:exit() end function state_menu:reenter() self.selection=1 end function state_menu:suspend() self.selection=nil end function state_menu:update() self.frame+=1 self.frame%=1024 if (btnp(1) or btnp(4)) sounds:menu() self.options[self.selection]:cb() return 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 end function state_menu:draw() cls(13) self:draw_bg() 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 -- rectfill(68,y,126,y+totalh-1,13) local y0=y 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 -- 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 end 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 menu_option=klass() function menu_option:init(name,cb) self.name=name self.cb=cb end