Advertisement
Guest User

browser

a guest
Nov 25th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.49 KB | None | 0 0
  1. -- Variables --
  2. prefPath = "loc/browser/.pref"
  3. basePath = "loc/browser/"
  4.  
  5. -- Just a load of functions! --
  6. function mouseAny()
  7. local event, button, x, y = os.pullEvent("mouse_click")
  8. if button == 1 then
  9. end
  10. end
  11.  
  12. function notif(text)
  13. paintutils.drawLine(2,19,50,19,colors.red)
  14. center(text,19,colors.black)
  15. end
  16.  
  17. function oneEntry()
  18. outputKey = read()
  19. end
  20.  
  21. function keyPress()
  22. local event, scancode = os.pullEvent("key")
  23. local event, scancode = os.pullEvent("key")
  24. if scancode == 26 then
  25. local event, scancode = os.pullEvent("key")
  26. end
  27. end
  28.  
  29. function settScreen()
  30.   term.setBackgroundColor(colors.gray)
  31.   term.clear()
  32.   paintutils.drawLine(2,2,50,2,colors.white)
  33.   center("Local Settings & Preferences",2,colors.black)
  34.   yM = 16
  35.   for y=4, yM do
  36.     paintutils.drawLine(2,y,50,y,colors.white)
  37.   end
  38.   paintutils.drawLine(2,18,50,18,colors.white)
  39.   center("Click here to return",18,colors.black)
  40.   term.setCursorPos(3,5)
  41.   write("Cursor Preference: ")
  42.   paintutils.drawPixel(20,5,colors.lightGray)
  43.   while true do
  44.     local event, button, x, y = os.pullEvent("mouse_click")
  45.     if button == 1 and x>=2 and x<=50 and y==18 then
  46.       break
  47.     elseif button == 1 and x==20 and y==5 then
  48.       --local fin = parallel.waitForAny(mouseAny,oneEntry)
  49.       local outputKey = read()
  50.       if outputKey ~= nil then
  51.         local h = fs.open("pref", "w")
  52.         h.writeLine("curPref = \""..outputKey.."\"")
  53.         h.close()
  54.       end
  55.     end
  56.   end
  57. end
  58.  
  59. function aboutScreen()
  60.   --[[
  61.   paintutils.drawLine(2,2,15,2,colors.lightGray)
  62.   sleep(0.1)
  63.   paintutils.drawLine(16,2,30,2,colors.lightGray)
  64.   sleep(0.1)
  65.   paintutils.drawLine(31,2,45,2,colors.lightGray)
  66.   sleep(0.1)
  67.   paintutils.drawLine(46,2,50,2,colors.lightGray)
  68.   paintutils.drawLine(50,2,50,4,colors.lightGray)
  69.   paintutils.drawLine(50,4,45,4,colors.lightGray)
  70.   sleep(0.1)
  71.   paintutils.drawLine(44,4,30,4,colors.lightGray)
  72.   sleep(0.1)
  73.   paintutils.drawLine(29,4,15,4,colors.lightGray)
  74.   sleep(0.1)
  75.   paintutils.drawLine(14,4,2,4,colors.lightGray)
  76.   paintutils.drawPixel(2,3,colors.lightGray)
  77.   sleep(0.1)
  78.   paintutils.drawLine(3,3,15,3,colors.lightGray)
  79.   sleep(0.1)
  80.   paintutils.drawLine(16,3,30,3,colors.lightGray)
  81.   sleep(0.1)
  82.   paintutils.drawLine(31,3,45,3,colors.lightGray)
  83.   sleep(0.1)
  84.   paintutils.drawLine(46,3,50,3,colors.lightGray)
  85.   ]]--
  86.   term.setBackgroundColor(colors.gray)
  87.   term.clear()
  88.   paintutils.drawLine(2,2,50,2,colors.white)
  89.   yM = 16
  90.   for y=4, yM do
  91.     paintutils.drawLine(2,y,50,y,colors.white)
  92.   end
  93.   paintutils.drawLine(2,18,50,18,colors.white)
  94.   center("About the LOC Browser",2,colors.black)
  95.   center("Click here to return",18,colors.black)
  96.   center("The Loc browser was made by Sam Gunner and",4,colors.black)
  97.   center("Cody Robinson. The LOC browser is Copyright (C)",5,colors.black)
  98.   center("2014, Sam Gunner and Cody Robinson.",6,colors.black)
  99.   center("It is designed to work with programs developed",8,colors.black)
  100.   center("specifically with the LOC browser in mind.",9,colors.black)
  101.   center("We have tried to make it as simple as possible",10,colors.black)
  102.   center("to set up and operate web pages with the LOC",11,colors.black)
  103.   center("browser. We hope you enjoy using it.",12,colors.black)
  104.   while true do
  105.     local event, button, x, y = os.pullEvent("mouse_click")
  106.     if x>=2 and x<=50 and y==18 then
  107.       break
  108.     end
  109.   end
  110. end
  111.  
  112. function mainAct()
  113.   while true do
  114.     local event, button, x, y = os.pullEvent("mouse_click")
  115.     if button == 1 and x>=2 and x<=50 and y>=2 and y<=4 then
  116.       aboutScreen()
  117.       break
  118.     elseif button == 1 and x>=2 and x<=50 and y==18 then
  119.       exComm = true
  120.       break
  121.     elseif button == 1 and x>=2 and x<=50 and y>=6 and y<=8 then
  122.       settScreen()
  123.       break
  124.     end
  125.   end
  126. end
  127.  
  128. function center(text,y,colour)
  129. local x = ((51-string.len(text))/2)+1
  130. term.setCursorPos(x,y)
  131. term.setTextColor(colour)
  132. print(text)
  133. end
  134.  
  135. function drawMainMenu()
  136.   term.setBackgroundColor(colors.gray)
  137.   term.clear()
  138.   paintutils.drawLine(2,18,50,18,colors.white)
  139.   center("Click here to exit",18,colors.black)
  140.   paintutils.drawLine(2,2,50,2,colors.white) --
  141.   paintutils.drawLine(2,3,50,3,colors.white)
  142.   paintutils.drawLine(2,4,50,4,colors.white)
  143.   paintutils.drawLine(2,6,50,6,colors.white) --
  144.   paintutils.drawLine(2,7,50,7,colors.white)
  145.   paintutils.drawLine(2,8,50,8,colors.white)
  146.   paintutils.drawLine(2,10,50,10,colors.white) --
  147.   paintutils.drawLine(2,11,50,11,colors.white)
  148.   paintutils.drawLine(2,12,50,12,colors.white)
  149.   paintutils.drawLine(2,14,50,14,colors.white) --
  150.   paintutils.drawLine(2,15,50,15,colors.white)
  151.   paintutils.drawLine(2,16,50,16,colors.white)
  152.   center("LOC Browser V1.1",3,colors.black)
  153.   center("Click here to find out more *",4,colors.black)
  154.   center("Local Settings *",7,colors.black)
  155.   center("Favourites",11,colors.black)
  156.   center("Normal Web Browser",15,colors.black)
  157. end
  158.  
  159. function drawStartup()
  160.   local img = paintutils.loadImage("loc/browser/assets/startup.gic")
  161.   paintutils.drawImage(img,1,1)
  162.   sleep(2)
  163. end
  164.  
  165. -- One-off things! --
  166. --if not settings then os.loadAPI("loc/browser/settings") end
  167. --if not gAPI then os.loadAPI("loc/browser/gAPI") end
  168. drawStartup()
  169. exComm = false
  170. while true do
  171. drawMainMenu()
  172. mainAct()
  173. if exComm == true then
  174. break
  175. end
  176. end
  177. term.setBackgroundColor(colors.black)
  178. term.clear()
  179. term.setTextColor(colors.white)
  180. paintutils.drawLine(1,1,51,1,colors.gray)
  181. term.setCursorPos(1,1)
  182. print("Thanks for using the LOC browser!")
  183. term.setBackgroundColor(colors.black)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement