Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- --this program for CC Tweaked acts as a Basic Menu for a tablet OS. this will be replaced in the future, with a better and more multipurpose Menu system(WIP)
- Current_Page = "Menu"
- Installed_Apps = []
- Access_Apps = [true,true,true,true,true]
- Access_Actions = []
- start()
- function start()
- term.setBackgroundColor("blue")
- term.setTextColor("white")
- paintutils.drawFilledBox(1,19,26,20,color.gray)
- paintutils.drawFilledBox(7,8,19,15,color.white)
- paintutils.drawFilledBox(12,10,14,9,color.black)
- MenuLoader()
- end
- function MenuLoader()
- local h = fs.open("InstalledApplications","r")
- for i=1, #h.list do
- Installed_Apps[i] = h.readline(i)
- end
- h.close()
- DrawMenu()
- Menu()
- end
- function DrawMenu()
- local X = 1
- local Y = 1
- for i=1, #15 do
- if Installed_Apps[i] ~= nil then
- paintutils.drawFilledBox(X*5,Y*5,(X*5)+5,(Y*5)+5,colors.white)
- term.setCursorPos(X*5,Y*5)
- term.write(Installed_Apps[i])
- end
- if X < 5 then
- X = X+1
- else
- X = 1
- Y = Y+1
- end
- end
- X = 1
- for i=1, #Access_Apps do
- if Allowed_Apps[i] ~= true then
- paintutils.drawFilledBox(X*3,18,(X*3)+2,20,colors.white)
- end
- X = X+1
- end
- end
- function Menu()
- while true do --this checks to see if the mouse is pressed down, and where
- local event, button, x, y = os.pullEvent("mouse_click")
- if button == "left" and y >= 18 then --Checks what app the player clicked on Task Bar
- TaskBarCheck(x)
- else if button == "left" and x <= 2 and y <= 2 then --opens Settings
- shell.run(".Heimbriech_SettingsMenu")
- else --checks to see if User clicked on a Installed App on menu
- InstalledApplicationCheck(x,y)
- end
- end
- end
- function TaskBarCheck(x)
- if x < 3 and Access_Apps[0] == true then --file manager
- else if x < 6 and Access_Apps[1] == true then --Store
- else if x < 9 and Access_Apps[2] == true then --Blank
- else if x < 12 and Access_Apps[3] == true then --Blank
- else if x < 15 and Access_Apps[4] == true then --Blank
- else
- end
- end
- function InstalledApplicationCheck(x,y)
- local X = 1
- local Y = 1
- local I = -1
- for i=1, #15 do
- if x > X*5 and x < (X*5)+5 and y > Y * 5 and y < (Y*5)+5 then
- I = (X + (Y*5))-1
- end
- if X < 5 then
- X = X + 1
- else
- X = 1
- Y = Y + 1
- end
- end
- if I > -1 then
- OpenApplication(I)
- end
- end
- function OpenApplication(Number)
- local Application_Name = Installed_Apps[Number]
- shell.run("Launcher_"..Application_Name)
- end
- os.pullEvent = oldPull
Add Comment
Please, Sign In to add comment