Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Paste+
- Advanced Pastebin
- client for CC
- Author: RodrickLord ]]
- local version = 0.2
- local apiKey = "374a4cb09acf573a9368bf21426d8ece"
- -- Design functions
- local d = {}
- termX,termY = term.getSize()
- centerX,centerY = termX/2+1,termY/2+1
- function d.clearLine(y,bColor)
- if bColor then term.setBackgroundColor(bColor) end
- term.setCursorPos(1,y)
- term.clearLine()
- end
- function d.centerWrite(text,y)
- local _,cY = term.getCursorPos()
- local y = y or cY
- term.setCursorPos(centerX-#text/2,y)
- term.write(text)
- end
- function d.cWrite(text,x,y,tColor,bColor)
- if tColor then term.setTextColor(tColor) end
- if bColor then term.setBackgroundColor(bColor) end
- local cursorX,cursorY = term.getCursorPos()
- local x = x or cursorX
- local y = y or cursorY
- term.setCursorPos(x,y)
- term.write(text)
- end
- function d.fadeScreen(color,wTime)
- term.setBackgroundColor(color)
- term.clear() sleep(wTime or 0.1)
- end
- function d.animWriteL(text,x,y)
- for i = -#text,x,3 do
- term.setCursorPos(i-3,y)
- term.write(" "..text)
- sleep(0.01)
- end
- term.setCursorPos(x-3,y)
- term.write(" "..text)
- end
- function d.animWriteR(text,x,y)
- for i = termX,x,-3 do
- term.setCursorPos(i,y)
- term.write(text.." ")
- sleep(0.01)
- end
- term.setCursorPos(x,y)
- term.write(text.." ")
- end
- function d.animWriteB(text,x,y)
- for i = termY,y,-1 do
- d.clearLine(i+1)
- term.setCursorPos(x,i)
- term.write(text)
- sleep(0.01)
- end
- end
- function d.drawButton(text,x,y,tColor,bColor)
- paintutils.drawFilledBox(x,y,x+#text+1,y+2,bColor)
- d.cWrite(text,x+1,y+1,tColor)
- end
- -- Misc functions
- local function wait(wTime)
- parallel.waitForAny(
- function() sleep(wTime or 3) end,
- function() os.pullEvent("key") end,
- function() os.pullEvent("mouse_click") end)
- end
- -- GUIs
- local gui = {}
- function gui.bar()
- d.clearLine(1,colors.gray)
- d.cWrite("Paste",2,1,colors.lightBlue)
- d.cWrite("+",nil,nil,colors.yellow)
- end
- function gui.welcome()
- d.fadeScreen(colors.black)
- d.fadeScreen(colors.gray)
- d.fadeScreen(colors.lightGray)
- d.fadeScreen(colors.white)
- term.setTextColor(colors.lightBlue)
- d.animWriteL("Paste",centerX-3,centerY-1)
- term.setTextColor(colors.yellow)
- d.animWriteR("+",centerX+3,centerY-1)
- sleep(0.2)
- term.setTextColor(colors.black)
- d.animWriteB("Advanced Pastebin Client",centerX-12,centerY)
- wait(3)
- d.fadeScreen(colors.lightGray)
- d.fadeScreen(colors.gray,0.5)
- d.fadeScreen(colors.lightGray)
- d.fadeScreen(colors.white)
- end
- local function gui.main()
- gui.bar()
- d.drawButton("Upload",2,3,colors.white,colors.lightBlue)
- d.drawButton("Download",11,3,colors.white,colors.lightBlue)
- d.drawButton("Login",termX-6,3,colors.white,colors.lightBlue)
- d.drawButton("List my pastes",2,7,colors.white,loggedIn and colors.lightBlue or colors.lightGray)
- end
- function gui.login()
- gui.bar()
- end
- -- Touch (click) functions
- local click = {}
- function click.login()
- while true do
- local _,_,cx,cy = os.pullEvent("mouse_click")
- if
- end
- end
- function click.main()
- while true do
- local _,_,cx,cy = os.pullEvent("mouse_click")
- if cx>=termX-6 and cx<=termX-1 and cy>=3 and cy<=5 then
- gui.login()
- click.login()
- end
- end
- end
- if not term.isColor() then
- term.setBackgroundColor(colors.black)
- term.clear()
- d.clearLine(1,colors.white)
- term.setTextColor(colors.black)
- d.centerWrite("Paste+ needs a Advanced Computer!")
- error("\n",0)
- end
- gui.welcome()
- gui.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement