local function dialogBox(mes,yes,no,ok,cancle,mes2) local indexer ={} local sel2 = 1 local sel3 = 1 local with,higth = 26,6 local x13,y13 = term.getSize() local off1 = (x13/2)-(with/2) local off2 = (y13/2)-(higth/2) local barier = string.rep("-",with-2) local blank = string.rep(" ",with-2) term.setCursorPos(off1,off2) write("+"..barier.."+") term.setCursorPos(off1,off2+1) write("|"..blank.."|") term.setCursorPos(off1,off2+2) write("+"..barier.."+") term.setCursorPos(off1,off2+3) write("|"..blank.."|") term.setCursorPos(off1,off2+4) write("|"..blank.."|") term.setCursorPos(off1,off2+5) write("+"..barier.."+") if mes ~= nil then term.setCursorPos(off1+1,off2+1) write(mes) end if mes2 ~= nil then term.setCursorPos(off1+1,off2+3) write(mes2) end if yes == 1 then table.insert(indexer,1) end if no == 1 then table.insert(indexer,2) end if ok == 1 then table.insert(indexer,3) end if cancle == 1 then table.insert(indexer,4) end sel2 = sel3 if sel3 > table.maxn(indexer) then sel3 = table.maxn(indexer) sel2 = indexer[sel3] end if sel3 < 1 then sel3 = 1 sel2 = indexer[1] end sel2 = indexer[1] while true do if yes == 1 then if sel2 == 1 then term.setCursorPos(off1+1,off2+4) write("[YES]") else term.setCursorPos(off1+1,off2+4) write(" YES ") end end if no == 1 then if sel2 == 2 then term.setCursorPos(off1+7,off2+4) write("[NO]") else term.setCursorPos(off1+7,off2+4) write(" NO ") end end if ok == 1 then if sel2 == 3 then term.setCursorPos(off1+12,off2+4) write("[OK]") else term.setCursorPos(off1+12,off2+4) write(" OK ") end end if cancle == 1 then if sel2 == 4 then term.setCursorPos(off1+17,off2+4) write("[CANCLE]") else term.setCursorPos(off1+17,off2+4) write(" CANCLE ") end end e,e1,e2,e3,e4,e5 = os.pullEvent() if e == "key" then if e1 == 203 then -- left sel3 = sel3-1 end if e1 == 205 then -- right sel3 = sel3+1 end if e1 == 28 then -- enter if indexer[sel3] == 1 then return true end if indexer[sel3] == 2 then return false end return indexer[sel3] end end sel2 = sel3 if sel3 > table.maxn(indexer) then sel3 = table.maxn(indexer) sel2 = indexer[sel3] end if sel3 < 1 then sel3 = 1 sel2 = indexer[1] end end end local listSize = 0 local parth = {} local function fileList(mode) local sParth local list = {} local x12,y12 = term.getSize() local sel = 3 local curent local offset = 0 local flot = 0 local fileName local function pointer() -- yes it points lol XD if sel > y12-2 then sel = y12-2 offset = offset+1 end if sel < 3 then sel = 3 offset = offset-1 end if offset < 0 then offset = 0 end term.setCursorPos(1,sel) write(">") end local function top() sParth = [[\]] for i = 1,table.maxn(parth) do sParth = sParth..parth[i]..[[\]] end list = fs.list(sParth) term.setCursorPos(1,1) write("Dir: "..sParth) local barier = string.rep("-",x12-2) term.setCursorPos(1,2) write(barier) end local function middle() local counter local specal local folder = {} local file = {} local this = nil for i = 1, table.maxn(list) do if fs.isDir(sParth..list[i]) then table.insert(folder,list[i]) else table.insert(file,list[i]) end end table.sort(folder) table.sort(file) table.insert(folder,1,[[\\]]) if offset > table.maxn(folder)+table.maxn(file)- (y12-5) then offset = table.maxn(folder)+table.maxn(file)- (y12-5) end if offset < 0 then offset = 0 end for i = 1 , y12-4 do if i+offset < table.maxn(folder)+1 then term.setCursorPos(3,i+2) this = folder[i+offset] write("[] "..folder[i+offset]) counter = i else if counter == nil then counter = 0 flot = offset - table.maxn(folder) end if i-counter+flot < table.maxn(file)+1 then term.setCursorPos(3,i+2) this = file[i-counter+flot] write(" "..file[i-counter+flot]) end end if i+2 == sel then curent = this end this = nil end listSize = table.maxn(folder)+table.maxn(file) end local function bottom() local barier = string.rep("-",x12-2) term.setCursorPos(1,y12-1) write(barier) term.setCursorPos(1,y12) write("File Name: "..tostring(fileName)) term.setCursorPos(x12-string.len(tostring(curent))-1,y12) write(tostring(curent)) end local function scroll() scBar = math.floor(((sel-3+offset)/(listSize+2))*(y12-2)) for i = 0,y12-3 do term.setCursorPos(x12-2,i+2) if scBar == i then write("[]") else write("||") end end end while true do term.clear() top() pointer() middle() bottom() scroll() e,e1,e2,e3,e4,e5 = os.pullEvent() if e == "key" then if e1 == 200 then -- up key sel = sel-1 end if e1 == 208 then -- down key sel = sel+1 end if e1 == 15 then -- tab term.setCursorPos(1,y12) term.clearLine() write("File Name: ") term.setCursorPos(12,y12) fileName = io.read() specal = true end if e1 == 29 then -- Ctrl if dialogBox("Message",1,1,0,0,"Exit file select") then return false end end if e1 == 28 or specal then -- enter key if curent == [[\\]] then table.remove(parth) else if curent ~= nil then if fs.isDir(sParth..curent) then table.insert(parth,curent) end end if mode == "save" then if fs.isDir(sParth..tostring(curent)) or curent == [[\\]] then else if fileName == nil and curent == nil then dialogBox("Enter a Name",0,0,1,0,"press Tab to add name") else if fs.exists(sParth..tostring(curent)) then if fs.isReadOnly(sParth..tostring(curent)) then dialogBox("Error",0,0,1,0,"File is read only") else if dialogBox("Confirm OVER WRITE",1,1,0,0,"Save as:"..sParth..curent) then return sParth..curent end end else if dialogBox("Confirm",1,1,0,0,"Save as:"..sParth..fileName) then return sParth..fileName end end end end end if mode == "load" then if curent ~= nil then if fs.isDir(sParth..curent) then else if dialogBox("confirm",1,1,0,0,"load :"..sParth..curent) then return sParth..curent else end end else dialogBox("Error",0,0,1,0,"No file selected") end end if mode == "file" then if fs.isDir(sParth..tostring(curent)) or curent == [[\\]] then else if curent == nil then else if fs.exists(sParth..tostring(curent)) then return sParth..curent end end end end end specal = false end end end end local temp local failed while true do temp = fileList("file") failed = nil if temp == false then term.clear() term.setCursorPos(1,1) return else failed = shell.run(temp) if failed then term.clear() term.setCursorPos(1,1) dialogBox("Program Crashed",0,0,1,0,"unknown cause") end end end