Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------РЎРўРђР РгўРћР’ЫЕ ПРЕЛЕССССТР?-------------------------
- local XSize, YSize = term.getSize()
- local Selector = 1
- local zaderzhka = 0.1
- local progressBarWidth = 20
- local ColorGray = colors.gray
- local ColorLightGray = colors.blue
- local ColorDownloadBack = colors.blue
- local ColorDownloadFront = colors.yellow
- -----------СМЕНА ЦВЕТОВОЙ РџРђР›Р?РўР Р«, ЕСЛР? РњРћРќР?ТОРЧЕРНО-БЕЛЫЙ---------
- if not term.isColor() then
- ColorGray = colors.blue
- ColorLightGray = colors.yellow
- ColorDownloadBack = colors.green
- ColorDownloadFront = colors.black
- end
- -----------ЗАГРУЗКА ВСЯКОЙ ФИГНИ--------
- local Data = {
- --пнгшки
- {["paste"]="KywaaXS4",["path"]="OS/.backgrounds/dt",["type"]="PNG",["category"]="pngs"},
- --важные системные файлы
- {["paste"]="729PYwzX",["path"]="/gui",["type"]="prog",["category"]="sysfiles"},
- }
- ----------------------ОБЪЯВЛЕНР?Р• ФУНКЦР?Р™-----------------------
- --ЗАГРУЗКА ФАЙЛОВ РЎ ПАСТЕБР?РќРђ
- local function pastebin(paste,path)
- local file = http.get("http://pastebin.com/raw.php?i="..paste)
- if file then
- file = file.readAll()
- h=fs.open(path,"w")
- h.write(file)
- h.close()
- else
- error("Pastebin server is not aviable.")
- end
- end
- --ЗАГРУЗР?РўР¬ КОНКРЕТНОЕ РџР Р?ЛОЖЕНР?Р•
- local function downloadApp(pasteApp,pasteIcon,path)
- fs.delete(path..".app")
- pastebin(pasteApp,path..".app/main")
- pastebin(pasteIcon,path..".app/Resources/icon.png")
- end
- --РџР РћРЎРўРђРЇ Р—РђР›Р?Р’РљРђ РРљР РђРќРђ ЦВЕТОМ
- local function clearScreen(color)
- term.setBackgroundColor(color)
- term.clear()
- end
- --ПЛАВНОЕ ВКЛЮЧЕНР?Р• РРљР РђРќРђ
- local function fadeIn(time)
- clearScreen(ColorGray)
- sleep(time)
- clearScreen(ColorLightGray)
- sleep(time)
- clearScreen(colors.white)
- sleep(time)
- end
- --ПЛАВНОЕ Р—РђРўРЈРҐРђРќР?Р• РРљР РђРќРђ
- local function fadeOut(time)
- clearScreen(ColorLightGray)
- sleep(time)
- clearScreen(ColorGray)
- sleep(time)
- clearScreen(colors.black)
- sleep(time)
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- end
- --РЈРќР?ВЕРСАЛЬНАЯ ФУНКЦР?РЇ ДЛЯ ОТОБРАЖЕНР?РЇ ТЕКСТА РџРћ ЦЕНТРУ РРљР РђРќРђ
- local function centerText(how,coord,text,textColor,backColor)
- term.setTextColor(textColor)
- term.setBackgroundColor(backColor)
- if how == "xy" then
- term.setCursorPos(math.floor(XSize/2-#text/2),math.floor(YSize/2))
- elseif how == "x" then
- term.setCursorPos(math.floor(XSize/2-#text/2),coord)
- elseif how == "y" then
- term.setCursorPos(coord,math.floor(YSize/2))
- end
- term.write(text)
- end
- --РќРђР Р?РЎРћР’РђРўР¬ ГОРЗОНТАЛЬНУЮ Р›Р?РќР?Р® РЈРљРђР—РђРќРќРћР™ ДЛР?РќР« Р? ЦВЕТА
- local function horisontalBar(x,y,width,color)
- for i=x,(x+width-1) do
- paintutils.drawPixel(i,y,color)
- end
- end
- --ОТОБРАЖЕНР?Р• ШКАЛЫ ЗАГРУЗКР? РЎ ПРОГРЕССОМ Р’ ПРОЦЕНТАХ
- local function progressBar(size,action,percent)
- local doneSize = math.ceil(percent/100*size)
- local startingY = math.floor(YSize/2-1)
- local startingX = math.floor(XSize/2-size/2)
- horisontalBar(1,startingY,XSize,colors.white)
- centerText("x",startingY,"Installing "..action,ColorGray,colors.white)
- horisontalBar(startingX,startingY+2,size,ColorDownloadBack)
- horisontalBar(startingX,startingY+2,doneSize,ColorDownloadFront)
- sleep(zaderzhka)
- end
- --ЗАГРУЗР?РўР¬ Р’РЎР• ФАЙЛЫ РЎ ПАСТЕБР?РќРђ
- local function downloadAll()
- clearScreen(colors.white)
- progressBar(progressBarWidth,"started",0)
- fs.makeDir("Applications")
- fs.makeDir("OS")
- --fs.makeDir("Documents")
- local oneFileIsHowMuchPercent = 1/#Data*100
- for i=1,#Data do
- if Data[i]["type"] == "Application" then
- downloadApp(Data[i]["paste"],Data[i]["icon"],Data[i]["path"])
- else
- pastebin(Data[i]["paste"],Data[i]["path"])
- end
- progressBar(progressBarWidth,Data[i]["category"],i*oneFileIsHowMuchPercent)
- end
- clearScreen(colors.white)
- centerText("x",math.floor(YSize/2),"Setup done.Press enter and print gui",ColorLightGray,colors.white)
- os.pullEvent("key")
- end
- --ЗАГРУЗР?РўР¬ Р’РЎР• РђРџР?
- local function downloadAPIs()
- for i=1,#Data do
- if Data[i]["type"] == "API" then
- pastebin(Data[i]["paste"],Data[i]["path"])
- end
- end
- end
- --УДАЛР?РўР¬ Р’РЎР• РњРћР? ФАЙЛЫ
- local function deleteOld()
- fs.delete("Applications")
- fs.delete("Documents")
- fs.delete("Images")
- fs.delete("System")
- fs.delete("OS")
- fs.delete("MineCode")
- fs.delete("startup")
- fs.delete("Startup")
- end
- --УДАЛР?РўР¬ ВООБЩЕ Р’РЎР• ФАЙЛЫ
- local function deleteAll()
- local fileList = fs.list("")
- for i=1,#fileList do
- if not fs.isReadOnly(fileList[i]) then
- fs.delete(fileList[i])
- end
- end
- end
- --РќРђР Р?РЎРћР’РђРўР¬ СЕЛЕКТОРДЛЯ ВЫБОРА РџР Р? РЎРўРђР РўР• ПРОГРАММЫ
- local function drawSelection(y,text,id)
- if id == Selector then
- horisontalBar(math.floor(XSize/2-8),y,16,ColorLightGray)
- centerText("x",y,text,colors.white,ColorLightGray)
- else
- horisontalBar(math.floor(XSize/2-8),y,16,colors.white)
- centerText("x",y,text,ColorLightGray,colors.white)
- end
- end
- --ОТОБРАЖЕНР?Р• СТАРТОВОГО Р?НТЕРФЕЙСА
- local function gui()
- local startingY = math.floor(YSize/2-2)
- centerText("x",startingY,"Welcome to Fast OS installer! (C) Robar",ColorGray,colors.blue)
- drawSelection(startingY+2,"Install",1)
- drawSelection(startingY+3,"Delet all files!",2)
- drawSelection(startingY+5,"Exit",4)
- end
- -----------------------СТАРТ ПРОГРАММЫ-----------------------
- fadeIn(0)
- gui()
- while true do
- --ОТСЛЕЖР?Р’РђРќР?Р• КЛАВР?РЁ СТРЕЛОК Р? ENTER
- local event, scancode = os.pullEvent("key")
- --ПЕРЕМЕСТР?ТЬСЯ ВЫШЕ
- if scancode == 200 then
- Selector = Selector-1
- if Selector<1 then Selector=1 end
- gui()
- --ПЕРЕМЕСТР?ТЬСЯ РќР?Р–Р•
- elseif scancode == 208 then
- Selector = Selector+1
- if Selector>4 then Selector=4 end
- gui()
- --СКАЧАТЬ Р’РЎР• РЎ ПАСТЕБР?РќРђ
- elseif scancode == 28 and Selector == 1 then
- --deleteOld()
- downloadAll()
- break
- --РћР§Р?РЎРўР?РўР¬ РљРћРњРџ РћРў МОЕГО ГОВНА
- elseif scancode == 28 and Selector == 2 then
- deleteAll()
- clearScreen(colors.white)
- centerText("x",math.floor(YSize/2),"disk has formated.",ColorLightGray,colors.white)
- local event, scancode = os.pullEvent("key")
- fadeOut(0)
- os.reboot()
- break
- --СКАЧАТЬ ТОЛЬКО РђРџР? РЎ ПАСТЕБР?РќРђ
- elseif scancode == 28 and Selector == 3 then
- fs.delete("System/API")
- clearScreen(colors.white)
- centerText("x",math.floor(YSize/2),"Downloading programs",ColorLightGray,colors.white)
- --[[for i=1,11 do
- pastebin(Data[i]["paste"],Data[i]["path"])
- end]]
- downloadAPIs()
- clearScreen(colors.white)
- centerText("x",math.floor(YSize/2),"Programs installed",ColorLightGray,colors.white)
- local event, scancode = os.pullEvent("key")
- break
- --ВЫЙТР? Р?Р— ПРОГРАММЫ
- elseif scancode == 28 and Selector == 4 then
- break
- end
- end
- fadeOut(0)
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement