Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- (C) Copyright - Redxone and GameFusion Staff --
- local w, h = term.getSize()
- games = {}
- local inProgram = true
- local mIndex = 1
- local sel = 1
- local inc = 2
- local page = 1
- local inProgram = true
- local maxSel = 0
- function drawMain()
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- local bg = paintutils.loadImage(shell.resolve(".background"))
- paintutils.drawImage(bg,2,1)
- end
- function initItems()
- --local rootdir = "Rogue/Hackbrew/Apps"
- local rootdir = "rom/programs/"
- for k, v in pairs(fs.list(rootdir))do
- if(not fs.isDir(rootdir..v))then
- table.insert(games,v)
- end
- end
- end
- function checkPage(ind)
- local ok = false
- ind = (ind*inc)-1
- for i = ind, #games do
- if(games[i] ~= "")then ok = true end
- end
- return ok
- end
- function makeMenu(ind)
- drawMain()
- local ri = 1
- maxSel = 0
- ind = (ind*inc)-1
- for i = ind, #games do
- if(ri <= inc)then
- if( ri == sel )then
- drawOption(games[i],ri,colors.lightBlue)
- else
- drawOption(games[i],ri,colors.gray)
- end
- ri = ri + 1
- maxSel = maxSel + 1
- end
- end
- end
- function drawOption(text,hi,color)
- -- math thinking out..
- -- menu size be ??? 10?
- -- soz divide 10 / 2 = 5 make w / 2 - 5
- -- even menu out
- -- height will be based on given index
- -- multiplyed by height constant
- -- now for teh text
- local mh = 2
- local hs = tonumber(4)+tonumber(mh)
- local mw = 15
- local sw = (w/2) - mw
- local sh = hs*hi
- local ew = (w/2) + mw
- local eh = sh + mh
- paintutils.drawFilledBox(sw,sh,ew,eh,color)
- if(#text > tonumber(32))then text = text:sub(1,31) end
- term.setCursorPos((w/2)-#text/2,(hs*hi) + 1)
- term.setTextColor(colors.white)
- write(text)
- end
- drawMain()
- initItems()
- makeMenu(page)
- while inProgram do
- a = {os.pullEvent("key")}
- term.current().setVisible(false)
- if(a[2] == keys.up and sel > 1)then sel = sel - 1 end
- if(a[2] == keys.down and sel < maxSel)then sel = sel + 1 end
- if(a[2] == keys.left and page > 1)then sel = 1 page = page - 1 end
- if(a[2] == keys.right and checkPage(page+1))then sel = 1 page = page + 1 end
- makeMenu(page)
- term.current().setVisible(true)
- end
- term.setCursorPos(1,15)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement