Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- function dualPull(...)
- local e={...}
- local ev={os.pullEvent()}
- repeat
- for k,v in pairs(e) do
- if v==ev[1] then return unpack(ev) end
- end
- ev={os.pullEvent()}
- until false
- end
- function shorten(sText,nLimit)
- sText = #sText > nLimit and string.sub(sText,1,nLimit-3).."..." or sText
- return sText
- end
- function drawStartMenu(item)
- term.setBackgroundColor(colors.white)
- term.clear()
- paintutils.drawLine(16,1,16,19,colors.black)
- paintutils.drawLine(17,6,51,6,colors.black)
- term.setCursorPos(17,7)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(17,8)
- term.setCursorPos(17,7)
- term.write("GUIDE v1.7")
- term.setCursorPos(17,10)
- term.write("Changes in 1.7 --------------------")
- term.setCursorPos(17,12)
- term.write("+ New Start Menu")
- term.setCursorPos(17,13)
- term.write("+ Changelog")
- term.setCursorPos(17,14)
- term.write("- Old Ugly Start Menu")
- paintutils.drawLine(29,4,39,4,colors.green)
- term.setCursorPos(29,4)
- term.write("Select Item")
- term.setCursorPos(math.ceil((34 / 2) - (#item / 2))+17,3)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- term.write(item)
- end
- function startMenu()
- local list = fs.list("/")
- local selected = math.ceil(#list/2)
- while true do
- drawStartMenu(list[selected] or "")
- for i=1,9 do
- term.setCursorPos(1,i)
- if list[selected - (10 - i)] then
- term.setTextColor(fs.isDir(shell.dir().."/"..list[selected - (10 - i)]) and colors.green or colors.gray)
- end
- term.setBackgroundColor(colors.white)
- term.write(list[selected - (10 - i)] or "")
- end
- term.setCursorPos(1,10)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(fs.isDir(shell.dir().."/"..list[selected]) and colors.green or colors.gray)
- term.write(list[selected])
- for i=1,9 do
- term.setCursorPos(1,i+10)
- if list[selected + i] then
- term.setTextColor(fs.isDir(shell.dir().."/"..list[selected + i]) and colors.green or colors.gray)
- end
- term.setBackgroundColor(colors.white)
- term.write(list[selected + i] or "")
- end
- sleep(0.05)
- local event, arg1, x, y = dualPull("mouse_scroll","mouse_click")
- if event == "mouse_scroll" then
- if arg1 == -1 and 1 < selected then
- selected = selected - 1
- elseif arg1 == 1 and selected < #list then
- selected = selected + 1
- end
- elseif event == "mouse_click" then
- if x < 16 then
- if y < 10 and selected - (10 - y) > 0 then
- selected = selected - (10 - y)
- elseif y > 10 and selected + (y - 10) < #list + 1 then
- selected = selected + (y - 10)
- end
- elseif x < 40 and x > 28 and y == 4 then
- if fs.isReadOnly(shell.dir().."/"..list[selected]) == false and fs.isDir(shell.dir().."/"..list[selected]) == false and list[selected] ~= "Back To Home" then
- return shell.dir()..list[selected]
- elseif fs.isDir(shell.dir().."/"..list[selected]) == true then
- local dir = shell.dir()
- shell.setDir(shell.dir().."/"..list[selected])
- list = fs.list(dir.."/"..list[selected].."/")
- selected = 1
- table.insert(list,1,"Back To Home")
- elseif list[selected] == "Back To Home" then
- shell.setDir("/")
- list = fs.list("/")
- selected = 1
- end
- end
- end
- end
- end
- if type(tArgs[1]) ~= "string" then
- tArgs[1] = startMenu()
- shell.setDir("/")
- end
- curColor = colors.black
- backColor = colors.white
- script = {}
- function toColor(nColor)
- for i,v in pairs(colors) do
- if v == nColor then
- return "colors."..i
- end
- end
- end
- colorsL = {
- colors.white,
- colors.orange,
- colors.magenta,
- colors.lightBlue,
- colors.yellow,
- colors.lime,
- colors.pink,
- colors.gray,
- colors.lightGray,
- colors.cyan,
- colors.purple,
- colors.blue,
- colors.brown,
- colors.green,
- colors.red,
- colors.black}
- function redraw()
- for i,v in pairs(script) do
- local exec = loadstring(v)
- exec()
- end
- end
- function startScreen()
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- paintutils.drawLine(1,1,1,19,colors.black)
- term.setCursorPos(2,1)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('How to use GUIDE')
- paintutils.drawLine(2,2,51,2,colors.black)
- paintutils.drawLine(18,2,18,1,colors.black)
- paintutils.drawLine(51,2,51,19,colors.black)
- paintutils.drawLine(51,19,1,19,colors.black)
- term.setCursorPos(2,3)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Press 1 to create a line, space to end line, R ')
- term.setCursorPos(2,4)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('to reposition starting point')
- term.setCursorPos(2,6)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Press 2 to write text, click to place text')
- term.setCursorPos(2,8)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Press 3 to clear the screen with background color')
- term.setCursorPos(2,10)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Press P to open Color Picker')
- term.setCursorPos(2,12)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Press Tab to finish project')
- term.setCursorPos(2,14)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Press Backspace to delete last GUI Item')
- term.setCursorPos(2,16)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Background is used for line and clear')
- term.setCursorPos(2,17)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write('Text is used for well, text.')
- paintutils.drawLine(2,5,50,5,colors.black)
- paintutils.drawLine(2,7,50,7,colors.black)
- paintutils.drawLine(2,9,50,9,colors.black)
- paintutils.drawLine(2,11,50,11,colors.black)
- paintutils.drawLine(2,13,51,13,colors.black)
- paintutils.drawLine(2,15,51,15,colors.black)
- paintutils.drawLine(1,18,51,18,colors.black)
- term.setCursorPos(2,19)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.write('GUI made with GUIDE')
- end
- function line()
- local event,button,x,y = os.pullEvent("mouse_click")
- local eventd,buttond,dragx,dragy = "",0,0,0
- local oldx, oldy = 1,1
- repeat
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- if eventd == "key" and buttond == keys.r then
- paintutils.drawLine(x,y,oldx,oldy,backColor)
- event,button,x,y = os.pullEvent("mouse_click")
- end
- if eventd == "mouse_drag" then
- oldx, oldy = dragx,dragy
- elseif eventd == "key" then
- oldx = oldx
- oldy = oldy
- end
- if eventd == "mouse_drag" then
- paintutils.drawLine(x,y,dragx,dragy,backColor)
- elseif eventd == "key" then
- paintutils.drawLine(x,y,oldx,oldy,backColor)
- end
- eventd,buttond,dragx,dragy = dualPull("mouse_drag","key")
- if eventd == "key" and buttond == keys.space then
- table.insert(script,"paintutils.drawLine("..x..","..y..","..oldx..","..oldy..","..toColor(backColor)..")")
- end
- until eventd == "key" and buttond == keys.space
- end
- function text()
- local event,button,x,y = os.pullEvent("mouse_click")
- term.setCursorPos(x,y)
- local text = {}
- repeat
- local event,key = os.pullEvent()
- if event == "char" then
- table.insert(text,string.sub(key,1,1))
- term.setCursorPos(x,y)
- term.setTextColor(curColor)
- term.setBackgroundColor(backColor)
- term.write(table.concat(text))
- elseif event == "key" then
- if key == keys.backspace then
- table.remove(text)
- paintutils.drawLine(x,y,x+#text,y,backColor)
- term.setCursorPos(x,y)
- term.write(table.concat(text))
- end
- end
- until key == keys.enter
- table.insert(script,"term.setCursorPos("..x..","..y..")")
- if lastColor ~= curColor and lastBackColor ~= backColor then
- table.insert(script,"term.setTextColor("..toColor(curColor)..")")
- table.insert(script,"term.setBackgroundColor("..toColor(backColor)..")")
- lastColor = curColor
- lastBackColor = backColor
- end
- table.insert(script,[[term.write("]]..table.concat(text)..[[")]])
- end
- function drawColorPick()
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- paintutils.drawLine(2,2,3,2,colors.white)
- paintutils.drawLine(4,2,5,2,colors.orange)
- paintutils.drawLine(6,2,7,2,colors.magenta)
- paintutils.drawLine(8,2,9,2,colors.lightBlue)
- paintutils.drawLine(2,3,3,3,colors.yellow)
- paintutils.drawLine(4,3,5,3,colors.lime)
- paintutils.drawLine(6,3,7,3,colors.pink)
- paintutils.drawLine(8,3,9,3,colors.gray)
- paintutils.drawLine(4,4,5,4,colors.cyan)
- paintutils.drawLine(6,4,7,4,colors.purple)
- paintutils.drawLine(8,4,9,4,colors.blue)
- paintutils.drawLine(2,5,3,5,colors.brown)
- paintutils.drawLine(4,5,5,5,colors.green)
- paintutils.drawLine(6,5,7,5,colors.red)
- paintutils.drawLine(8,5,9,5,colors.black)
- paintutils.drawLine(1,1,1,5,colors.black)
- paintutils.drawLine(1,6,7,6,colors.black)
- paintutils.drawLine(2,1,9,1,colors.black)
- paintutils.drawLine(10,1,10,4,colors.black)
- paintutils.drawLine(10,5,10,6,colors.black)
- paintutils.drawLine(10,6,8,6,colors.black)
- term.setCursorPos(11,1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.write('Color Picker')
- term.setCursorPos(12,4)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.write('Background Color')
- term.setCursorPos(12,6)
- term.write('Text Color')
- paintutils.drawLine(10,6,10,19,colors.black)
- term.setCursorPos(11,12)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.write('This Color Picker GUI was made with GUIDE')
- term.setCursorPos(11,13)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.write(', A tool to improve tools. The GUI blade')
- term.setCursorPos(11,14)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.lightGray)
- term.write('sharpener.')
- paintutils.drawLine(10,2,51,2,colors.black)
- paintutils.drawLine(11,10,51,10,colors.black)
- term.setCursorPos(12,8)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.red)
- term.write('Cancel')
- end
- function colorPick()
- drawColorPick()
- local function fillColor(nColor)
- for i=7,19 do
- paintutils.drawLine(1,i,9,i,nColor)
- end
- end
- local selectedColor = colors.white
- repeat
- local event,button,xpos,ypos = dualPull("mouse_click","mouse_drag")
- if xpos == 2 and ypos == 2 or xpos == 3 and ypos == 2 then
- selectedColor = colors.white
- elseif xpos == 4 and ypos == 2 or xpos == 5 and ypos == 2 then
- selectedColor = colors.orange
- elseif xpos == 6 and ypos == 2 or xpos == 7 and ypos == 2 then
- selectedColor = colors.magenta
- elseif xpos == 8 and ypos == 2 or xpos == 9 and ypos == 2 then
- selectedColor = colors.lightBlue
- elseif xpos == 2 and ypos == 3 or xpos == 3 and ypos == 3 then
- selectedColor = colors.yellow
- elseif xpos == 4 and ypos == 3 or xpos == 5 and ypos == 3 then
- selectedColor = colors.lime
- elseif xpos == 6 and ypos == 3 or xpos == 7 and ypos == 3 then
- selectedColor = colors.pink
- elseif xpos == 8 and ypos == 3 or xpos == 9 and ypos == 3 then
- selectedColor = colors.gray
- elseif xpos == 2 and ypos == 4 or xpos == 3 and ypos == 4 then
- selectedColor = colors.lightGray
- elseif xpos == 4 and ypos == 4 or xpos == 5 and ypos == 4 then
- selectedColor = colors.cyan
- elseif xpos == 6 and ypos == 4 or xpos == 7 and ypos == 4 then
- selectedColor = colors.purple
- elseif xpos == 8 and ypos == 4 or xpos == 9 and ypos == 4 then
- selectedColor = colors.blue
- elseif xpos == 2 and ypos == 5 or xpos == 3 and ypos == 5 then
- selectedColor = colors.brown
- elseif xpos == 4 and ypos == 5 or xpos == 5 and ypos == 5 then
- selectedColor = colors.green
- elseif xpos == 6 and ypos == 5 or xpos == 7 and ypos == 5 then
- selectedColor = colors.red
- elseif xpos == 8 and ypos == 5 or xpos == 9 and ypos == 5 then
- selectedColor = colors.black
- end
- fillColor(selectedColor)
- if (xpos >= 12 and xpos <= 12+#"Text Color" and ypos == 6) then
- curColor = selectedColor
- elseif (xpos >= 12 and xpos <= 12+#"Background Color" and ypos == 4 ) then
- backColor = selectedColor
- end
- until (xpos >= 12 and xpos <= 18 and ypos == 8) or (xpos >= 12 and xpos <= 12+#"Text Color" and ypos == 6) or (xpos >= 12 and xpos <= 12+#"Background Color" and ypos == 4 )
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- end
- function pixel()
- repeat
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- local event, arg1, arg2, arg3 = dualPull("mouse_click","key","mouse_drag")
- if event == "mouse_click" or event == "mouse_drag" then
- paintutils.drawPixel(arg2,arg3,backColor)
- table.insert(script,"paintutils.drawPixel("..arg2..","..arg3..","..toColor(backColor)..")")
- elseif event == "key" then
- if arg1 == keys.p then
- colorPick()
- end
- if arg1 == keys.backspace then
- table.remove(script)
- end
- end
- until event == "key" and arg1 == keys.space
- end
- function clear()
- term.setBackgroundColor(backColor)
- term.clear()
- table.insert(script,"term.setBackgroundColor("..toColor(backColor)..")")
- table.insert(script,"term.clear()")
- end
- startScreen()
- function finish()
- local file = fs.open(tArgs[1],"a")
- file.writeLine(" ")
- file.writeLine("function drawGUI()")
- for i,v in pairs(script) do
- file.writeLine(v)
- end
- file.writeLine("end")
- file.writeLine("drawGUI()")
- file.close()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- write("Thanks for using GUIDE by Requeim")
- term.setCursorPos(1,2)
- end
- function drawHotbar()
- paintutils.drawLine(51,1,39,1,colors.gray)
- paintutils.drawLine(39,2,39,19,colors.gray)
- paintutils.drawLine(40,2,40,19,colors.gray)
- paintutils.drawLine(41,19,41,2,colors.gray)
- paintutils.drawLine(42,2,42,19,colors.gray)
- paintutils.drawLine(43,19,43,2,colors.gray)
- paintutils.drawLine(44,2,44,19,colors.gray)
- paintutils.drawLine(45,19,45,2,colors.gray)
- paintutils.drawLine(46,2,46,19,colors.gray)
- paintutils.drawLine(47,19,47,2,colors.gray)
- paintutils.drawLine(48,2,48,18,colors.gray)
- paintutils.drawLine(48,2,48,19,colors.gray)
- paintutils.drawLine(49,19,49,2,colors.gray)
- paintutils.drawLine(50,2,50,19,colors.gray)
- paintutils.drawLine(51,19,51,2,colors.gray)
- paintutils.drawLine(40,3,50,3,colors.white)
- term.setCursorPos(40,3)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.write(" Draw Line")
- paintutils.drawLine(40,5,50,5,colors.white)
- term.setCursorPos(40,5)
- term.write(" Write")
- paintutils.drawLine(40,7,50,7,colors.white)
- term.setCursorPos(40,7)
- term.write(" Clear")
- paintutils.drawLine(40,9,50,9,colors.white)
- term.setCursorPos(40,9)
- term.write("Draw Pixels")
- paintutils.drawLine(40,11,50,11,colors.white)
- term.setCursorPos(40,11)
- term.write(" Color")
- term.setCursorPos(40,1)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.gray)
- term.write(" Hotbar")
- term.setCursorPos(51,1)
- term.setCursorPos(51,1)
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.white)
- paintutils.drawLine(40,18,50,18,colors.green)
- term.setCursorPos(40,18)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.green)
- term.write(" Need Help")
- paintutils.drawLine(40,16,50,16,colors.green)
- term.setCursorPos(40,16)
- term.write("Im Finished")
- paintutils.drawLine(40,13,50,13,colors.white)
- term.setCursorPos(40,13)
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.white)
- term.write("Delete Last")
- term.setCursorPos(38,1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.write(">")
- end
- function hotbar()
- repeat
- drawHotbar()
- local event, button, x, y = os.pullEvent("mouse_click")
- if x < 51 and x > 39 then
- if y == 3 then
- line()
- break
- elseif y == 5 then
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- text()
- break
- elseif y == 7 then
- clear()
- break
- elseif y == 9 then
- pixel()
- break
- elseif y == 11 then
- colorPick()
- break
- elseif y == 13 then
- table.remove(script)
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- elseif y == 16 then
- finish()
- return
- elseif y == 18 then
- end
- end
- until y == 1 and x == 38
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- end
- repeat
- redraw()
- term.setCursorPos(51,1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write("<")
- local event, key, mousex, mousey = dualPull("key","mouse_click")
- if event == "key" then
- if key == keys.one then
- line()
- elseif key == keys.two then
- text()
- elseif key == keys.three then
- clear()
- elseif key == keys.p then
- colorPick()
- elseif key == keys.four then
- pixel()
- elseif key == keys.backspace then
- table.remove(script)
- term.setBackgroundColor(colors.black)
- term.clear()
- redraw()
- end
- elseif event == "mouse_click" then
- if mousex == 51 and mousey == 1 then
- hotbar()
- end
- end
- until key == keys.tab
- finish()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement