state_menu=klass() function state_menu:init() self.selection=1 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() return "music" end,function() -- todo: music manager 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() if (btnp(1) or btnp(4)) self.options[self.selection]:cb() 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) 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 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 end menu_option=klass() function menu_option:init(name,cb) self.name=name self.cb=cb end