Advertisement
RodrickLord

Paste+

Apr 7th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.55 KB | None | 0 0
  1. --[[   Paste+
  2.   Advanced Pastebin
  3.     client for CC
  4.      
  5.  Author: RodrickLord ]]
  6.  
  7. local version = 0.2
  8. local apiKey = "374a4cb09acf573a9368bf21426d8ece"
  9.  
  10. -- Design functions
  11. local d = {}
  12.  
  13. termX,termY = term.getSize()
  14. centerX,centerY = termX/2+1,termY/2+1
  15.  
  16. function d.clearLine(y,bColor)
  17.   if bColor then term.setBackgroundColor(bColor) end
  18.   term.setCursorPos(1,y)
  19.   term.clearLine()
  20. end
  21.  
  22. function d.centerWrite(text,y)
  23.   local _,cY = term.getCursorPos()
  24.   local y = y or cY
  25.   term.setCursorPos(centerX-#text/2,y)
  26.   term.write(text)
  27. end
  28.  
  29. function d.cWrite(text,x,y,tColor,bColor)
  30.   if tColor then term.setTextColor(tColor) end
  31.   if bColor then term.setBackgroundColor(bColor) end
  32.   local cursorX,cursorY = term.getCursorPos()
  33.   local x = x or cursorX
  34.   local y = y or cursorY
  35.   term.setCursorPos(x,y)
  36.   term.write(text)
  37. end
  38.  
  39. function d.fadeScreen(color,wTime)
  40.   term.setBackgroundColor(color)
  41.   term.clear() sleep(wTime or 0.1)
  42. end
  43.  
  44. function d.animWriteL(text,x,y)
  45.   for i = -#text,x,3 do
  46.     term.setCursorPos(i-3,y)
  47.     term.write("   "..text)
  48.     sleep(0.01)
  49.   end
  50.   term.setCursorPos(x-3,y)
  51.   term.write("   "..text)
  52. end
  53.  
  54. function d.animWriteR(text,x,y)
  55.   for i = termX,x,-3 do
  56.     term.setCursorPos(i,y)
  57.     term.write(text.."   ")
  58.     sleep(0.01)
  59.   end
  60.   term.setCursorPos(x,y)
  61.   term.write(text.."   ")
  62. end
  63.  
  64. function d.animWriteB(text,x,y)
  65.   for i = termY,y,-1 do
  66.     d.clearLine(i+1)
  67.     term.setCursorPos(x,i)
  68.     term.write(text)
  69.     sleep(0.01)
  70.   end
  71. end
  72.  
  73. function d.drawButton(text,x,y,tColor,bColor)
  74.   paintutils.drawFilledBox(x,y,x+#text+1,y+2,bColor)
  75.   d.cWrite(text,x+1,y+1,tColor)
  76. end
  77.  
  78. -- Misc functions
  79. local function wait(wTime)
  80.   parallel.waitForAny(
  81.   function() sleep(wTime or 3) end,
  82.   function() os.pullEvent("key") end,
  83.   function() os.pullEvent("mouse_click") end)
  84. end
  85.  
  86. -- GUIs
  87. local gui = {}
  88.  
  89. function gui.bar()
  90.   d.clearLine(1,colors.gray)
  91.   d.cWrite("Paste",2,1,colors.lightBlue)
  92.   d.cWrite("+",nil,nil,colors.yellow)
  93. end
  94.  
  95. function gui.welcome()
  96.   d.fadeScreen(colors.black)
  97.   d.fadeScreen(colors.gray)
  98.   d.fadeScreen(colors.lightGray)
  99.   d.fadeScreen(colors.white)
  100.   term.setTextColor(colors.lightBlue)
  101.   d.animWriteL("Paste",centerX-3,centerY-1)
  102.   term.setTextColor(colors.yellow)
  103.   d.animWriteR("+",centerX+3,centerY-1)
  104.   sleep(0.2)
  105.   term.setTextColor(colors.black)
  106.   d.animWriteB("Advanced Pastebin Client",centerX-12,centerY)
  107.   wait(3)
  108.   d.fadeScreen(colors.lightGray)
  109.   d.fadeScreen(colors.gray,0.5)
  110.   d.fadeScreen(colors.lightGray)
  111.   d.fadeScreen(colors.white)
  112. end
  113.  
  114. local function gui.main()
  115.   gui.bar()
  116.   d.drawButton("Upload",2,3,colors.white,colors.lightBlue)
  117.   d.drawButton("Download",11,3,colors.white,colors.lightBlue)
  118.   d.drawButton("Login",termX-6,3,colors.white,colors.lightBlue)
  119.   d.drawButton("List my pastes",2,7,colors.white,loggedIn and colors.lightBlue or colors.lightGray)
  120. end
  121.  
  122. function gui.login()
  123.   gui.bar()
  124.  
  125. end
  126.  
  127. -- Touch (click) functions
  128. local click = {}
  129.  
  130. function click.login()
  131.   while true do
  132.     local _,_,cx,cy = os.pullEvent("mouse_click")
  133.       if
  134.   end
  135. end
  136.  
  137. function click.main()
  138.   while true do
  139.     local _,_,cx,cy = os.pullEvent("mouse_click")
  140.     if cx>=termX-6 and cx<=termX-1 and cy>=3 and cy<=5 then
  141.       gui.login()
  142.       click.login()
  143.     end
  144.   end
  145. end
  146.  
  147. if not term.isColor() then
  148.   term.setBackgroundColor(colors.black)
  149.   term.clear()
  150.   d.clearLine(1,colors.white)
  151.   term.setTextColor(colors.black)
  152.   d.centerWrite("Paste+ needs a Advanced Computer!")
  153.   error("\n",0)
  154. end
  155.  
  156. gui.welcome()
  157. gui.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement