Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w, h = term.getSize()
- os.loadAPI("iosutils")
- os.loadAPI("iosvars")
- function resetScreen()
- term.setBackgroundColor(iosvars.backgroundColor)
- term.clear()
- term.setCursorPos(w, 1)
- if iosvars.wifi then
- term.setBackgroundColor(colors.red)
- term.write(" ")
- else
- term.setBackgroundColor(colors.black)
- term.write(" ")
- end
- end
- function initializeApps()
- appPage = {}
- pg = 1
- cnt = 1
- os.loadAPI("iostabs")
- os.loadAPI("iostabsinit")
- if iosvars.wifi then
- rednet.open("back")
- else
- rednet.close("back")
- end
- for i, v in pairs(iostabs.appsinit) do
- appPage[pg] = {}
- if iostabs.appsinit[i] then
- appPage[pg][cnt] = iostabs.appsinit[i][5]
- cnt = cnt + 1
- end
- if cnt == 10 then
- pg = pg + 1
- cnt = 1
- end
- end
- end
- function drawApps()
- for i = page * 9 - 9, page * 9 do
- if iostabs.appsinit[i] then
- paintutils.drawImage(iostabs.appsinit[i][5], iostabs.appsinit[i][1] - (page - 1) * w, iostabs.appsinit[i][2])
- end
- end
- end
- function appcheck(x, y, x2, y2, run)
- if (clickTab[3] >= x and clickTab[3] <= x2) and
- (clickTab[4] >= y and clickTab[4] <= y2) then
- --print("recieved"..tostring(x).." "..tostring(y).." "..run)
- shell.run(run)
- end
- end
- function click()
- clickTab = {os.pullEvent("mouse_click")}
- return clickTab
- end
- function drag()
- dragTab = {os.pullEvent("mouse_drag")}
- return dragTab
- end
- page = 1
- while true do
- os.loadAPI("iosvars")
- initializeApps()
- resetScreen()
- drawApps()
- term.setCursorPos(1, h)
- --term.write("Page: " .. page)
- parallel.waitForAny(click, drag)
- if clickTab then
- for i = page * 9 - 8, #iostabs.appsinit do
- appcheck(iostabs.appsinit[i][1] - (page - 1) * w, iostabs.appsinit[i][2], iostabs.appsinit[i][3] - (page - 1) * w, iostabs.appsinit[i][4], iostabs.appsinit[i][6])
- end
- end
- if dragTab then
- if math.abs(clickTab[3] - dragTab[3]) > 15 then
- dir = math.abs(clickTab[3] - dragTab[3]) / (clickTab[3] - dragTab[3])
- if not ((page == 1 and dir == -1) or (page == #appPage and dir == 1)) then
- page = page + dir
- for k = 1, w * dir, dir do
- resetScreen()
- for i = 1, #iostabs.appsinit do
- if dir == 1 then
- if i > (page - 1) * 9 - 9 and i <= (page - 1) * 9 + 9 then
- paintutils.drawImage(iostabs.appsinit[i][5], iostabs.appsinit[i][1] - k - w * (page - 2), iostabs.appsinit[i][2])
- end
- elseif dir == -1 then
- if i > (page + 1) * 9 - 18 and i <= (page + 1) * 9 then
- paintutils.drawImage(iostabs.appsinit[i][5], iostabs.appsinit[i][1] - k - w * page, iostabs.appsinit[i][2])
- end
- end
- end
- sleep(.01)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement