kizz12

gui

Apr 22nd, 2015
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 KB | None | 0 0
  1. --button functions
  2. ----------------------------------
  3. function lgt() --logout function
  4.     t:toggleButton("Logout")
  5.     sleep(.2)
  6.     t:toggleButton("Logout")
  7.     term.setBackgroundColor(colors.black)
  8.     term.clear()
  9.     term.setCursorPos(1,1)
  10.     shell.run("logout")
  11.  
  12. end
  13.  
  14. function pgm()
  15.     t:toggleButton("Programs")
  16.     sleep(.2)
  17.     t:toggleButton("Programs")
  18.     term.setBackgroundColor(colors.orange)
  19.     term.setTextColor(colors.blue)
  20.     term.clear()
  21.     term.setCursorPos(1,1)
  22.     shell.run("programs")
  23.     print'Please enter the program you wish to run, or exit to return to the GUI.'
  24.     getPgm=read()
  25.     if getPgm~="exit" then
  26.         shell.run(getPgm)
  27.     end
  28. end
  29.  
  30. function hlp()
  31.     t:toggleButton("Help")
  32.     sleep(.2)
  33.     t:toggleButton("Help")
  34.     term.setCursorPos(1,1)
  35.     term.clear()
  36.     term.setBackgroundColor(colors.black)
  37.     shell.run("help")
  38. end
  39.  
  40. function tm()
  41.     t:toggleButton("Terminal Mode")
  42.     sleep(.2)
  43.     t:toggleButton("Terminal Mode")
  44.     term.setBackgroundColor(colors.black)
  45.     term.clear()
  46.     term.setCursorPos(1,1)
  47.     print("Switching to Terminal mode!")
  48.     sleep(1)
  49.     setBreak=true
  50. end
  51.  
  52. function ext()
  53.     t:toggleButton("Extend")
  54.     sleep(.2)
  55.     t:toggleButton("Extend")
  56.     term.setBackgroundColor(colors.black)
  57.     term.clear()
  58.     term.setCursorPos(1,1)
  59.     shell.run("extend")
  60. end
  61.  
  62. function nu()
  63.     t:toggleButton("New User")
  64.     sleep(.2)
  65.     t:toggleButton("New User")
  66.     term.setBackgroundColor(colors.black)
  67.     term.clear()
  68.     term.setCursorPos(1,1)
  69.     shell.run("newuser")
  70. end
  71.  
  72. function ru()
  73.     t:toggleButton("Remove User")
  74.     sleep(.2)
  75.     t:toggleButton("Remove User")
  76.     term.setBackgroundColor(colors.black)
  77.     term.clear()
  78.     term.setCursorPos(1,1)
  79.     --shell.run("remove")
  80.     print("Coming soon!")
  81.     sleep(1)
  82. end
  83.  
  84. function nfile()
  85.     t:toggleButton("New File")
  86.     sleep(.2)
  87.     t:toggleButton("New File")
  88.     term.setBackgroundColor(colors.black)
  89.     term.clear()
  90.     term.setCursorPos(1,1)
  91.     print'What would you like to name your file?'
  92.     fName=read()
  93.     shell.run("edit "..fName)
  94. end
  95.  
  96. function doNothing()
  97. return
  98. end
  99. ------------------------------------------
  100.  
  101.  
  102. --prevent loop break when restarting GUI
  103. setBreak=false
  104. --load api
  105. os.loadAPI("touchpoint")
  106.  
  107.  
  108. ------------------------------------------
  109. --New screen
  110. ------------------------------------------
  111. t = touchpoint.new()
  112.  
  113.  
  114. ------------------------------------------
  115. --Buttom parameters
  116. ------------------------------------------
  117. t:add("Programs", pgm, 2, 2, 12, 6, colors.red, colors.green)
  118. t:add("Logout", lgt, 40, 14, 51, 18, colors.red, colors.green)
  119. t:add("Help", hlp, 14, 2, 19, 6, colors.red, colors.green)
  120. t:add("Terminal Mode", tm, 2, 8, 19, 12, colors.red, colors.green)
  121. t:add("Extend", ext, 2, 14, 19, 18, colors.red, colors.green)
  122. if user==1 then
  123. t:add("New User", nu, 21, 8, 38, 12, colors.red, colors.orange)
  124. t:add("Remove User", ru, 21, 14, 38, 18, colors.red, colors.orange)
  125. end
  126. t:add("New File", nfile, 21, 2, 38, 6, colors.red, colors.blue)
  127. t:add("KOS", doNothing, 40, 2, 50, 7, colors.brown, colors.blue)
  128. getTime=os.day()
  129. t:add("Day:"..getTime, doNothing, 40, 8, 50, 12, colors.brown, colors.blue)
  130. ------------------------------------------
  131. --actually make the buttons
  132. ------------------------------------------
  133. t:draw()
  134.  
  135.  
  136. ------------------------------------------
  137. --Make the buttons fancy
  138. ------------------------------------------
  139. t:toggleButton("Programs")
  140. t:toggleButton("Logout")
  141. t:toggleButton("Help")
  142. t:toggleButton("Terminal Mode")
  143. t:toggleButton("Extend")
  144. if user==1 then
  145. t:toggleButton("New User")
  146. t:toggleButton("Remove User")
  147. end
  148. t:toggleButton("New File")
  149.  
  150.  
  151. ------------------------------------------
  152. --Listen for buttons to be clicked
  153. ------------------------------------------
  154.  
  155.     while true do
  156.         t:run()
  157.         bp=true
  158.         if setBreak==true then
  159.             break
  160.         end
  161.     end
  162.  
  163.  
  164.  
  165. term.setBackgroundColor(colors.black)
  166. term.clear()
  167. term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment