Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local redos_files = {
- [ "vhd/RedOS/ea" ] = {
- content = "function s(...) return sleep(...) end\
- function w(...) return write(...) end\
- function p(...) return print(...) end\
- function tw(...) return term.write(...) end\
- function scp(...) return term.setCursorPos(...) end\
- function sbc(...) return term.setBackgroundColor(...) end\
- function stc(...) return term.setTextColor(...) end\
- function tc(...) return term.clear(...) end\
- function tcl(...) return term.clearLine() end\
- function scb(...) return term.setCursorBlink(...) end\
- function ts(...) return term.scroll(...) end\
- function r(...) return shell.run(...) end\
- function para(...) return parallel.waitForAny(...) end\
- function sw(...) return textutils.slowWrite(...) end\
- function sp(...) return textutils.slowPrint(...) end",
- },
- [ "vhd/RedOS/.RedOS/startmenu/apps/cozyfile" ] = {
- content = "local arg = { ... }\
- \
- local selFile = \"\"\
- local fPath = \"rom/\"\
- local fDefault = fPath\
- local fPrePath = fPath\
- local printoff = 0\
- local mfoff = 0\
- local fs_ver = \"RedOS - v1.0 Alpha\"\
- local copy_path = \"\"\
- local copy_file = \"\"\
- local fName = \"\"\
- shell.setDir(\"\")\
- function checkShort(name)\
- return fs.isDir(\".RedOS/desktop/\"..name)\
- end\
- \
- function deleteShort (name)\
- fs.delete(\".RedOS/desktop/\"..name)\
- inContext = false\
- inRun = true\
- fileSystem()\
- end\
- \
- function makeShortcut (name,mkLoc)\
- fs.makeDir(\".RedOS/desktop/\"..name)\
- fs.copy(mkLoc, \".RedOS/desktop/\"..name..\"/\"..name)\
- shell.run(\"paint\",\".RedOS/desktop/\"..name..\"/icon\")\
- inContext = false\
- inRun = true\
- fileSystem()\
- \
- end\
- \
- local theme = {\
- \
- foldercolor = colors.lime,\
- filecolor = colors.orange,\
- iconbgcolor = colors.gray,\
- folderIcon = \"[=]\",\
- fileIcon = \"-~-\",\
- bgcolor = colors.white,\
- tbcolor = colors.gray,\
- tbtcolor = colors.yellow,\
- textcolor = colors.black,\
- dimtextcolor = colors.gray,\
- selectedcolor = colors.blue,\
- mbcolor = colors.black,\
- mtcolor = colors.white,\
- infocolor = colors.lightGray,\
- shortcolor = colors.blue,\
- }\
- \
- \
- if(#arg > 0)then\
- f = fs.open(arg[1],\"r\")\
- filetheme = textutils.unserialize(f.readAll())\
- f.close()\
- \
- theme = setmetatable(filetheme, {__index = theme})\
- end\
- \
- \
- inRun = true\
- inContext=false\
- \
- \
- local contextEmpty = {\
- [\"____________\"] = {x=0,y=0,yoff = 1, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() end};\
- [\" New Folder \"] = {x=0,y=0,yoff = 2, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() ea.scp(1,1) ea.sbc(theme.tbcolor) ea.stc(theme.mtcolor); term.clearLine() write(\"New Folder: \") nFn = read(); if(not fs.isDir(nFn) and nFn ~= \"\")then fs.makeDir(fPath..\"/\"..nFn) inContext = false; inRun = true; cEmpty = false; fileSystem() end end};\
- [\" New File \"] = {x=0,y=0,yoff = 3, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() ea.scp(1,1) ea.sbc(theme.tbcolor) ea.stc(theme.mtcolor); term.clearLine() write(\"New File: \") nFn = read(); if(not fs.exists(fPath..\"/\"..nFn) and nFn ~= \"\")then f=fs.open(fPath..\"/\"..nFn,\"w\") f.writeLine(\" \") f.close(); cEmpty = false; inContext = false; inRun = true; fileSystem() end end};\
- [\" Paste \"] = {x=0,y=0,yoff = 4, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() if(fs.exists(fPath..\"/\"..copy_file))then cut =false inContext = false inRun = true selFile = fPath..copy_file; copy_path = \"\" copy_file = \"\" fileSystem() end if(copy_path ~= \"\" and not fs.exists(fPath..\"/\"..copy_file))then if(not cut)then fs.copy(copy_path,fPath..\"/\"..copy_file); else fs.move(copy_path,fPath..\"/\"..copy_file); cut =false end inContext = false inRun = true selFile = fPath..copy_file; copy_path = \"\" copy_file = \"\" fileSystem() end end}; \
- [\"------------\"] = {x=0,y=0,yoff = 5, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() end};\
- }\
- \
- \
- local folderMenu = {\
- \
- [\"_____________\"] = {yoff = 1, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() end};\
- [\" Open Folder \"] = {yoff = 2, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() fPrePath = fPath; fPath = fPath..fName..\"/\"; selFile = \"\"; loadFS(fPath); inContext=false inRun = true fileSystem(); end};\
- [\" New Folder \"] = {yoff = 3, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() ea.scp(1,1) ea.sbc(theme.tbcolor) ea.stc(theme.textcolor); term.clearLine() write(\"New Folder: \") nFn = read(); if(not fs.isDir(nFn) and nFn ~= \"\")then fs.makeDir(fPath..\"/\"..nFn) inContext = false; inRun = true; fileSystem() end end};\
- [\" Cut \"] = {yoff= 4, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() cut = true; copy_path = selFile; copy_file = fName inContext = false inRun = true fileSystem() end};\
- [\" Copy \"] = {yoff= 5, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() cut = false; copy_path = selFile; copy_file = fName inContext = false inRun = true fileSystem() end};\
- [\"Rename Folder\"] = {yoff = 6, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() ea.sbc(theme.bgcolor) ea.stc(theme.textcolor); ea.scp(4,renameY) write(string.rep(\" \",15)) ea.scp(4,renameY); nFn = read(); if(not fs.isDir(fPath..\"/\"..nFn))then fs.move(selFile, fPath..\"/\"..nFn) inContext = false inRun = true fileSystem(); end end};\
- [\"Delete Folder\"] = {yoff = 7, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() fs.delete(selFile); selFile = \"\"; inContext = false; inRun = true fileSystem(); end};\
- [\"-------------\"] = {yoff = 8, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() end};\
- }\
- \
- \
- \
- local contextMenu = {\
- \
- --[\"____________\"] = {yoff = 1, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() end};\
- --[\"Run File \"] = {yoff = 2, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() os.run({},selFile) inContext = false; inRun = true; fileSystem() ;end};\
- [\"Edit File \"] = {yoff = 1, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() shell.run(\"edit\",selFile); inContext = false; inRun = true; fileSystem() end};\
- [\"New File \"] = {yoff = 2, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() \
- ea.scp(1,1) \
- ea.sbc(theme.tbcolor) \
- ea.stc(theme.mtcolor); \
- term.clearLine() \
- write(\"New File: \") \
- nFn = read(); \
- if(not fs.exists(nFn) and nFn ~= \"\")then \
- f = fs.open(fPath..\"/\"..nFn,\"w\") \
- f.writeLine(\" \") \
- f.close(); \
- \
- inContext = false; \
- inRun = true; \
- fileSystem() \
- end end};\
- [\"New Folder \"] = {yoff = 3, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() ea.scp(1,1) ea.sbc(theme.tbcolor) ea.stc(theme.mtcolor); term.clearLine() write(\"New Folder: \") nFn = read(); if(not fs.isDir(nFn) and nFn ~= \"\")then fs.makeDir(fPath..\"/\"..nFn) inContext = false; inRun = true; fileSystem() end end}; \
- [\"Cut \"] = {yoff= 4, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() cut = true; copy_path = selFile; copy_file = fName inContext = false inRun = true fileSystem() end};\
- [\"Copy \"] = {yoff= 5, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() cut = false; copy_path = selFile; copy_file = fName inContext = false inRun = true fileSystem() end};\
- [\"Link File \"] = {yoff= 6, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() makeShortcut(fName, selFile) end};\
- [\"Remove Link \"] = {yoff= 7, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() if(checkShort(fName))then deleteShort(fName) end end};\
- [\"Rename File \"] = {yoff = 8, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() ea.scp(4,renameY); ea.stc(theme.textcolor) ea.sbc(theme.bgcolor); print(\" \") ea.scp(5,renameY) nFn = read() if(not fs.exists(fPath..nFn) and nFn ~= \"\")then fs.move(selFile,fPath..nFn); end inRun = true; inContext = false; fileSystem() end};\
- [\"Delete File \"] = {yoff = 9, bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() if(fs.exists(selFile))then fs.delete(selFile); inContext = false; inRun = true; fileSystem(); end end};\
- [\"------------\"] = {yoff = 10,bcol=theme.mbcolor,tcol=theme.mtcolor,fcmd = function() end};\
- } \
- \
- local w,h = term.getSize()\
- \
- os.loadAPI(\"ea\")\
- os.loadAPI(\"cozy_string\")\
- \
- function clear() ea.sbc(theme.bgcolor); term.clear() end\
- clear()\
- \
- --]] FILE SYSTEM [[--\
- local filetable = {}\
- \
- function loadFS(fsl)\
- \
- mfoff = 0\
- \
- \
- if(filetable ~= {})then filetable = {}\
- \
- for k, v in pairs(fs.list(fsl)) do \
- \
- if(fs.isDir(fsl..v))then isdir=true; else isdir = false; end\
- \
- if(not filetable[v])then\
- filetable[v] = v\
- filetable[v] = {offset = k, dir = isdir};\
- mfoff = mfoff + 1 \
- end\
- \
- end\
- \
- end\
- end\
- \
- \
- function drawMenu(x,y)\
- \
- \
- for k, v in pairs(contextMenu)do\
- \
- ea.sbc(v.bcol)\
- ea.stc(v.tcol)\
- ea.scp(x+2,y+v.yoff)\
- print(k)\
- \
- end\
- \
- end\
- \
- function drawEmptyContext(x,y)\
- \
- for k, v in pairs(contextEmpty)do\
- \
- v.x=x\
- v.y=y+v.yoff\
- ea.sbc(v.bcol)\
- ea.stc(v.tcol)\
- ea.scp(x+2,y+v.yoff)\
- print(k)\
- \
- end\
- \
- end\
- \
- \
- function drawFolderMenu(x,y)\
- \
- \
- for k, v in pairs(folderMenu)do\
- \
- ea.sbc(v.bcol)\
- ea.stc(v.tcol)\
- ea.scp(x+2,y+v.yoff)\
- print(k)\
- \
- end\
- \
- end\
- \
- \
- function fileSystem()\
- \
- \
- \
- while inRun do \
- \
- clear()\
- \
- ea.scp(1,2)\
- \
- moff = 14\
- \
- \
- loadFS(fPath)\
- \
- \
- ea.sbc(theme.bgcolor)\
- term.clear()\
- ea.sbc(theme.tbcolor)\
- ea.scp(1,1)\
- term.clearLine()\
- ea.stc(theme.tbtcolor)\
- ea.scp(1,1)\
- print(\"Cozy File Manager \")\
- ea.scp(w-#fs_ver,1)\
- print(fs_ver)\
- ea.stc(theme.infocolor)\
- ea.sbc(theme.bgcolor)\
- print(fPath)\
- print(\"[BACK] [EXIT]\")\
- \
- \
- \
- for k, v in pairs(filetable) do\
- \
- if(v.offset-printoff < moff+1 and v.offset >= printoff)then\
- \
- if( ((v.offset)-printoff)+3 < 4)then addl = 4 else addl = ( (v.offset) - printoff )+3 end\
- \
- if(checkShort(k))then \
- ea.stc(theme.shortcolor) \
- else \
- if(v.dir)then \
- ea.stc(theme.foldercolor) \
- else \
- ea.stc(theme.filecolor)\
- end \
- end\
- \
- if(v.dir)then ea.sbc(theme.iconbgcolor); ea.scp(1,addl); write(theme.folderIcon); if(cut and copy_path == fPath..k)then ea.stc(theme.dimtextcolor) else ea.stc(theme.textcolor); end ea.sbc(theme.bgcolor); if(fPath..k == selFile)then ea.sbc(theme.selectedcolor) else ea.sbc(theme.bgcolor) end; print(\" \"..k) end\
- if(not v.dir)then ea.sbc(theme.iconbgcolor); ea.scp(1,addl); write(theme.fileIcon); ea.sbc(theme.bgcolor); if(cut and copy_path == fPath..k)then ea.stc(theme.dimtextcolor) else ea.stc(theme.textcolor); end if(fPath..k == selFile)then ea.sbc(theme.selectedcolor) else ea.sbc(theme.bgcolor) end; print(\" \"..k) end\
- end\
- \
- if(mfoff-printoff > moff)then\
- \
- ea.stc(theme.infocolor)\
- ea.scp(10,3)\
- print(\"+\")\
- end\
- \
- if(printoff+1 > 1)then\
- \
- ea.stc(theme.infocolor)\
- ea.scp(11,3)\
- print(\"-\")\
- end\
- \
- end\
- \
- \
- mi = {os.pullEvent()}\
- \
- \
- if(mi[1] == \"mouse_click\" and mi[2] == 1)then\
- \
- fBi = 1\
- clkF = 0\
- \
- for k, v in pairs(filetable) do\
- \
- if(mi[3] >= 1 and mi[3] <= 4+#k and mi[4] == (v.offset-printoff)+3)then\
- \
- clkF = 1\
- if(v.dir and selFile == fPath..k)then fPrePath = fPath; fPath = fPath..k..\"/\"; loadFS(fPath); selFile = \"\"; printoff = 0 end\
- if(selFile == fPath..k)then ea.stc(colors.white); ea.sbc(colors.black); ea.scp(1,1); os.run({},fPath..k); term.setCursorBlink(false) ea.sbc(colors.black) ea.stc(colors.white) term.clear() print(\"Press Any Key\") os.pullEvent(\"key\")\
- else selFile = \"\"; selFile = fPath..k; fName = k end\
- \
- end\
- \
- end\
- if(clkF == 0)then selFile = \"\" end\
- \
- if( mi[3] >= 1 and mi[3] <= 6 and mi[4] == 3)then \
- fPrePath = cozy_string.split(fPrePath,\"/\",(cozy_string.pathLen(fPath)-fBi))\
- fPath = fPrePath; \
- printoff = 0 \
- selFile = \"\"\
- loadFS(fPath)\
- fBi = 0\
- end\
- \
- if( mi[3] >= w-6 and mi[3] <= w and mi[4] == 3)then inRun=false; ea.sbc(colors.black) ea.stc(colors.white) ea.scp(1,1) end\
- \
- else\
- \
- fBi = 1\
- \
- if(mi[1] == \"key\" or mi[1] == \"mouse_scroll\")then\
- \
- ea.scp(1,1)\
- pfc = mfoff\
- if(mi[2] == keys.up or mi[2] == -1)then if(printoff > 0)then printoff = printoff - 1 end end\
- if(mi[2] == keys.down or mi[2] == 1)then if(printoff < mfoff-moff)then printoff = printoff + 1 end end\
- \
- end\
- \
- end\
- \
- if(mi[1] == \"mouse_click\" and mi[2] == 2)then\
- \
- i = 0\
- \
- for k, v in pairs(filetable) do\
- \
- i = i + 1\
- \
- if(mi[3] >= 1 and mi[3] <= #k+5 and mi[4] == (v.offset-printoff)+3 and not inContext)then\
- \
- if(selFile == fPath..k)then\
- \
- if(mi[4] >= h-9)then\
- prntedY = ((v.offset-printoff)+3)-9\
- else\
- prntedY = (v.offset-printoff)+3\
- end\
- \
- renameY = (v.offset-printoff)+3 \
- \
- if(not fs.isDir(selFile))then drawMenu(1,prntedY) else if(mi[4] >= h-10)then end drawFolderMenu(1,prntedY) end\
- contextY = prntedY\
- cEmpty=false\
- inContext = true\
- inRun = false\
- fileSystem()\
- \
- \
- end\
- end\
- \
- if(selFile == \"\" and not (mi[3] >= w-6 and mi[3] <= w and mi[4] == 3) )then\
- \
- if(mi[4] >= h-5)then pY = mi[4]-10 else pY = mi[4] end\
- if(mi[3] >= w-12)then pX = w-22 else pX = mi[3] end\
- drawEmptyContext(pX,pY) \
- cEmpty = true\
- inContext=true\
- inRun=false\
- \
- end\
- \
- end\
- \
- if(i == 0 )then\
- \
- if(mi[4] >= h-5)then\
- pY = mi[4]-10\
- else\
- pY = mi[4]\
- end\
- \
- if(mi[3] >= w-12)then\
- pX = w-22\
- else\
- pX = mi[3]\
- end\
- \
- drawEmptyContext(pX,pY) \
- cEmpty = true\
- inContext=true\
- inRun=false\
- \
- end\
- \
- end\
- end\
- \
- \
- while inContext and not inRun do\
- \
- m = {os.pullEvent()}\
- \
- if(m[1] == \"mouse_click\")then\
- \
- if(m[2] == 2)then inContext = false; inRun = true; fileSystem() end\
- \
- if(cEmpty)then\
- for k, v in pairs(contextEmpty) do\
- \
- if(m[2] == 1 and m[3] >= v.x and m[3] <= (#k)+v.x and m[4] == v.y)then\
- \
- v.fcmd()\
- \
- end\
- \
- end\
- end\
- \
- \
- if(not fs.isDir(selFile) and not cEmpty)then\
- \
- for k, v in pairs(contextMenu) do\
- \
- if(m[2] == 1 and m[3] >=3 and m[3] <= #k+3 and m[4] == v.yoff+contextY)then\
- \
- v.fcmd()\
- \
- end\
- \
- end\
- end\
- \
- if(not cEmpty and fs.isDir(selFile))then\
- for k, v in pairs(folderMenu) do\
- \
- if(m[2] == 1 and m[3] >=3 and m[3] <= #k+3 and m[4] == v.yoff+contextY)then\
- \
- v.fcmd()\
- \
- end\
- \
- end\
- end \
- \
- end\
- \
- end\
- \
- end\
- fileSystem()",
- },
- [ "vhd/RedOS/redos" ] = {
- content = "\
- \
- -- Life Easier Commands -- \
- local w, h = term.getSize()\
- local scp = term.setCursorPos\
- local sbc = term.setBackgroundColor\
- local stc = term.setTextColor\
- local sp = textutils.slowPrint\
- local cl = term.clear\
- local needUpdate = false\
- local iconContent = {}\
- local clk = function(btext,x,y,color,time) sbc(color) scp(x,y) write(btext) sleep(time) end\
- shell.setDir(\"\")\
- \
- function checkUpdate()\
- local res = http.get(\"http://www.pastebin.com/raw.php?i=mZi6TjgU\")\
- \
- if res then \
- con = res.readAll() \
- res.close() \
- \
- f = fs.open(shell.getRunningProgram(),\"r\")\
- compare = f.readAll()\
- f.close()\
- \
- if(con ~= compare)then \
- needUpdate = true\
- else\
- needUpdate = false\
- end\
- \
- end\
- \
- end\
- \
- function UncodeColor(code)\
- \
- local code_colors = {\
- \
- [\"0\"] = colors.white,\
- [\"1\"] = colors.orange,\
- [\"2\"] = colors.magenta,\
- [\"3\"] = colors.lightBlue,\
- [\"4\"] = colors.yellow,\
- [\"5\"] = colors.lime,\
- [\"6\"] = colors.pink,\
- [\"7\"] = colors.gray,\
- [\"8\"] = colors.lightGray,\
- [\"9\"] = colors.cyan,\
- [\"a\"] = colors.purple,\
- [\"b\"] = colors.blue,\
- [\"c\"] = colors.brown,\
- [\"d\"] = colors.green,\
- [\"e\"] = colors.red,\
- [\"f\"] = colors.black,\
- \
- }\
- \
- \
- for k, v in pairs(code_colors) do\
- if(code == k)then return v end\
- end\
- \
- end\
- \
- \
- function drawIcon(file,x,y)\
- \
- x = x - 1\
- y = y - 1\
- \
- file = \"tut/lol\"\
- -- get file and content from a 5x5 pixel area --\
- f = fs.open(file,\"r\")\
- for i = 1, 5 do\
- table.insert(iconContent,f.readLine():sub(1,5))\
- end\
- f.close()\
- \
- -- now to draw the contents grabed from the icon\
- for i = 1, #iconContent do\
- -- how do i set the color?\
- for cf = 1, 5 do\
- scp(x+cf,y+i)\
- sbc(UncodeColor(iconContent[i]:sub(cf,cf)))\
- write(\" \")\
- end\
- end\
- \
- end\
- \
- \
- function fadeScr()\
- local fadecolors = {colors.black,colors.gray,colors.lightGray,colors.white}\
- for i = 1, #fadecolors do\
- term.setBackgroundColor(fadecolors[i])\
- term.clear()\
- sleep(rate)\
- end\
- end\
- \
- function fadeout_complete(rate,text)\
- local fadecolors = {colors.white,colors.lightGray,colors.gray,colors.black}\
- local txtfcolors = {colors.black,colors.gray,colors.lightGray,colors.black}\
- for i = 1, #fadecolors do\
- term.setBackgroundColor(fadecolors[i])\
- term.clear()\
- term.setTextColor(txtfcolors[i])\
- center_complete(text)\
- sleep(rate)\
- end\
- end\
- \
- function center_x(text,y)\
- term.setCursorPos((w/2) - (#text/2), y)\
- print(text)\
- end\
- \
- function center_y(text,x)\
- term.setCursorPos(x, (h/2))\
- print(text)\
- end\
- \
- function center_complete(text,optional_yoffset)\
- if(not optional_yoffset)then term.setCursorPos((w/2) - (#text/2), (h/2) ) end\
- if(optional_yoffset)then term.setCursorPos((w/2) - (#text/2), (h/2)+optional_yoffset) end\
- write(text)\
- end\
- -----------------------------\
- \
- \
- -- Program Enviorment\
- local programs = {\
- prgs = {},\
- progpath = \".RedOS/docs/\",\
- selected=false,\
- inMenu = false,\
- menutype = '',\
- selID = 1,\
- \
- shortAddMenu = {\
- \
- {g=\" \"};\
- {g=\" Add Shortcut? \"};\
- {g=\" \"};\
- {g=\" \"};\
- {g=\" [Accept] - [Cancel] \"};\
- \
- },\
- \
- remMenu = {\
- \
- {g=\" \"};\
- {g=\" Delete Program? \"};\
- {g=\" \"};\
- {g=\" \"};\
- {g=\" [Accept] - [Cancel] \"};\
- \
- },\
- \
- shortRemMenu = {\
- \
- {g=\" \"};\
- {g=\" Remove Shortcut? \"};\
- {g=\" \"};\
- {g=\" \"};\
- {g=\" [Accept] - [Cancel] \"};\
- \
- },\
- \
- draw_short = function(self, state)\
- if(state)then shm = self.shortRemMenu else shm = self.shortAddMenu end\
- scp(1,(h/2) - (#shm)/2)\
- for i = 1, #shm do\
- sbc(colors.orange)\
- stc(colors.white)\
- scp(5,((h/2) - ((#shm)/2))+i)\
- print(shm[i].g)\
- sleep(0.01)\
- end\
- end,\
- \
- draw_del = function(self)\
- shm = self.remMenu\
- scp(1,(h/2) - (#shm)/2)\
- for i = 1, #shm do\
- sbc(colors.orange)\
- stc(colors.white)\
- scp(5,((h/2) - ((#shm)/2))+i)\
- print(shm[i].g)\
- sleep(0.01)\
- end\
- end,\
- \
- \
- \
- checkShort = function(self,name)\
- return fs.isDir(\".RedOS/desktop/\"..name)\
- end,\
- \
- deleteShort = function(self,name)\
- fs.delete(\".RedOS/desktop/\"..name)\
- end,\
- \
- makeShortcut = function(self,name,mkLoc)\
- fs.makeDir(\".RedOS/desktop/\"..name)\
- fs.copy(mkLoc, \".RedOS/desktop/\"..name..\"/\"..name)\
- \
- shell.run(\"paint\",\".RedOS/desktop/\"..name..\"/icon\")\
- end,\
- \
- getprogs = function(self)\
- self.prgs = {}\
- for k, v in pairs(fs.list(self.progpath)) do\
- self.prgs[k] = {sel=false,file=v,off=k,dir = fs.isDir(self.progpath..v)}\
- end\
- end,\
- \
- \
- \
- clear = function(self)\
- sbc(colors.white)\
- cl()\
- \
- sbc(colors.red)\
- scp(1,1)\
- term.clearLine()\
- scp(1,1)\
- stc(colors.white)\
- write(\"Programs\")\
- sbc(colors.orange)\
- scp(w,1)\
- write(\"X\")\
- scp((w)-9,2)\
- sbc(colors.red)\
- stc(colors.white)\
- self:getprogs()\
- for i = 2, h do \
- scp(w-9,i)\
- write(string.rep(\" \",10))\
- end\
- end,\
- \
- draw = function(self)\
- self:clear()\
- end,\
- \
- update = function(self)\
- \
- sbc(colors.orange)\
- stc(colors.white)\
- center_x(\"Downloaded Programs\",3)\
- \
- \
- stc(colors.black)\
- sbc(colors.red)\
- scp(w-8,3)\
- write(\"Shortcut\")\
- scp(w-8,4)\
- write(\"Delete\")\
- sbc(colors.white)\
- -- print out programs--\
- \
- -- draw programs --\
- \
- \
- for i = 1, #self.prgs do\
- if(not self.prgs[i].dir)then \
- scp(1,i+3)\
- stc(colors.black)\
- if(self.prgs[i].sel)then sbc(colors.lightBlue) else sbc(colors.white) end\
- if(self:checkShort(self.prgs[i].file))then stc(colors.green) else stc(colors.black) end\
- print(self.prgs[i].file)\
- end\
- end\
- \
- a = {os.pullEvent()}\
- \
- if( (a[1] == \"mouse_drag\" or a[1] == \"mouse_click\") and a[2] == 1)then\
- if(a[3] >= w and a[4] == 1)then \
- clk(\"X\",w,1,colors.red,0.2)\
- self.selected=false\
- setState('desktop') \
- end\
- scp(1,2)\
- stc(colors.black)\
- --print(a[3]..\" | \"..a[4])\
- \
- -- Button Clicks --\
- if(a[3] >= w-10 and a[4] == 4 and self.selected)then -- Remove File\
- self:draw_del()\
- self.inMenu = true\
- menutype = 'remove'\
- end\
- \
- if(a[3] >= w-10 and a[4] == 3 and self.selected)then -- Manage Shortcut File\
- \
- if(self:checkShort(self.prgs[self.selID].file))then \
- self:draw_short(true)\
- self.inMenu = true\
- menutype = 'shortcut-' \
- else \
- self:draw_short(false)\
- self.inMenu = true\
- menutype = 'shortcut+' \
- end\
- end\
- \
- -- cancel button --\
- \
- if(a[3] >= 29 and a[3] <= 36 and a[4] == 12 and self.inMenu == true)then\
- self.selected=false\
- self.inMenu=false\
- self:clear()\
- end\
- \
- -- accept button --\
- if(a[3] >= 16 and a[3] <= 23 and a[4] == 12 and self.inMenu == true)then\
- if(menutype == 'remove')then\
- fs.delete(self.progpath..self.prgs[self.selID].file)\
- if(self:checkShort(self.prgs[self.selID].file))then self:deleteShort(self.prgs[self.selID].file) end\
- self:clear()\
- self:update()\
- self.inMenu = false\
- self.selected=false\
- elseif(menutype=='shortcut+')then\
- self:makeShortcut(self.prgs[self.selID].file,self.progpath..self.prgs[self.selID].file)\
- self.inMenu = false\
- self.selected=false\
- setState('desktop')\
- elseif(menutype=='shortcut-')then\
- self:deleteShort(self.prgs[self.selID].file)\
- self:clear()\
- self:update()\
- self.inMenu = false\
- self.selected=false\
- end\
- end\
- \
- -- program selection / management --\
- for i = 1, #self.prgs do\
- if(not self.prgs[i].dir)then \
- \
- if(a[3] >= 1 and a[3] <= #self.prgs[i].file and a[4] == i+3)then\
- if(self.selected)then\
- if(self.prgs[i].sel)then self.prgs[i].sel=false self.selected=false end\
- else\
- self.prgs[i].sel = true\
- self.selected=true\
- self.selID = i\
- end\
- self:update()\
- end\
- end\
- end\
- end\
- end,\
- }\
- \
- \
- -- Downloader Enviorment\
- local downloader = {\
- \
- downloading=false,\
- \
- dwnFiles = {\
- {text=\"Kosy Mail\",url=\"Tsjq5eVa\",locdir = \".RedOS/docs/cozymail\",down=false,install=true,has=false};\
- {text=\"Kosy Chat\",url=\"cj8SKTMj\", locdir = \".RedOS/docs/cozychat\",down=false,install=false,has=true};\
- },\
- \
- \
- draw = function(self)\
- sbc(colors.white)\
- cl()\
- sbc(colors.red)\
- scp(1,1)\
- term.clearLine()\
- scp(1,1)\
- stc(colors.white)\
- write(\"Downloader\")\
- sbc(colors.orange)\
- scp(w,1)\
- write(\"X\")\
- end,\
- download = function(self)\
- \
- if(not http)then setState('desktop') end\
- self.downloading=true\
- \
- sleep(1)\
- for i = 1, #self.dwnFiles do\
- if(self.dwnFiles[i].down)then\
- local res = http.get(\"http://www.pastebin.com/raw.php?i=\"..textutils.urlEncode(self.dwnFiles[i].url) )\
- \
- if res then \
- con = res.readAll() \
- res.close() \
- else\
- changeState('desktop')\
- end\
- \
- if(self.dwnFiles[i].install)then\
- f = fs.open(\".temp\",\"w\")\
- f.write(con)\
- f.close()\
- shell.run(\".temp\")\
- fs.delete(\".temp\")\
- self.dwnFiles[i].down = false\
- self.downloading=false\
- else\
- f = fs.open(self.dwnFiles[i].locdir,\"w\")\
- f.write(con)\
- f.close()\
- self.dwnFiles[i].down = false\
- self.downloading=false\
- end\
- end\
- end\
- \
- end,\
- update = function(self)\
- \
- \
- if(self.downloading)then sbc(colors.red) else sbc(colors.green) end\
- stc(colors.white)\
- scp(1,h-1)\
- write(string.rep(\" \",w))\
- center_x(\"Download\",h-1)\
- \
- sbc(colors.orange)\
- stc(colors.white)\
- center_x(\"Available RedOS Software\",3)\
- \
- sbc(colors.white)\
- stc(colors.black)\
- \
- -- print out downloadablez --\
- for i = 1, #self.dwnFiles do\
- if(fs.exists(self.dwnFiles[i].locdir))then self.dwnFiles[i].has = true else self.dwnFiles[i].has = false end\
- if(not self.dwnFiles[i].has)then stc(colors.black) else stc(colors.red) end\
- if(self.dwnFiles[i].down)then sbc(colors.lightBlue) else sbc(colors.white) end\
- scp(1,i+4)\
- write(self.dwnFiles[i].text)\
- scp(30,i+4)\
- stc(colors.lightGray)\
- sbc(colors.white)\
- write(self.dwnFiles[i].url)\
- end\
- \
- a = {os.pullEvent()}\
- \
- if( (a[1] == \"mouse_drag\" or a[1] == \"mouse_click\") and a[2] == 1)then\
- if(a[3] >= w and a[4] == 1)then \
- clk(\"X\",w,1,colors.red,0.2)\
- setState('desktop') \
- end\
- \
- --Download--\
- if(a[4] == 18)then\
- self:download()\
- end\
- \
- for i = 1, #self.dwnFiles do\
- if(a[3] >= 1 and a[3] <= #self.dwnFiles[i].text \
- and a[4] == i+4 and not self.dwnFiles[i].has)then\
- if(not self.dwnFiles[i].down)then self.dwnFiles[i].down = true \
- else self.dwnFiles[i].down = false end \
- end\
- end\
- end\
- end,\
- clear = function(self)\
- sbc(colors.white)\
- cl()\
- sbc(colors.red)\
- scp(1,1)\
- term.clearLine()\
- scp(1,1)\
- stc(colors.white)\
- write(\"Downloader\")\
- sbc(colors.orange)\
- scp(w,1)\
- write(\"X\")\
- end,\
- \
- }\
- \
- \
- -- Desktop Enviorment\
- local desktop = {\
- \
- sMenuWidth = 10,\
- inMenu = false, \
- deskLoc = \".RedOS/desktop/\",\
- deskProgs = {};\
- ficons = {},\
- icon_width = 4,\
- icon_height = 5,\
- needUpdateInstance=false,\
- \
- \
- get_desk = function(self)\
- self.deskProgs = {}\
- for k, v in pairs(fs.list(self.deskLoc)) do\
- if(fs.isDir(self.deskLoc..v))then\
- self.deskProgs[k] = {name=v,file=self.deskLoc..v..\"/\"..v,icon=self.deskLoc..v..\"/icon\"}\
- end\
- end\
- end,\
- \
- loadBack = function(self)\
- if(fs.exists(\".RedOS/graphics/background\"))then\
- paintutils.drawImage(paintutils.loadImage(\".RedOS/graphics/background\"), 2, 1)\
- end\
- end,\
- \
- draw_desk = function(self)\
- \
- self.ficons = {}\
- \
- local c_tab = 0\
- local sp_count = 0\
- local mx_tab = 2\
- local x_degree = 10\
- local y_degree = 7\
- \
- for i = 1, #self.deskProgs do\
- -- get current files icon\
- if(c_tab == 2)then sp_count = sp_count + 1 c_tab = 0 end\
- c_tab = c_tab + 1\
- self.ficons[i] = {icon = self.deskProgs[i].icon, x = 2, y = i+((i-1)*y_degree)}\
- local fileico = paintutils.loadImage(self.ficons[i].icon)\
- local calc_x = sp_count*x_degree\
- local calc_y = (c_tab-1)*y_degree\
- self.ficons[i].x = self.ficons[i].x + calc_x\
- self.ficons[i].y = calc_y + 2\
- paintutils.drawImage(fileico, self.ficons[i].x, self.ficons[i].y)\
- scp( self.ficons[i].x - 1, 1 + self.ficons[i].y + 3 )\
- sbc(colors.white)\
- stc(colors.black)\
- print(self.deskProgs[i].name)\
- \
- end\
- \
- end,\
- \
- draw_avaupdate = function(self)\
- scp(1,(h/2) - (#self.updateMenu)/2)\
- for i = 1, #self.updateMenu do\
- sbc(colors.red)\
- stc(colors.white)\
- scp(5,((h/2) - ((#self.updateMenu)/2))+i)\
- print(self.updateMenu[i].g)\
- sleep(0.01)\
- end\
- end,\
- \
- reboot = function(self)\
- sbc(colors.white)\
- cl()\
- stc(colors.black)\
- print()\
- fadeout_complete(0.2,\"Rebooting...\")\
- sleep(0.4)\
- os.reboot()\
- end,\
- shutdown = function(self)\
- sbc(colors.white)\
- cl()\
- stc(colors.black)\
- print()\
- fadeout_complete(0.2,\"Shutting Down...\")\
- sleep(0.4)\
- os.shutdown()\
- end,\
- \
- startMenu = {\
- \
- {text=\" \",run = function() end};\
- {text=\" Settings> \",run = function(self) self.inMenu = false shell.run(\"paint\", \".RedOS/graphics/background\") self:draw() end};\
- {text=\" Download> \",run = function() changeState('downloader') end};\
- {text=\" Explorer> \",run = function(self) shell.run(\".RedOS/startmenu/apps/cozyfile\") self.inMenu = false self:draw() end};\
- {text=\" Programs> \",run = function(self) changeState('programs') end};\
- {text=\" Shell \",run = function() sbc(colors.black) stc(colors.white) scp(1,1) cl() shell.run(\"shell\") end};\
- {text=\" Reboot \",run = function(self) self:reboot() end};\
- {text=\" Shutdown \",run = function(self) self:shutdown() end};\
- {text=\" Update \",run = function(self) checkUpdate() self.inMenu =false self:draw() end};\
- {text=\" \",run = function() end};\
- },\
- \
- \
- updateMenu = {\
- \
- {g=\" \"};\
- {g=\" Update Available \"};\
- {g=\" \"};\
- {g=\" \"};\
- {g=\" [Download] - [Not Now] \"};\
- \
- },\
- \
- clear = function(self)\
- fadeScr(0.08)\
- self:loadBack()\
- sbc(colors.red)\
- scp(1,19)\
- sleep(0.1)\
- write(string.rep(\" \",w))\
- stc(colors.white)\
- scp(1,19)\
- checkUpdate()\
- self.needUpdateInstance = needUpdate\
- write(\"RedOS\")\
- if(not self.needUpdateInstance)then\
- write(\" Up to Date!\")\
- else\
- write(\" Needs Update!\") \
- end\
- sbc(colors.black)\
- self:get_desk()\
- self:draw_desk()\
- end,\
- draw = function(self)\
- sbc(colors.white)\
- cl()\
- self:loadBack()\
- sbc(colors.red)\
- scp(1,19)\
- write(string.rep(\" \",w))\
- stc(colors.white)\
- scp(1,19)\
- write(\"RedOS\")\
- if(not self.needUpdateInstance)then\
- write(\" Up to Date!\") \
- else\
- write(\" Needs Update!\") \
- end\
- sbc(colors.black)\
- self:get_desk() \
- end,\
- update = function(self)\
- \
- \
- --Events--\
- self:draw_desk()\
- \
- \
- --- Check if a update is needed -- \
- if(needUpdate)then\
- self:draw_avaupdate()\
- end\
- \
- if(self.inMenu)then\
- -- Drawing Da Menu --\
- \
- for i =1, #self.startMenu do\
- sbc(colors.gray)\
- stc(colors.white)\
- scp(1,18-#self.startMenu+i)\
- write(self.startMenu[i].text)\
- end\
- \
- end\
- \
- e = {os.pullEvent()}\
- \
- if(e[1] == \"mouse_click\" and not self.inMenu)then\
- -- desktop item clicks brah --\
- for i = 1, #self.deskProgs do\
- \
- -- Click detection --\
- if(e[3] >= self.ficons[i].x and \
- e[3] <= self.icon_width+self.ficons[i].x and \
- e[4] >= self.ficons[i].y and \
- e[4] <= self.icon_height+self.ficons[i].y ) then\
- \
- -- run program -- \
- sbc(colors.black)\
- stc(colors.white)\
- term.clear()\
- if(e[2] == 1)then\
- os.run({},self.deskProgs[i].file)\
- center_complete(\"Press Any Key To Return to RedOS\")\
- center_complete(\"Program Ran: \"..self.deskProgs[i].file,1)\
- os.pullEvent(\"key\")\
- elseif(e[2] == 2)then\
- \
- shell.run(\"paint \",self.deskProgs[i].icon)\
- end\
- \
- self:draw()\
- end\
- end\
- end\
- \
- if(e[1] == \"mouse_click\" and e[2] == 1)then\
- \
- -- Start Menu Clicked --\
- -- e[2] == mouse_button e[3] == mouse_x, e[4] == mouse_y, \
- --scp(1,1)\
- --print(\"X: \"..e[3]..\"Y: \"..e[4])\
- if(needUpdate)then\
- if(e[3] >= 14 and e[3] <= 23 and e[4] == 12)then\
- -- download update --\
- sbc(colors.white)\
- cl()\
- stc(colors.black)\
- center_x(\"Downloading Update....\",2)\
- scp(1,4)\
- stc(colors.lightGray)\
- print(\"Pinging RedOS File...\")\
- local redRes = http.get(\"http://www.pastebin.com/raw.php?i=mZi6TjgU\")\
- if(redRes)then\
- local con = redRes.readAll()\
- redRes.close()\
- stc(colors.green)\
- print(\"Success!.\")\
- stc(colors.gray)\
- print(\"Replaceing File...\")\
- fs.delete(shell.getRunningProgram())\
- f = fs.open(shell.getRunningProgram(),\"w\")\
- f.write(con)\
- stc(colors.black)\
- center_x(\"Press Any Key To Reboot\",7)\
- os.pullEvent(\"key\")\
- os.reboot()\
- else\
- stc(colors.red)\
- print(\"Failed.\")\
- stc(colors.gray)\
- print(\"Please check your connection to the internet\")\
- stc(colors.black)\
- center_x(\"Press Any Key\",7)\
- os.pullEvent(\"key\")\
- self:draw()\
- end\
- end\
- \
- if(e[3] >= 29 and e[3] <= 37 and e[4] == 12)then\
- -- not now\
- needUpdate=false\
- self:draw()\
- end \
- end\
- \
- if(e[3] >= 1 and e[3] <= 5 and e[4] == 19)then\
- \
- if(not self.inMenu) then self.inMenu = true; \
- elseif(self.inMenu) then self.inMenu=false end\
- \
- sbc(colors.gray)\
- scp(1,h)\
- write(\"RedOS\")\
- sleep(0.1)\
- \
- self:draw()\
- self:update()\
- \
- end\
- \
- \
- \
- -- Menu Button Clicks --\
- for i = 1, #self.startMenu do \
- if(e[3] >= 1 and e[3] <= self.sMenuWidth and e[4] >= h-#self.startMenu and e[4] <= h and self.inMenu)then\
- if(self.inMenu and e[4] == i+((h-1) - #self.startMenu))then self.startMenu[i].run(self) end\
- elseif(self.inMenu)then self.inMenu = false self:draw() end\
- end\
- end\
- \
- end,\
- \
- }\
- \
- --- Without transition --\
- function setState(s)\
- if(s == 'desktop')then desktop:draw() state = 'desktop' end\
- if(s == 'downloader')then downloader:draw() state = 'downloader' end\
- if(s == 'programs')then programs:draw() state = 'programs' end\
- ros()\
- end\
- \
- -- With Transition --\
- function changeState(s)\
- if(s == 'desktop')then desktop:clear() state = 'desktop' end\
- if(s == 'downloader')then downloader:clear() state = 'downloader' end\
- if(s == 'programs')then programs:clear() state = 'programs' end\
- ros()\
- end\
- \
- function ros()\
- while true do\
- sleep(0.001)\
- if(state == 'desktop')then desktop:update() end\
- if(state == 'downloader')then downloader:update() end\
- if(state == 'programs')then programs:update() end\
- end\
- end\
- \
- changeState('desktop')\
- ros()",
- },
- [ "vhd/RedOS/cozy_string" ] = {
- content = "function split(inputstr, sep, index)\
- \
- i=1\
- \
- t={}\
- \
- s=\"\"\
- \
- for str in string.gmatch(inputstr, \"([^\"..sep..\"]+)\") do\
- t[i] = str \
- i = i + 1\
- end\
- \
- for k, v in pairs(t) do\
- if(k <= index)then s = s..t[k]..\"/\" end\
- end\
- \
- return s\
- end\
- \
- \
- \
- function pathLen(inputstr)\
- \
- i=1\
- t={}\
- s=\"\"\
- ki=0\
- \
- for str in string.gmatch(inputstr, \"([^/]+)\") do\
- t[i] = str \
- i = i + 1\
- end\
- \
- for k, v in pairs(t) do\
- ki=k\
- end\
- \
- return ki\
- end",
- },
- }
- -- ]] wit auto extractor [[ --
- function install(from)
- for k, v in pairs(fs.list(from)) do
- if(fs.isDir(from.."/"..v))then
- install(from..v.."/")
- else
- print("Installing: "..from..v)
- sleep(0.3)
- f = fs.open(from..v,"r")
- content = f.readAll()
- f.close()
- f = fs.open(v,"w")
- f.write(content)
- f.close()
- end
- end
- end
- print("Extracting RedOS...")
- local _system = {}
- local
- -- ]] make all files in _system [[ --
- function loadFiles()
- for k, v in pairs(_system) do
- f = fs.open(k,"w")
- f.write(v.content)
- f.close()
- print(k)
- end
- print("RedOS Extracted!")
- print("Installing...")
- install("vhd/RedOS/")
- fs.delete("vhd")
- print("Completed!")
- end
- -- ]] load harddisk [[ --
- _system = redos_files
- fs.makeDir(".RedOS/desktop/")
- loadFiles()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement