Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("gpx")
- w,h = term.getSize()
- sel = 2
- gpx.sbc(colors.white)
- gpx.clr()
- gpx.stc(colors.black)
- clk = os.startTimer(0.1)
- clks = textutils.formatTime(os.time(),false)
- gpx.fadeScreen("in",0.03)
- local gameMenu = {
- {name="Worm",path="rom/programs/fun/worm",desc="worm.ginfo",top="worm_top.gim",ico="worm_ico.gim"};
- {name="Adventure",path="rom/programs/fun/adventure",desc="adventure.ginfo",top="adventure_top.gim",ico="adventure_ico.gim"};
- }
- function disp()
- term.current().setVisible(false)
- term.setBackgroundColor(colors.white)
- gpx.clr()
- gpx.stc(colors.black)
- -- draw top
- function drawBar()
- gpx.drawImage(gameMenu[sel].top,14,3)
- gpx.scp(1,1)
- gpx.sbc(colors.gray)
- term.clearLine()
- gpx.scp(1,1)
- gpx.stc(colors.white)
- write("Game - "..gameMenu[sel].name)
- gpx.scp(w-#clks,1)
- write(clks)
- end
- drawBar()
- for i = 1, #gameMenu do
- if(sel == i)then
- -- draw bottom
- gpx.scp((w/2) - #gameMenu[i].name/2, h-(h/2)+3)
- gpx.sbc(colors.gray)
- gpx.stc(colors.white)
- write(gameMenu[i].name)
- gpx.drawImage(gameMenu[i].ico,(w/2)-3, h - (h/2)+4)
- elseif(i == sel-1)then
- gpx.scp(1 + #gameMenu[i].name/2, h-(h/2)+4)
- gpx.stc(colors.lightGray)
- gpx.sbc(colors.white)
- write(gameMenu[i].name)
- end
- if(i == sel+1)then
- gpx.scp((w) - (#gameMenu[i].name)-2, h-(h/2)+4)
- gpx.sbc(colors.white)
- gpx.stc(colors.lightGray)
- write(gameMenu[i].name)
- end
- end
- term.current().setVisible(true)
- a = {os.pullEvent()}
- if(a[1] == "key")then
- if(a[2] == keys.left and sel > 1)then sel = sel - 1 end
- if(a[2] == keys.right and sel < #gameMenu)then sel = sel + 1 end
- if(a[2] == keys.enter)then
- function gdesc()
- gpx.sbc(colors.white)
- gpx.clr()
- drawBar()
- gpx.scp(4,3)
- gpx.stc(colors.black)
- -- get teh info frum the json clone
- f = fs.open(gameMenu[sel].desc,"r")
- jsun = textutils.unserialize(f.readAll())
- f.close()
- gpx.sbc(colors.white)
- gpx.clr()
- write(jsun.name)
- gpx.scp(gpx.w-(#jsun.author),3)
- write(jsun.author)
- gpx.scp(3,6)
- gpx.stc(colors.lightGray)
- jsun.desc = jsun.desc:gsub("\n"," ")
- write(jsun.desc)
- gpx.scp(1,19)
- gpx.stc(colors.black)
- write("< - [Back] ")
- gpx.scp(gpx.w-10,19)
- write("[Play] - >")
- ev = {os.pullEvent()}
- if(ev[1] == "key")then
- if(ev[2] == keys.left)then
- clk = os.startTimer(0.01)
- elseif(ev[2] == keys.right)then
- gpx.fadeScreen("out",0.03)
- os.run({},gameMenu[sel].path)
- gpx.stc(colors.white)
- gpx.sbc(colors.black)
- gpx.clr()
- gpx.centerText("Press any key.")
- os.pullEvent("key")
- gpx.fadeScreen("in",0.03)
- clk = os.startTimer(0.01)
- disp()
- else
- gdesc()
- end
- elseif(ev[1] == "timer")then
- clk = os.startTimer(0.01)
- gdesc()
- end
- end
- gdesc()
- end
- end
- if(a[1] == "timer")then
- clks = textutils.formatTime(os.time(),false)
- gpx.sbc(colors.gray)
- gpx.scp(w-#clks,1)
- gpx.stc(colors.white)
- clk = os.startTimer(0.01)
- end
- end
- clk = os.startTimer(0.01)
- while true do
- disp()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement