Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- --Vars-------------------------------------------------------------------
- local w,h = term.getSize()
- local rng = true
- local src = A.RCpath()
- local User = A.RUser()
- local conf = {}
- local cm = 0
- local txy = {}
- local cT = {}
- local xy2 = {0,0}
- local t = nil
- local ctable = nil
- local colorsC = nil
- local tbP = {}
- local tbl2 = {}
- local tbl3 = {}
- local xy = {0,0}
- --buffers--
- local figBuffer = nil
- local bImageOps = buf.createBuffer()
- ---------------------------------------------------------------------------
- local function setT(src,save)
- local file = fs.open(src,"w")
- file.write(textutils.serialize(save))
- file.close()
- end
- local function getUser()
- src = A.RCpath()
- User = A.RUser()
- end
- local function dImageOps()
- tbP = { }
- for v,k in ipairs(fs.list("os/images")) do
- if fs.isDir("os/images/"..k) then
- if ("os/images/"..k)=="os/images/icons" then
- else
- for s,d in ipairs(fs.list("os/images/"..k)) do
- table.insert(tbP,k.."/"..d)
- end
- end
- else
- table.insert(tbP,k)
- end
- end
- local x = 7
- local y = 2
- local x2 = w-8
- local y2 = h-1
- buf.drawFilledBox(bImageOps,x+1,y+1,x2-2,y2-1,colors.white)
- buf.drawBox(bImageOps,x,y,x2,y2,colors.gray)
- buf.drawLine(bImageOps,x2-1,y+2,x2-1,y2-2,colors.orange)
- buf.pos(x2-1,y+1)
- buf.bWrite(bImageOps,"^",colors.white,colors.red)
- buf.pos(x2-1,y2-1)
- buf.bWrite(bImageOps,"v",colors.white,colors.red)
- local X = x+2
- local Y = y+1
- buf.bc(colors.white)
- buf.tc(colors.black)
- for v,k in ipairs(tbP) do
- buf.pos(X,Y)
- buf.bWriteL(bImageOps,k)
- local t = {X-1,X+#k,Y,k} -- x1 x2 y (file name) os/images/kyle = kyle
- table.insert(tbl2,t)
- Y=Y+1
- end
- buf.drawBuffer(bImageOps)
- end
- local function drawOps()
- local w,h = term.getSize()
- txy = {}
- local x = 2
- local y = 3
- local t = {"Background Image:","Background Color:","Meun Color:","Meun Text Color:","Side Meun Color:","Side Meun Text Color:","Config Background Image:","Config Background Color:","Config Text Color:"}
- local tt = {"BCI","BCC","MC","MTC","SMC","SMTC","CBI","CBC","CTC"}
- local curt = 1
- buf.tc(colors.white)
- buf.bc(colors.black)
- for v,k in ipairs(t) do
- buf.pos(x,y)
- buf.bc(conf["CBC"])
- buf.tc(conf["CTC"])
- buf.bWriteLP(figBuffer,k.." ")
- buf.tc(colors.red)
- local type1 = "string"
- local tn = {}
- if type(conf[tt[curt]])=="number" then
- type1="number"
- if (conf[tt[curt]])~=conf["CBC"] then
- buf.bc(conf[tt[curt]])
- buf.bWriteLP(figBuffer," ")
- tn = {x+#k+1,x+#k+3,y,type1,tostring(tt[curt])}
- else
- for g,f in ipairs(colorsC) do
- if f[1]==conf[tt[curt]] then
- buf.bc(f[3])
- buf.tc(f[1])
- buf.bWriteLP(figBuffer,string.rep(" ",#f[2]+2))
- buf.pos(x+#k+2,y)
- buf.bWriteLP(figBuffer,f[2])
- tn = {x+#k+1,x+#k+7,y,type1,tostring(tt[curt])}
- end
- end
- end
- else
- buf.bWriteLP(figBuffer,tostring(conf[tt[curt]]))
- type1="Image"
- tn = {x+#k+1,x+#k+#conf[tt[curt]],y,type1,tostring(tt[curt])}
- end
- buf.bc(conf["CBC"])
- --tn = (x1, x2, y, type ) type = string or color
- table.insert(txy,1,tn)
- curt=curt+1
- y=y+1
- end
- buf.pos(2,h-4)
- buf.tc(conf["CTC"])
- buf.bWriteLP(figBuffer,"UserName:")
- buf.tc(colors.red)
- buf.bWriteLP(figBuffer,tostring(User))
- tn = {11,11+#User-1,h-4,"file",User}
- table.insert(txy,1,tn)
- buf.pos(2,h-2)
- buf.tc(conf["CTC"])
- buf.bWriteLP(figBuffer,"PassWord:")
- buf.tc(colors.red)
- buf.bWriteLP(figBuffer,tostring(conf["PW"]))
- tn = {11,11+#conf["PW"],h-2,"string","PW"}
- table.insert(txy,1,tn)
- end
- local function dm()
- conf = A.getT(src)
- colorsC = A.getT("os/files/colorsC")
- buf.bc(conf["CBC"])
- A.dfig()
- drawOps()
- buf.copyBuffer(figBuffer,bImageOps)
- buf.drawBuffer(figBuffer)
- A.Time(w-4,h,conf["MC"],conf["MTC"])
- end
- function main()
- figBuffer = A.RFmeun()
- conf = A.getT(src)
- colorsC = A.getT("os/files/colorsC")
- dm()
- t = os.startTimer(.1)
- while true do
- getUser()
- conf = A.getT(src)
- local arg = { os.pullEvent() }
- if arg[1]=="timer" and arg[2]==t then
- A.Time(w-3,h,conf["MC"],conf["MTC"])
- t = os.startTimer(.1)
- elseif cm==0 then
- if arg[1]=="mouse_click" then
- if arg[2]==1 then
- if arg[3]>=2 and arg[3]<=8 and arg[4]==1 then
- A.dmeun5()
- cm=1
- else
- local ok = false
- local x = arg[3]
- local y = arg[4]
- -- tn = (x1, x2, y, type ) tpye = string or color
- for v,k in ipairs(txy) do
- if x>=k[1] and x<=k[2] then
- if y==k[3] then
- term.setTextColor(colors.white)
- ok = true
- cT = txy[v]
- end
- end
- end
- if ok then
- cm=2
- else
- dm()
- end
- end
- elseif arg[2]==2 then
- xy = {A.dmeun6(arg[3],arg[4])}
- cm=5
- end
- end
- elseif cm==1 then
- if arg[1]=="mouse_click" then
- if arg[2]==1 then
- if arg[3]>=2 and arg[3]<=11 then
- if arg[4]==3 then
- A.ExitIS(true,true)
- break
- elseif arg[4]==4 then
- os.shutdown()
- elseif arg[4]==5 then
- os.reboot()
- elseif arg[4]==6 then
- break
- else
- dm()
- cm=0
- end
- else
- dm()
- cm=0
- end
- else
- dm()
- cm=0
- end
- end
- elseif cm==2 then
- if cT[4]=="string" then
- term.setCursorPos(cT[1],cT[3])
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.green)
- write(string.rep(" ",cT[2]-cT[1]+1))
- term.setCursorPos(cT[1],cT[3])
- local input = read()
- sleep(.2)
- if input~=conf[cT[5]] then
- conf[cT[5]]=input
- end
- setT(src,conf)
- dm()
- cm=0
- elseif cT[4]=="Image" then
- dImageOps()
- t = os.startTimer(.1)
- cm=4
- elseif cT[4]=="number" then
- ctable = {}
- local function color()
- local t = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
- local x = cT[2]+2
- local y = cT[3]
- for v,k in ipairs(t) do
- term.setBackgroundColor(k)
- write(" ")
- local ct = {x,y,k}
- table.insert(ctable,ct)
- x=x+1
- end
- end
- term.setCursorPos(cT[2]+2,cT[3])
- color()
- cm=3
- elseif cT[4]=="file" then
- term.setCursorPos(cT[1],cT[3])
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.green)
- write(string.rep(" ",cT[2]-cT[1]+1))
- term.setCursorPos(cT[1],cT[3])
- local input = read()
- sleep(.2)
- --tn = {11,11+#User-1,h-4,"file",User}
- if input~=cT[5] then
- if input~="" then
- fs.move("os/users/"..User, "os/users/"..input)
- A.LoadConf(input)
- getUser()
- end
- end
- dm()
- cm=0
- end
- t = os.startTimer(.1)
- elseif cm==3 then
- if arg[1]=="mouse_click" and arg[2]==1 then
- for v,k in ipairs(ctable) do
- if arg[3]==k[1] and arg[4]==k[2] then
- if cT[5]=="CBC" then
- if k[3]~=conf["CTC"] then
- conf[cT[5]]=k[3]
- setT(src,conf)
- end
- elseif cT[5]=="CTC" then
- if k[3]~=conf["CBC"] then
- conf[cT[5]]=k[3]
- setT(src,conf)
- end
- else
- conf[cT[5]]=k[3]
- setT(src,conf)
- end
- end
- end
- dm()
- cm=0
- end
- t = os.startTimer(.1)
- A.reloadMeuns()
- elseif cm==4 then
- if arg[1]=="mouse_click" then
- if arg[2]==1 then
- for v,k in ipairs(tbl2) do
- if arg[3]>=k[1] and arg[3]<=k[2] then
- if arg[4]==k[3] then
- conf[cT[5]]="os/images/"..k[4]
- setT(src,conf)
- end
- end
- end
- dm()
- cm=0
- setT(src,conf)
- elseif arg[2]==2 then
- for v,k in ipairs(tbl2) do
- if arg[3]>=k[1] and arg[3]<=k[2] then
- if arg[4]==k[3] then
- tbl3 = {k[4]}
- A.dmeun4(k[1]+1,k[3]+1)
- cm=6
- xy = {k[1]+1,k[3]+1}
- end
- end
- end
- else
- dm()
- cm=0
- end
- end
- elseif cm==5 then
- if arg[1]=="mouse_click" then
- if arg[2]==1 then
- if arg[3]>=xy[1]+1 and arg[3]<=xy[1]+11 then
- if arg[4]==xy[2]+1 then
- dm()
- local input = A.userin(2,3,3)
- shell.run("paint",input) ---new icon
- dm()
- t = os.startTimer(.1)
- cm=0
- else
- dm()
- cm=0
- end
- else
- dm()
- cm=0
- end
- else
- dm()
- cm=0
- end
- end
- elseif cm==6 then
- if arg[1]=="mouse_click" then
- if arg[2]==1 then
- if arg[3]>=xy[1]+1 and arg[3]<=xy[1]+8 then
- if arg[4]==xy[2]+1 then
- shell.run("paint","os/images/"..tbl3[1])
- t = os.startTimer(.1)
- dm()
- dImageOps()
- cm=4
- elseif arg[4]==xy[2]+2 then
- shell.run("delete","os/images/"..tbl3[1])
- if conf["BCI"] == "os/images/"..tbl3[1] then
- conf["BCI"] = "os/images/default"
- elseif conf["CBI"] == "os/images/"..tbl3[1] then
- conf["CBI"] = "os/images/default"
- end
- setT(src,conf)
- t = os.startTimer(.1)
- dm()
- dImageOps()
- cm=4
- else
- dm()
- dImageOps()
- t = os.startTimer(.1)
- cm=4
- end
- else
- dm()
- dImageOps()
- t = os.startTimer(.1)
- cm=4
- end
- else
- dm()
- dImageOps()
- t = os.startTimer(.1)
- cm=4
- end
- end
- end
- end
- end
- local ok, err = pcall(main)
- if not ok then
- A.Error(err)
- sleep(5)
- end
Add Comment
Please, Sign In to add comment