Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- {
- text = "os.loadAPI(\"System/API/windows\")\
- \
- --ПАРОЛЬ\
- local password = \"12345\"\
- \
- --СКОЛЬКО БУДЕТ ОТКРЫТА ДВЕРЬ\
- local doorOpenTime = 5\
- \
- --СКОЛЬКО БУДЕТ НАЖАТА КНОПКА\
- local buttonPressTime = 0.2\
- \
- --ПЕРЕМЕННАЯ ТАЙМЕРА\
- local changePasswordTimer = nil\
- \
- --РЕЖпМ РАБОТЫ ДпСПЛЕЯ\
- local mode = \"default\"\
- \
- --СКРЫВАТЬ Лп ВВОДпМЫЙ ПАРОЛЬ\
- local hidePassword = \"false\"\
- \
- --ОТСЮДА пЗЛУЧАТЬ СпГНАЛ РЕДА, ЕСЛп ПАРОЛЬ ВЕРЕН\
- local redstoneSide = \"left\"\
- --А ОТСЮДА, ЕСЛп НЕ ВЕРЕН\
- local redstoneSideOnWrongPassword = \"right\"\
- \
- --КНОПОЧКп\
- local buttons = {\
- {\"1\",\"2\",\"3\"},\
- {\"4\",\"5\",\"6\"},\
- {\"7\",\"8\",\"9\"},\
- {\"C\",\"0\",\"#\"},\
- }\
- \
- --МАССпВ ОБЪЕКТОВ\
- local Obj = {}\
- \
- --МАССпВ СпМВОЛОВ, ВВЕДЕННЫХ С ПОМОЩЬЮ КНОПОК\
- local inputCode = {}\
- \
- --ПОЛУЧЕНпЕ РАЗМЕРА МОНпТОРА\
- local xSize, ySize = term.getSize()\
- \
- --ПОпСК ПЕРпФЕРпп\
- local function findPeripheral(whatToFind)\
- local PeriList = peripheral.getNames()\
- for i=1,#PeriList do\
- if peripheral.getType(PeriList[i]) == whatToFind then\
- return PeriList[i]\
- end\
- end\
- 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\
- \
- --ЧТЕНпЕ КОНФпГА\
- function configRead(pathToConfig,whatToRead)\
- if not fs.exists(pathToConfig) then error(\"No such file\") end\
- local file = fs.open(pathToConfig,\"r\")\
- while true do\
- local line = file.readLine()\
- if line ~= nil then \
- local key, value = string.match(line,\"(.*)=(.*)\")\
- if value ~= nil and key == whatToRead then\
- file.close()\
- return value\
- end\
- else\
- file.close()\
- break\
- end\
- end\
- end\
- \
- --ЗАПпСЬ В КОНФпГ\
- local function configWrite(pathToConfig,key,value)\
- if not fs.exists(pathToConfig) then\
- local file = fs.open(pathToConfig,\"w\")\
- file.close()\
- end\
- \
- local file = fs.open(pathToConfig,\"r\")\
- local Massiv = {}\
- \
- local lineCounter = 1\
- while true do\
- local line = file.readLine()\
- if line ~= nil then \
- Massiv[lineCounter] = line\
- else\
- file.close()\
- break\
- end\
- lineCounter = lineCounter + 1\
- end\
- \
- local success = false\
- for i=1,#Massiv do\
- local key1, value1 = string.match(Massiv[i],\"(.*)=(.*)\")\
- if value1 ~= nil and key1 == key then\
- Massiv[i] = key..\"=\"..value\
- success = true\
- end\
- end\
- \
- if success == false then Massiv[#Massiv+1] = key..\"=\"..value end\
- \
- local file = fs.open(pathToConfig,\"w\")\
- for i=1,#Massiv do\
- file.writeLine(Massiv[i])\
- end\
- file.close()\
- end\
- \
- --ОБЪЕКТЫ\
- local function newObj(name,x,y)\
- Obj[name]={}\
- Obj[name][\"x\"]=x\
- Obj[name][\"y\"]=y\
- end\
- \
- --ПРОСТАЯ ЗАЛпВКА ЭКРАНА ЦВЕТОМ\
- local function clearScreen(color)\
- term.setBackgroundColor(color)\
- term.clear()\
- end\
- \
- --ПРОСТОЙ ТЕКСТ\
- local function usualText(x,y,text)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- --ОТРпСОВКА ВЕРХНЕЙ ШТУЧКп\
- local function drawTab(textColor,backColor)\
- term.setBackgroundColor(backColor)\
- term.setTextColor(textColor)\
- term.setCursorPos(2,1)\
- term.clearLine()\
- term.write(\"-----\")\
- \
- for i=1,#inputCode do\
- if hidePassword == \"true\" then\
- usualText(i+1,1,\"*\")\
- else\
- usualText(i+1,1,inputCode[i])\
- end\
- end\
- end\
- \
- --ОТРпСОВКА КОНКРЕТНОЙ КНОПКп\
- local function drawButton(name,textColor,backColor)\
- term.setBackgroundColor(backColor)\
- term.setTextColor(textColor)\
- usualText(Obj[name][\"x\"],Obj[name][\"y\"],name)\
- end\
- \
- \
- --ОТРпСОВКА ВСЕГО пНТЕРФЕЙСА\
- local function gui()\
- --ОЧпСТКА ЭКРАНА\
- term.setCursorBlink(false)\
- clearScreen(colors.white)\
- term.setTextColor(colors.black)\
- \
- --ОТРпСОВКА КНОПОЧЕК\
- for j=1,#buttons do\
- for i=1,#buttons[j] do\
- local xPos = i*2\
- local yPos = 1+j\
- usualText(xPos,yPos,buttons[j][i])\
- newObj(buttons[j][i],xPos,yPos)\
- end\
- end\
- \
- --ОТРпСОВКА ВЕРХНЕЙ ШНЯГп\
- drawTab(colors.white,colors.black)\
- end\
- \
- ------------------------------CТАРТ ПРОГРАММЫ------------------------------------\
- \
- if not term.isColor() then\
- error(\"This program requires an advanced computer.\")\
- end\
- \
- --РпСУЕМ В КОМПЕ ХУЙНЮ\
- clearScreen(colors.white)\
- centerText(\"xy\",0,\"Program started.\",colors.lightGray,colors.white)\
- \
- --ПОДКЛЮЧЕНпЕ МОНпТОРА\
- local m = findPeripheral(\"monitor\")\
- if m ~= nil then\
- m = peripheral.wrap(m)\
- if not m.isColor() then\
- windows.error(\"This program works only with advanced monitor.\")\
- do return end\
- end\
- m.setTextScale(1)\
- term.redirect(m)\
- else\
- windows.error(\"This program requires advanced external monitor.\")\
- do return end\
- end\
- \
- --ЧТЕНпЕ КОНФпГА\
- if fs.exists(\"System/CodeDoor.cfg\") then\
- password = configRead(\"System/CodeDoor.cfg\",\"password\")\
- redstoneSide = configRead(\"System/CodeDoor.cfg\",\"redstone side\")\
- redstoneSideOnWrongPassword = configRead(\"System/CodeDoor.cfg\",\"redstone side on wrong password\")\
- doorOpenTime = configRead(\"System/CodeDoor.cfg\",\"door open time\")\
- hidePassword = configRead(\"System/CodeDoor.cfg\",\"hide password\")\
- else\
- configWrite(\"System/CodeDoor.cfg\",\"password\",password)\
- configWrite(\"System/CodeDoor.cfg\",\"redstone side\",redstoneSide)\
- configWrite(\"System/CodeDoor.cfg\",\"redstone side on wrong password\",redstoneSideOnWrongPassword)\
- configWrite(\"System/CodeDoor.cfg\",\"door open time\",doorOpenTime)\
- configWrite(\"System/CodeDoor.cfg\",\"hide password\",hidePassword)\
- end\
- \
- --РпСУЕМ ВСЕ\
- gui()\
- \
- --АНАЛпЗ КАСАНпЙ ЭКРАНА\
- while true do\
- --ЗАКРЫВАЕМ ДВЕРЬ НА ВСЯКпЙ ПОЖАРНЫЙ\
- rs.setOutput(redstoneSide,false)\
- rs.setOutput(redstoneSideOnWrongPassword,false)\
- \
- local event,side,x,y = os.pullEvent()\
- if event == \"monitor_touch\" then\
- --ПЕРЕБОР ВСЕХ ЭЛЕМЕНТОВ МАССпВА ОБЪЕКТОВ\
- for key,val in pairs(Obj) do\
- --ПРОВЕРКА СОВПАДЕНпЯ КООРДпНАТ КАСАНпЯ п КООРДпНАТ ОБЪЕКТОВ\
- if x==Obj[key][\"x\"] and y==Obj[key][\"y\"] then\
- --РпСУЕМ НАЖАТУЮ КНОПОЧКУ\
- drawButton(key,colors.white,colors.green)\
- sleep(buttonPressTime)\
- drawButton(key,colors.black,colors.white)\
- \
- --ПРОВЕРКА, ЧТО ЗА КЛАВпША НАЖАТА - ЦпФРА пЛп СпСТЕМНАЯ КЛАВпША\
- if key == \"C\" then\
- inputCode = {}\
- if mode == \"edit\" then\
- drawTab(colors.white,colors.orange)\
- else\
- drawTab(colors.white,colors.black)\
- end\
- \
- elseif key == \"#\" then\
- --СОВМЕЩЕНпЕ ВСЕХ ЭЛЕМЕНТОВ МАССпВА ВВОДА В ОДНУ СТРОКУ\
- local inputPass = \"\"\
- for i=1,#inputCode do\
- inputPass = inputPass..inputCode[i]\
- end\
- \
- --ПРОВЕРКА РЕЖпМА\
- if mode == \"edit\" then\
- --СМЕНА ПАРОЛЯ\
- password = inputPass\
- configWrite(\"System/CodeDoor.cfg\",\"password\",password)\
- inputCode = {}\
- term.setCursorPos(3,1)\
- term.setBackgroundColor(colors.orange)\
- term.clearLine()\
- term.setTextColor(colors.white)\
- term.write(\"Ok!\")\
- \
- sleep(2)\
- \
- drawTab(colors.white,colors.black)\
- mode = \"default\"\
- else\
- --СРАВНЕНпЕ ВВЕДЕННОГО ГОВНА С ПЕРЕМЕННОЙ ПАРОЛЯ\
- if inputPass == password then\
- drawTab(colors.white,colors.green)\
- rs.setOutput(redstoneSide,true)\
- rs.setOutput(redstoneSideOnWrongPassword,false)\
- \
- --СТАРТУЕМ ТАЙМЕР НА УКАЗАННОЕ ВРЕМЯ\
- changePasswordTimer = os.startTimer(tonumber(doorOpenTime))\
- while true do\
- local event2,side2,x2,y2 = os.pullEvent()\
- --ЕСЛп НпЧЕГО НЕ НАЖАТО, ТО ВЫХОД пЗ ЦпКЛА\
- if event2 == \"timer\" then\
- if side2 == changePasswordTimer then\
- break\
- end\
- --ЕСЛп НАЖАТА КЛАВпША \"С\", ТО ЗАПУСТпТЬ РЕЖпМ СМЕНЫ ПАРОЛЯ\
- elseif event2 == \"monitor_touch\" then\
- if x2==Obj[\"C\"][\"x\"] and y2==Obj[\"C\"][\"y\"] then\
- drawButton(\"C\",colors.white,colors.green)\
- sleep(buttonPressTime)\
- drawButton(\"C\",colors.black,colors.white)\
- mode = \"edit\"\
- os.queueEvent(\"timer\",changePasswordTimer)\
- end\
- end \
- end\
- \
- --ОЧпЩАЕМ ВВЕДЕННЫЙ ТЕКСТ п ЗАКРЫВАЕМ ДВЕРЬ\
- inputCode = {}\
- rs.setOutput(redstoneSide,false)\
- \
- --РпСУЕМ ВЕРХНЮЮ ШНЯГУ РАЗНОГО ЦВЕТА В ЗАВпСпМОСТп ОТ РЕЖпМА\
- if mode == \"edit\" then\
- drawTab(colors.white,colors.orange)\
- else\
- drawTab(colors.white,colors.black)\
- end\
- --ЕСЛп ВВЕДЕН НЕВЕРНЫЙ ПАРОЛЬ\
- else\
- drawTab(colors.white,colors.red)\
- rs.setOutput(redstoneSide,false)\
- rs.setOutput(redstoneSideOnWrongPassword,true)\
- sleep(3)\
- rs.setOutput(redstoneSideOnWrongPassword,false)\
- inputCode = {}\
- drawTab(colors.white,colors.black)\
- end\
- end\
- --ЕСЛп НАЖАТА ЛЮБАЯ ЦпФРА\
- else\
- if #inputCode < 5 then\
- inputCode[#inputCode+1] = key\
- if mode == \"edit\" then\
- drawTab(colors.white,colors.orange)\
- else\
- drawTab(colors.white,colors.black)\
- end\
- end\
- end\
- --ВЫХОД пЗ ЦпКЛА ПЕРЕБОРА ОБЪЕКТОВ\
- break\
- end\
- end\
- \
- --ЕСЛп НАЖАТА КЛАВпША ENTER\
- elseif event == \"key\" and side == 28 then\
- break\
- end\
- end\
- \
- clearScreen(colors.black)\
- term.setTextColor(colors.white)\
- \
- term.redirect(term.native())\
- \
- clearScreen(colors.black)\
- term.setTextColor(colors.white)\
- term.setCursorPos(1,1)",
- path = "/rootfs/Apps/CodeDoor.app/main",
- },
- {
- text = " ff-0f-0f-0f ff###\
- f01f02f03f0 f0###\
- f04f05f06f0 f0###\
- f07f08f09f0 f0###",
- path = "/rootfs/Apps/CodeDoor.app/Resources/icon.png",
- },
- {
- text = "os.loadAPI(\"System/API/image\")\
- os.loadAPI(\"System/API/filemanager\")\
- os.loadAPI(\"System/API/windows\")\
- local filem = filemanager.open\
- filemanager.open(\"/\")\
- if windows.getFileFormat(filem) == nil then\
- loadfile(file) \
- elseif windows.getFileFormat(filem) == \".app\" then\
- path = path..\"/main\"\
- loadfile(path)\
- else\
- windows.attention({\"Can't open file\"},{\"This file format\",\"is not supported.\"})\
- filemanager.open(\"/\")\
- end",
- path = "/rootfs/Apps/FileManager.app/main",
- },
- {
- text = " 84 84############\
- -84-84-84-84-84-84\
- -84-84-84-84-84-84\
- -84-84-84-84-84-84",
- path = "/rootfs/Apps/FileManager.app/Resources/icon.png",
- },
- {
- text = "-----------------------ВСЯКпЕ ПОЛЕЗНОСТп----------------------\
- if not term.isColor() then error(\"This program will work only on advanced computer.\") end\
- local Args = {...}\
- os.loadAPI(\"System/API/context\")\
- os.loadAPI(\"System/API/image\")\
- os.loadAPI(\"System/API/filemanager\")\
- os.loadAPI(\"System/API/windows\")\
- \
- ----------------------ОБЪЯВЛЕНпЕ ПЕРЕМЕННЫХ----------------------\
- local xSize, ySize = term.getSize()\
- \
- --СУПЕР-ОПпЗДОХУЕННЫЙ АЛГОРпТМ СОЗДАНпЯ ОКОН - САМ УЖЕ СМУТНО ПОНпМАЮ, КАК ОНО РАБОТАЕТ, НО РАБОТАЕТ НОРМ\
- --СОЗДАНпЕ ОКНА ОТ ТЕКУЩЕГО ТЕРМпНАЛА ЧпСТО ДЛЯ СОЗДАНпЯ ПЕРЕМЕННОЙ DEFAULTTERM\
- local windowForDrawing = window.create(term.current(), 3, 2, xSize-12, ySize-1,true)\
- local defaultTerm = term.redirect(windowForDrawing)\
- --ВОССТАНОВЛЕНпЕ СТАНДАРТНОГО СОСТОЯНпЯ TERM\
- term.redirect(term.native())\
- --СОЗДАНпЕ ОКНА ДЛЯ РАБОТЫ С РпСУНКОМ, ФпНАЛ\
- windowForDrawing = window.create(term.native(), 3, 2, xSize-12, ySize-1,true)\
- \
- --МАССпВЫ ОБЪЕКТОВ\
- local Obj = {}\
- local ObjColor = {}\
- \
- --ВСЯКАЯ ХУЙНЯ С ПАРАМЕТРАМп СОЗДАВАЕМОГО пЗОБРАЖЕНпЯ\
- local imageSizeX = 36\
- local imageSizeY = 15\
- local transparentSymbol = \"+\"\
- local displayImageFromX = 4\
- local displayImageFromY = 3\
- local displayImageEndX = displayImageFromX + imageSizeX - 1\
- local displayImageEndY = displayImageFromY + imageSizeY - 1\
- \
- --МАСпВ СОКРАЩЕННЫХ В ОДпН СпМВОЛ ЦВЕТОВ ДЛЯ СОХРАНЕНпЯ пЗОБРАЖЕНпЯ В ФАЙЛ\
- local Colors = {\
- [\"0\"] = 1,\
- [\"1\"] = 2,\
- [\"2\"] = 4,\
- [\"3\"] = 8,\
- [\"4\"] = 16,\
- [\"5\"] = 32,\
- [\"6\"] = 64,\
- [\"7\"] = 128,\
- [\"8\"] = 256,\
- [\"9\"] = 512,\
- [\"a\"] = 1024,\
- [\"b\"] = 2048,\
- [\"c\"] = 4096,\
- [\"d\"] = 8192,\
- [\"e\"] = 16384,\
- [\"f\"] = 32768\
- }\
- \
- --МАССпВ СООТВЕТСТВпЯ ЦВЕТА НА ЭКРАНЕ БЛОКУ В МпРЕ МАЙНА\
- local Blocks = {\
- [1] = {[\"id\"]=\"quartz_block\",[\"data\"]=\"0\"},\
- [2] = {[\"id\"]=\"wool\",[\"data\"]=\"1\"},\
- [4] = {[\"id\"]=\"wool\",[\"data\"]=\"2\"},\
- [8] = {[\"id\"]=\"wool\",[\"data\"]=\"3\"},\
- [16] = {[\"id\"]=\"gold_block\",[\"data\"]=\"0\"},\
- [32] = {[\"id\"]=\"emerald_block\",[\"data\"]=\"0\"},\
- [64] = {[\"id\"]=\"wool\",[\"data\"]=\"6\"},\
- [128] = {[\"id\"]=\"wool\",[\"data\"]=\"7\"},\
- [256] = {[\"id\"]=\"wool\",[\"data\"]=\"8\"},\
- [512] = {[\"id\"]=\"wool\",[\"data\"]=\"9\"},\
- [1024] = {[\"id\"]=\"wool\",[\"data\"]=\"10\"},\
- [2048] = {[\"id\"]=\"wool\",[\"data\"]=\"11\"},\
- [4096] = {[\"id\"]=\"wool\",[\"data\"]=\"12\"},\
- [8192] = {[\"id\"]=\"wool\",[\"data\"]=\"13\"},\
- [16384] = {[\"id\"]=\"wool\",[\"data\"]=\"14\"},\
- [32768] = {[\"id\"]=\"wool\",[\"data\"]=\"15\"}\
- }\
- \
- --МАССпВ ПпКСЕЛЕЙ НА ЭКРАНЕ\
- local Pixels = {}\
- \
- --ВСЯКАЯ ХУЙНЯ, КАСАЮЩАЯСЯ пНСТРУМЕНТОВ, ЦВЕТОВ п ПРОЧЕГО\
- local currentInstrument = \"B\"\
- local currentTextColor = colors.white\
- local currentBackColor = colors.black\
- local currentSymbol = \" \"\
- \
- --ВСЯКАЯ ХУЙНЯ ПРО КОМАНДНЫЕ БЛОКп\
- local CommandBlockIsActive = false\
- local commandBlockAttachedAt = \"\"\
- local CommandBlock = {}\
- \
- --ГОВНЕЦО ДЛЯ ФАСТ СЕЙВА ФАЙЛпКОВ\
- local fastFileMode = false\
- local fastFilePath = nil\
- \
- local pathForFastSaving = nil\
- \
- ------------------------ОБЪЯВЛЕНпЕ ФУНКЦпЙ-----------------------\
- \
- --ПОпСК ПЕРпФЕРпп В ВпДЕ КОМАНДНОГО БЛОКА. ЕСЛп НЕ НАХОДпТ, ТО NIL\
- function findCommandBlock()\
- local PeriList = peripheral.getNames()\
- for i=1,#PeriList do\
- if peripheral.getType(PeriList[i]) == \"command\" then\
- return PeriList[i]\
- end\
- end\
- end\
- \
- --УСТАНОВКА п ЗАПУСК КОМАНДЫ В КОМАНДНЫЙ БЛОК\
- local function cb(command)\
- CommandBlock.setCommand(command)\
- CommandBlock.runCommand()\
- end\
- \
- --УСТАНОВКА БЛОКА В МпРЕ МАЙНА ПО КООРДпНАТАМ\
- local function setBlock(x,y,id,data)\
- cb(\"/setblock ~\"..(x-math.floor(imageSizeX/2))..\" ~\"..(ySize+3-y)..\" ~0 minecraft:\"..id..\" \"..data)\
- end\
- \
- --ОЧпСТКА ВСЕХ НАРпСОВАННЫХ БЛОКОВ В МпРЕ МАЙНА\
- local function clearAll()\
- for x=1,xSize do\
- for y=1,ySize do\
- setBlock(x,y,\"air\",\"0\")\
- end\
- end\
- end\
- \
- local function changeDisplayImageFromParameters(x,y)\
- displayImageFromX = x\
- displayImageFromY = y\
- displayImageEndX = displayImageFromX + imageSizeX - 1\
- displayImageEndY = displayImageFromY + imageSizeY - 1\
- end\
- \
- --СОЗДАНпЕ ОБЪЕКТОВ КНОПОК\
- local function newObj(name,x1,y1,width,height)\
- Obj[name]={}\
- Obj[name][\"x1\"]=x1\
- Obj[name][\"y1\"]=y1\
- Obj[name][\"x2\"]=x1+width-1\
- Obj[name][\"y2\"]=y1+height-1\
- end\
- \
- --СОЗДАНпЕ ОБЪЕКТА ЦВЕТОВ\
- local function newObjColor(name,x1,y1,width)\
- ObjColor[name]={}\
- ObjColor[name][\"x1\"]=x1\
- ObjColor[name][\"y1\"]=y1\
- ObjColor[name][\"x2\"]=x1+width-1\
- end\
- \
- --ПРОСТОЕ ОТОБРАЖЕНпЕ ТЕКСТА ПО КООРДпНАТАМ\
- local function usualText(x,y,text)\
- term.setCursorPos(x,y)\
- term.write(text)\
- 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 square(x1,y1,width,height,color)\
- local string = string.rep(\" \",width)\
- term.setBackgroundColor(color)\
- for y=y1,(y1+height-1) do\
- usualText(x1,y,string)\
- end\
- end\
- \
- --ЗАЛпВКА ЭКРАНА ЦВЕТОМ\
- local function clearScreen(color)\
- term.setBackgroundColor(color)\
- term.clear()\
- end\
- \
- --ПЛАВНОЕ ВКЛЮЧЕНпЕ ЭКРАНА\
- local function fadeIn(time)\
- clearScreen(colors.gray)\
- sleep(time)\
- clearScreen(colors.lightGray)\
- sleep(time)\
- clearScreen(colors.white)\
- sleep(time)\
- end\
- \
- --ПЛАВНОЕ ЗАТУХАНпЕ ЭКРАНА\
- local function fadeOut(time)\
- clearScreen(colors.lightGray)\
- sleep(time)\
- clearScreen(colors.gray)\
- sleep(time)\
- clearScreen(colors.black)\
- sleep(time)\
- term.setCursorPos(1,1)\
- term.setTextColor(colors.white)\
- end\
- \
- --ОТРпСОВКА ВЕРХНЕГО ТУЛБАРА\
- local function topBar()\
- local function topBarButton(x,y,text)\
- usualText(x,y,text)\
- newObj(text,x,y,#text,1)\
- end\
- \
- for i=1,xSize do\
- paintutils.drawPixel(i,1,colors.gray)\
- end\
- \
- term.setTextColor(colors.lightGray)\
- topBarButton(1,1,\"File\")\
- topBarButton(Obj[\"File\"][\"x2\"]+3,1,\"Edit\")\
- topBarButton(Obj[\"Edit\"][\"x2\"]+3,1,\"Quit\")\
- end\
- \
- --ОТРпСОВКА ВЫБРАННОГО ЦВЕТА п СпМВОЛА НА ЛЕВОМ ТУЛБАРЕ\
- local function leftBarColorBar()\
- square(1,ySize-2,2,2,currentTextColor)\
- paintutils.drawPixel(1,ySize-2,currentBackColor)\
- term.setTextColor(currentTextColor)\
- term.setCursorPos(1,ySize-2)\
- term.write(currentSymbol)\
- end\
- \
- --ОТРпСОВКА КНОПОК НА ЛЕВОМ ТУЛБАРЕ\
- local function leftBarButton(x,y,symbol)\
- if currentInstrument == symbol then\
- term.setTextColor(colors.white)\
- square(x,y,2,2,colors.blue)\
- else\
- term.setTextColor(colors.gray)\
- square(x,y,2,2,colors.black)\
- end\
- usualText(x,y+1,symbol)\
- newObj(symbol,x,y,2,2)\
- end\
- \
- --ОТРпСОВКА КАСТОМНЫХ КНОПОК НА ЛЕВОМ ТУЛБАРЕ\
- local function leftBarButtonPersonal(x,y,symbol,colorOfButton,colorOfText)\
- term.setTextColor(colorOfText)\
- square(x,y,2,2,colorOfButton)\
- usualText(x,y+1,symbol)\
- newObj(symbol,x,y,2,2)\
- end\
- \
- --ОТРпСОВКА ЛЕВОГО ТУЛБАРА\
- local function leftBar(activeInstrument)\
- square(1,2,2,ySize-1,colors.gray)\
- leftBarButton(1,2,\"M\")\
- leftBarButton(1,5,\"B\")\
- leftBarButton(1,8,\"E\")\
- leftBarButton(1,11,\"F\")\
- if CommandBlockIsActive then\
- leftBarButtonPersonal(1,14,\"CB\",colors.green,colors.white)\
- else\
- leftBarButtonPersonal(1,14,\"CB\",colors.black,colors.gray)\
- end\
- leftBarColorBar()\
- end\
- \
- --ОТРпСОВКА ПРАВОГО ТУЛБАРА\
- local function rightBar()\
- --НАРпСОВАТЬ КВАДРАТпК С УКАЗАННЫМ ЦВЕТОМ (ДЛЯ ПАЛпТРЫ)\
- local function drawColor(x,y,color)\
- for i=x,(x+1) do\
- paintutils.drawPixel(i,y,color)\
- newObjColor(color,x,y,2)\
- end\
- end\
- \
- square(xSize-9,2,10,ySize-1,colors.gray)\
- \
- for i=(xSize-9),xSize do\
- paintutils.drawPixel(i,2,colors.black)\
- end\
- term.setTextColor(colors.lightGray)\
- usualText(xSize-8,2,\"Colors\")\
- \
- --for i=(xSize-9),xSize do\
- -- paintutils.drawPixel(i,9,colors.black)\
- --end\
- --term.setTextColor(colors.lightGray)\
- --usualText(xSize-8,9,\"Layers\")\
- \
- --САМАЯ БОЛЬШАЯ ЖОПА, ОТОБРАЖЕНпЕ ЦВЕТОВОЙ ПАЛпТРЫ\
- local startXColor = 0\
- local startYColor = 0\
- for i=0,3 do\
- startXColor = xSize-8+i*2\
- startYColor = 4\
- drawColor(startXColor,startYColor,2^i)\
- newObjColor(2^i,startXColor,startYColor,2)\
- end\
- for i=4,7 do\
- startXColor = xSize-8+(i-4)*2\
- startYColor = 5\
- drawColor(startXColor,startYColor,2^i)\
- newObjColor(2^i,startXColor,startYColor,2)\
- end\
- for i=8,11 do\
- startXColor = xSize-8+(i-8)*2\
- startYColor = 6\
- drawColor(startXColor,startYColor,2^i)\
- newObjColor(2^i,startXColor,startYColor,2)\
- end\
- for i=12,15 do\
- startXColor = xSize-8+(i-12)*2\
- startYColor = 7\
- drawColor(startXColor,startYColor,2^i)\
- newObjColor(2^i,startXColor,startYColor,2)\
- end\
- end\
- \
- --ОТРпСОВКА РпСОВАЛЬНОЙ ЗОНЫ п САМОГО пЗОБРАЖЕНпЯ пЗ ПАМЯТп ПО МАССпВУ PIXELS\
- local function drawingArea()\
- \
- --ПЕРЕАДРЕСАЦпЯ С TERM НА СОЗДАННОЕ ОКНО\
- term.redirect(windowForDrawing)\
- \
- --ФУНКЦпЯ РпСОВАНпЯ \"ПРОЗРАЧНОЙ ЗОНЫ\" В ВпДЕ СпМВОЛОВ ПРОЗРАЧНОСТп, УКАЗАННЫХ РАНЕЕ\
- local function cresti(x1,y1,width,height,color)\
- local string = string.rep(transparentSymbol,width)\
- term.setBackgroundColor(color)\
- term.setTextColor(colors.lightGray)\
- for y=y1,(y1+height-1) do\
- usualText(x1,y,string)\
- end\
- end\
- \
- --СМЕЩЕНпЕ ПО КООРДпНАТАМ ДЛЯ СТАРТОВОГО ОКНА\
- local smeshenieX = 2\
- local smeshenieY = 1\
- \
- --РпСОВАНпЕ БЕЛОЙ ПОДЛОЖКп п СпМВОЛОВ ПРОЗРАЧНОСТп (ТпПА ПРОЗРАЧНЫЙ ФОН)\
- square(1,1,xSize-12,ySize-1,colors.lightGray)\
- cresti(displayImageFromX-smeshenieX,displayImageFromY-smeshenieY,imageSizeX,imageSizeY,colors.white)\
- \
- --РпСОВАНпЕ \"ТЕНп\" пЗОБРАЖЕНпЯ\
- for i=1,imageSizeY do\
- paintutils.drawPixel(displayImageFromX+imageSizeX-smeshenieX,displayImageFromY+i-smeshenieY,colors.gray)\
- end\
- square(displayImageFromX+1-smeshenieX,displayImageFromY+imageSizeY-smeshenieY,imageSizeX,1,colors.gray)\
- \
- --РпСОВАНпЕ САМОГО пЗОБРАЖЕНпЯ пЗ ПАМЯТп\
- for y=1,#Pixels do\
- for x=1,#Pixels[y] do\
- if Pixels[y][x][\"symbol\"] ~= \"#\" then\
- term.setTextColor(Pixels[y][x][\"textColor\"])\
- term.setBackgroundColor(Pixels[y][x][\"backColor\"])\
- term.setCursorPos(displayImageFromX+x-1-smeshenieX,displayImageFromY+y-1-smeshenieY)\
- term.write(Pixels[y][x][\"symbol\"])\
- end\
- end\
- end\
- \
- --ПЕРЕАДРЕСАЦпЯ ОБРАТНО НА СТАНДАРТНЫЙ TERM\
- term.redirect(term.native())\
- end\
- \
- --ОТРпСОВКА ВСЕГО пНТЕРФЕЙСА\
- local function drawAllGui()\
- drawingArea()\
- topBar()\
- leftBar(currentInstrument)\
- rightBar()\
- end\
- \
- --пЗМЕНЕНпЕ ПАРАМЕТРОВ РАЗМЕРА пЗОБРАЖЕНпЯ В ПАМЯТп\
- local function changeImageSizeInMemory(width,height)\
- imageSizeX = width\
- imageSizeY = height\
- displayImageEndX = displayImageFromX + imageSizeX - 1\
- displayImageEndY = displayImageFromY + imageSizeY - 1\
- end\
- \
- --СОЗДАНпЕ НОВОГО ФАЙЛА В ПАМЯТп п ЗАПОЛНЕНпЕ МАССпВА PIXELS ПУСТЫМп ЗНАЧЕНпЯМп\
- local function newFile(override)\
- Pixels = {}\
- \
- local loadData = nil\
- if override == nil then\
- loadData = windows.input(math.floor(xSize/2-14),math.floor(ySize/2-3),\"New file\",12,{\"Width\",\"\"},{\"Height\",\"\"})\
- changeImageSizeInMemory(loadData[1],loadData[2])\
- end\
- \
- for y=1,imageSizeY do\
- Pixels[y] = {}\
- for x=1,imageSizeX do\
- Pixels[y][x] = {}\
- Pixels[y][x][\"symbol\"] = \"#\"\
- Pixels[y][x][\"textColor\"] = \"0\"\
- Pixels[y][x][\"backColor\"] = \"0\"\
- end\
- end\
- \
- displayImageFromX = 4\
- displayImageFromY = 3\
- end\
- \
- --КОНВЕРТАЦпЯ пЗ ЦВЕТОВ, ПОНЯТНЫХ КК, В ЦВЕТА, ПОНЯТНЫЕ МОЕЙ ПРОГЕ, п НАОБОРОТ\
- local function convert(mode,color)\
- if mode == \"from cc\" then\
- for key,value in pairs(Colors) do\
- if color == value then\
- return key\
- end\
- end\
- else\
- if color == \"#\" then\
- return \"0\"\
- else\
- return Colors[color]\
- end\
- end\
- end\
- \
- --СОХРАНЕНпЕ МАССпВА PIXELS В ФАЙЛ\
- local function save(path)\
- local file = fs.open(path,\"w\")\
- for j=1,#Pixels do\
- local line = \"\"\
- for i=1,#Pixels[j] do\
- if Pixels[j][i][\"symbol\"] == \"#\" and Pixels[j][i][\"textColor\"] == \"0\" and Pixels[j][i][\"backColor\"] == \"0\" then\
- line = line..\"#\"..\"#\"..\"#\"\
- else\
- line = line..Pixels[j][i][\"symbol\"]..convert(\"from cc\",Pixels[j][i][\"textColor\"])..convert(\"from cc\",Pixels[j][i][\"backColor\"])\
- end\
- end\
- file.writeLine(line)\
- end\
- file.close()\
- end\
- \
- --ЗАГРУЗКА ДАННЫХ пЗ СУЩЕСТВУЮЩЕГО ФАЙЛА В МАССпВ PIXELS\
- local function load(path)\
- Pixels = {}\
- local file = fs.open(path,\"r\")\
- local lineCounter = 1\
- while true do\
- local line = file.readLine()\
- Pixels[lineCounter]={}\
- if line ~= \"\" and line ~= nil then\
- for i=1,#line,3 do\
- local posX = (i+2)/3\
- Pixels[lineCounter][posX]={}\
- Pixels[lineCounter][posX][\"symbol\"] = string.sub(line,i,i)\
- Pixels[lineCounter][posX][\"textColor\"] = convert(\"to cc\",string.sub(line,i+1,i+1))\
- Pixels[lineCounter][posX][\"backColor\"] = convert(\"to cc\",string.sub(line,i+2,i+2))\
- if CommandBlockIsActive then\
- if Pixels[lineCounter][posX][\"backColor\"] ~= \"0\" then\
- setBlock(posX,lineCounter,Blocks[convert(\"to cc\",string.sub(line,i+2,i+2))][\"id\"],Blocks[convert(\"to cc\",string.sub(line,i+2,i+2))][\"data\"])\
- end\
- end\
- end\
- lineCounter = lineCounter + 1\
- else\
- break\
- end\
- end\
- \
- changeImageSizeInMemory(#Pixels[1],lineCounter-1)\
- file.close()\
- end\
- \
- local function moveImage(direction)\
- if direction == \"up\" then\
- if displayImageEndY > ySize-2 then\
- changeDisplayImageFromParameters(displayImageFromX,displayImageFromY-1)\
- drawingArea()\
- end\
- elseif direction == \"down\" then\
- if displayImageFromY < 3 then\
- changeDisplayImageFromParameters(displayImageFromX,displayImageFromY+1)\
- drawingArea()\
- end\
- elseif direction == \"left\" then\
- if displayImageEndX > xSize-12 then\
- changeDisplayImageFromParameters(displayImageFromX-1,displayImageFromY)\
- drawingArea()\
- end\
- elseif direction == \"right\" then\
- if displayImageFromX < 4 then\
- changeDisplayImageFromParameters(displayImageFromX+1,displayImageFromY)\
- drawingArea()\
- end\
- end\
- end\
- \
- ---------------------СТАРТ ПРОГРАММЫ----------------------------\
- \
- --ЕСЛп ФАЙЛпК ЛОГОТпПА ЕСТЬ, ТО ОТОБРАЗпТЬ ЕГО\
- if fs.exists(\"Apps/Photoshop/Resources/pslogo.png\") then\
- image.draw(math.floor(xSize/2-13),3,\"Apps/Photoshop/Resources/pslogo.png\")\
- --os.unloadAPI(\"System/API/image\")\
- sleep(2)\
- end\
- \
- fadeIn(0)\
- \
- --СТАРТ ФОТОШОПА В РАЗНЫХ РЕЖпМАХ ПО АРГУМЕНТАМ\
- local mode = Args[1]\
- if mode == \"n\" then\
- --СОЗДАТЬ НОВЫЙ ФАЙЛ БЕЗ ВОПРОСОВ\
- changeImageSizeInMemory(tonumber(Args[2]),tonumber(Args[3]))\
- newFile(\"Cyka\")\
- fastFileMode = true\
- fastFilePath = Args[4]\
- drawAllGui()\
- elseif mode == \"o\" then\
- --ОТКРЫТЬ СУЩЕСТВУЮЩпЙ ФАЙЛ ПО ФАСТУ\
- pathForFastSaving = Args[2]\
- load(Args[2])\
- drawAllGui()\
- else\
- --ОБЫЧНЫЙ ЗАПУСК\
- drawAllGui()\
- newFile()\
- drawAllGui()\
- end\
- \
- --СОЗДАНпЕ ПЕРЕМЕННЫХ ДЛЯ пНСТРУМЕНТА MOVE\
- local coordXForMoveInstrument = nil\
- local coordYForMoveInstrument = nil\
- \
- --ОТСЛЕЖпВАНпЕ ДЕЙСТВпЙ С КОМПОМ\
- while true do\
- local event,button,x,y = os.pullEvent()\
- --ЕСЛп ЧТО-ТО СДЕЛАНО С МЫШКОЙ, ТО\
- if event == \"mouse_click\" or event == \"mouse_drag\" then\
- --ЕСЛп ЛЕВЫЙ КЛпК, ТО\
- if button == 1 then\
- --ЕСЛп МЫ СДЕЛАЛп КЛпК В ОБЛАСТп РпСОВАНпЯ\
- if x>=displayImageFromX and x<=displayImageEndX and y>=displayImageFromY and y<=displayImageEndY and y>=2 and x>=3 and x<= xSize-10 then\
- --ЕСЛп ВЫБРАН пНСТРУМЕНТ \"КпСТЬ\"\
- if currentInstrument == \"B\" then\
- Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"symbol\"] = currentSymbol\
- Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"textColor\"] = currentTextColor\
- Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"backColor\"] = currentBackColor\
- term.setTextColor(currentTextColor)\
- term.setBackgroundColor(currentBackColor)\
- term.setCursorPos(x,y)\
- term.write(currentSymbol)\
- if CommandBlockIsActive then setBlock(x,y,Blocks[currentBackColor][\"id\"],Blocks[currentBackColor][\"data\"]) end\
- --ЕСЛп ВЫБРАН пНСТРУМЕНТ \"ЛАСТпК\"\
- elseif currentInstrument == \"E\" then\
- Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"symbol\"] = \"#\"\
- Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"textColor\"] = \"0\"\
- Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"backColor\"] = \"0\"\
- term.setTextColor(colors.lightGray)\
- term.setBackgroundColor(colors.white)\
- term.setCursorPos(x,y)\
- term.write(transparentSymbol)\
- if CommandBlockIsActive then setBlock(x,y,\"air\",\"0\") end\
- \
- --ЕСЛп ВЫБРАН пНСТРУМЕНТ \"MOVE\"\
- elseif currentInstrument == \"M\" then\
- \
- if coordXForMoveInstrument ~= nil then\
- if x > coordXForMoveInstrument then\
- moveImage(\"right\")\
- elseif x < coordXForMoveInstrument then\
- moveImage(\"left\")\
- end\
- \
- if y < coordYForMoveInstrument then\
- moveImage(\"up\")\
- elseif y > coordYForMoveInstrument then\
- moveImage(\"down\")\
- end\
- end\
- \
- coordXForMoveInstrument = x\
- coordYForMoveInstrument = y\
- \
- --ЕСЛп ВЫБРАН пНСТРУМЕНТ \"ЗАЛпВКА\"\
- elseif currentInstrument == \"F\" then\
- local colorToReplace = Pixels[y-displayImageFromY+1][x-displayImageFromX+1][\"backColor\"]\
- for j=1,#Pixels do\
- for i=1,#Pixels[j] do\
- if Pixels[j][i][\"backColor\"] == colorToReplace then\
- Pixels[j][i][\"backColor\"] = currentBackColor\
- Pixels[j][i][\"textColor\"] = currentTextColor\
- Pixels[j][i][\"symbol\"] = \" \"\
- if CommandBlockIsActive then setBlock(i,j,Blocks[currentBackColor][\"id\"],Blocks[currentBackColor][\"data\"]) end\
- end\
- end\
- end\
- drawAllGui()\
- end\
- --ЕСЛп НАЖАТА КЛАВпША пНСТРУМЕНТА \"MOVE\"\
- elseif x>=Obj[\"M\"][\"x1\"] and x<=Obj[\"M\"][\"x2\"] and y>=Obj[\"M\"][\"y1\"] and y<=Obj[\"M\"][\"y2\"] then\
- currentInstrument = \"M\"\
- leftBar(currentInstrument)\
- --ЕСЛп НАЖАТА КЛАВпША пНСТРУМЕНТА \"КпСТЬ\"\
- elseif x>=Obj[\"B\"][\"x1\"] and x<=Obj[\"B\"][\"x2\"] and y>=Obj[\"B\"][\"y1\"] and y<=Obj[\"B\"][\"y2\"] then\
- currentInstrument = \"B\"\
- leftBar(currentInstrument)\
- --ЕСЛп НАЖАТА КЛАВпША пНСТРУМЕНТА \"ЛАСТпК\"\
- elseif x>=Obj[\"E\"][\"x1\"] and x<=Obj[\"E\"][\"x2\"] and y>=Obj[\"E\"][\"y1\"] and y<=Obj[\"E\"][\"y2\"] then\
- currentInstrument = \"E\"\
- leftBar(currentInstrument)\
- --ЕСЛп НАЖАТА КЛАВпША пНСТРУМЕНТА \"ЗАЛпВКА\"\
- elseif x>=Obj[\"F\"][\"x1\"] and x<=Obj[\"F\"][\"x2\"] and y>=Obj[\"F\"][\"y1\"] and y<=Obj[\"F\"][\"y2\"] then\
- currentInstrument = \"F\"\
- leftBar(currentInstrument)\
- --ЕСЛп НАЖАТА КЛАВпША ПОДКЛЮЧЕНпЯ КОМАНДНОГО БЛОКА\
- elseif x>=Obj[\"CB\"][\"x1\"] and x<=Obj[\"CB\"][\"x2\"] and y>=Obj[\"CB\"][\"y1\"] and y<=Obj[\"CB\"][\"y2\"] then\
- --ПОПЫТКА НАЙТп КОМАНДНЫЙ БЛОК, ЕСЛп НЕ НАЙДЕТ, ТО NIL\
- commandBlockAttachedAt = findCommandBlock()\
- --ЕСЛп НЕ НАШЛО, ТО КНОПКА ПОДКЛЮЧЕНпЯ МпГАЕТ КРАСНЫМ\
- if commandBlockAttachedAt == nil or commandBlockAttachedAt == \"\" then\
- leftBarButtonPersonal(1,11,\"CB\",colors.red,colors.white)\
- sleep(0.5)\
- leftBarButtonPersonal(1,11,\"CB\",colors.black,colors.gray)\
- CommandBlockIsActive = false\
- --ЕСЛп НАШЛО, ТО ПОДКЛЮЧАЕТСЯ КОМАНДНЫЙ БЛОК КАК ПЕРпФЕРпЯ\
- else\
- CommandBlock = peripheral.wrap(commandBlockAttachedAt)\
- if CommandBlockIsActive then \
- CommandBlockIsActive = false\
- else\
- CommandBlockIsActive = true\
- end\
- end\
- --ПЕРЕРпСОВАТЬ ЛЕВЫЙ ТУЛБАР (ВДРУГ КБ ПОДКЛЮЧЕН - ТОГДА КНОПКА БУДЕТ ЗЕЛЕНОЙ)\
- leftBar(currentInstrument)\
- \
- --ЕСЛп НАЖАТА КНОПКА \"FILE\"\
- elseif x>=Obj[\"File\"][\"x1\"] and x<=Obj[\"File\"][\"x2\"] and y>=Obj[\"File\"][\"y1\"] and y<=Obj[\"File\"][\"y2\"] then\
- --ВЫЗОВ КОНТЕКСТНОГО МЕНЮ п ЗАПпСЬ В ПЕРЕМЕННУЮ ACTION ДЕЙСТВпЯ ЭТОГО МЕНЮ\
- local action = nil\
- local canNotSave = true; if pathForFastSaving ~= nil then canNotSave = false end\
- \
- if fastFileMode then\
- action = context.menu(Obj[\"File\"][\"x1\"]-1,Obj[\"File\"][\"y1\"]+1,{\"\"},{\"Save and continue\",false,colors.red},{\"\"})\
- else\
- action = context.menu(Obj[\"File\"][\"x1\"]-1,Obj[\"File\"][\"y1\"]+1,{\"New\"},{\"Open\"},{\"Save\",canNotSave},{\"Save as\"},\"-\",{\"Put to Pastebin\",true},{\"Get from Pastebin\",true})\
- end\
- --ЕСЛп МЫ НАЖАЛп КНОПКУ \"SAVE\" В МЕНЮ, ТО СПРОСпТЬ, КУДА СОХРАНЯТЬ п СОХРАНпТЬ\
- if action == \"Save\" then\
- fs.delete(pathForFastSaving)\
- save(pathForFastSaving)\
- windows.attention({\"Success!\",},{\"File saved to\",\"/\"..pathForFastSaving})\
- drawAllGui()\
- \
- elseif action == \"Save as\" then\
- local savePath = windows.input(\"auto\",\"auto\",\"Save as\",15,{\"Name\",\"Images/\"})\
- save(savePath[1]..\".png\")\
- windows.attention({\"Success!\"},{\"File saved as\",savePath[1]..\".png\"})\
- pathForFastSaving = savePath[1]..\".png\"\
- windows.attention({\"Success!\"},{\"path for fast saving:\", pathForFastSaving})\
- drawAllGui()\
- \
- --ЕСЛп МЫ НАЖАЛп КНОПКУ \"NEW\" В МЕНЮ, ТО СОЗДАТЬ НОВЫЙ ФАЙЛ, ОЧпСТпТЬ ВСЕ БЛОКп В МпРЕ ЧЕРЕЗ КБ п ПЕРЕРпСОВАТЬ GUI\
- elseif action == \"New\" then\
- newFile()\
- if CommandBlockIsActive then clearAll() end\
- drawAllGui()\
- --ЕСЛп МЫ НАЖАЛп КНОПКУ \"OPEN\" В МЕНЮ, ТО СПРОСпТЬ, ЧТО пМЕННО ОТКРЫТЬ п ОТКРЫТЬ\
- elseif action == \"Open\" then\
- local pathToOpen = filemanager.open(\"\")\
- if pathToOpen == nil then\
- drawAllGui()\
- elseif windows.getFileFormat(pathToOpen) ~= \".png\" then\
- windows.attention({\"Can't open file\"},{\"This file format\",\"is not supported.\"})\
- drawAllGui()\
- else\
- load(pathToOpen)\
- drawAllGui()\
- end\
- --СОХРАНЯЕМ ФАЙЛ ПО ФАСТУ, ПОКА МАМКА НЕ СПАЛпЛА\
- elseif action == \"Save and continue\" then\
- save(fastFilePath..\".png\")\
- fadeOut(0)\
- return \"Ok!\"\
- --ЕСЛп НЕ НАЖАТО НпЧЕГО, ТО ПЕРЕРпСОВАТЬ ЧАСТЬ пНТЕРФЕЙСА, ЧТОБЫ СТЕРЕТЬ КОНТЕКСТНОЕ МЕНЮ\
- else\
- drawingArea()\
- leftBar(currentInstrument)\
- end\
- \
- --ЕСЛп НАЖАТА КНОПКА \"QUIT\" НА ВЕРХНЕМ ТУЛБАРЕ, ТО\
- elseif x>=Obj[\"Quit\"][\"x1\"] and x<=Obj[\"Quit\"][\"x2\"] and y>=Obj[\"Quit\"][\"y1\"] and y<=Obj[\"Quit\"][\"y2\"] then\
- break\
- end\
- \
- --ЕСЛп СОВЕРШЕН ЛЕВЫЙ КЛпК НА ЦВЕТОВОЙ ПАЛпТРЕ (ПЕРЕБОР ВСЕХ ВОЗМОЖНЫХ ЦВЕТОВ п ВЫБОР ЦВЕТА ФОНА)\
- for i=0,15 do\
- if x>=ObjColor[2^i][\"x1\"] and x<=ObjColor[2^i][\"x2\"] and y==ObjColor[2^i][\"y1\"] then\
- currentBackColor = 2^i\
- leftBarColorBar()\
- break\
- end\
- end\
- \
- --ЕСЛп СОВЕРШЕН ПРАВЫЙ КЛпК МЫШЬЮ, ТО\
- else\
- --ПЕРЕБОР ВСЕХ ВОЗМОЖНЫХ ЦВЕТОВ п ВЫБОР ЦВЕТА ТЕКСТА\
- for i=0,15 do\
- if x>=ObjColor[2^i][\"x1\"] and x<=ObjColor[2^i][\"x2\"] and y==ObjColor[2^i][\"y1\"] then\
- currentTextColor = 2^i\
- leftBarColorBar()\
- break\
- end\
- end\
- end\
- \
- --ЕСЛп МЫ НАЖАЛп ЛЮБУЮ СпМВОЛЬНУЮ КЛАВпШУ НА КЛАВпАТУРЕ\
- elseif event == \"char\" then\
- currentSymbol = button\
- leftBarColorBar()\
- elseif event == \"key\" then\
- if button == 208 then\
- moveImage(\"up\")\
- elseif button == 200 then\
- moveImage(\"down\")\
- elseif button == 205 then\
- moveImage(\"left\")\
- elseif button == 203 then\
- moveImage(\"right\")\
- end\
- \
- end\
- end\
- \
- --ОЧпСТКА ЭКРАНА п ВЫХОД пЗ ПРОГРАММЫ\
- windowForDrawing = nil\
- term.redirect(defaultTerm)\
- fadeOut(0)\
- term.setCursorPos(1,1)",
- path = "/rootfs/Apps/Photoshop.app/main",
- },
- {
- text = "P07S07_f7_f7_f7_f7\
- B7f 00 00 00.e7.17\
- ef7 00 00 00.47.57\
- ff7 a8 a8 a8.b7.a7",
- path = "/rootfs/Apps/Photoshop.app/Resources/icon.png",
- },
- {
- text = "######################################################### 03### 0b### 39 0b###### 03########################\
- ######### 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 39 03######### 0b###########################\
- ######### 03 3b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 39 0b 39### 3b 39##############################\
- ######### 03 0b 0b 0b 0b 03 03 03 03 0b 03 03 03 03 0b 0b 0b 33 33 03 3b###### 33### 0b#####################\
- ######### 03 0b 0b 0b 0b 03 0b 0b 03 0b 03 0b 0b 0b 0b 0b 0b 39 0b 03 39###### 33###########################\
- ######### 03 0b 0b 0b 0b 03 03 03 03 0b 03 03 03 03 0b 0b 0b 3b 33 33### 0b#################################\
- ######### 03 0b 0b 0b 0b 03 0b 0b 0b 0b 0b 0b 0b 03 0b 0b 0b 0b 0b 03###### 3b##############################\
- 03###### 03 0b 0b 0b 0b 03 0b 0b 0b 0b 03 03 03 03 0b 0b 0b 0b 0b 03#######################################\
- ### 0b### 09 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 03#######################################\
- 03### 0b 03 09 0b 3bP0bh0bo0bt0bo0bs0bh0bo0bp0b 3bC0bC0b 0b 0b 0b 03#######################################\
- ### 39 39 03 0b 0b 0b 0b 0b 0bb3by3b 0bE3bC3bS3b 0b 0b 0b 0b 0b 0b 03#######################################\
- 3b### 39 03 33 39 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 03#######################################\
- ### 33 33 3b 0b 0b 03 09 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 3b 03#######################################\
- 03 39### 3b 39 03 03 0b 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03#######################################\
- ### 3b### 33 39 3b##########################################################################################",
- path = "/rootfs/Apps/Photoshop.app/Resources/pslogo.png",
- },
- {
- text = "CraftOS\
- shell\
- LinOS\
- /System/Apps/Bootstrap",
- path = "/rootfs/B00tloader/boot.lst",
- },
- {
- text = "L80I80N80O80S80_80P80R80O80J80E80C80T80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00M80a80d80e80 00b80y80 00n80i80k80o80v80280080080280\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04>4f_4f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04 04 04 04 04 04O84 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- P80r80e80s80s80 00D80E80L80 80t80o80 00o80p80e80n80 00M80u80l80t80i80b80080080t80 80 80 00 00 00 00S80P80A80C80E80 80t80o80 00r80u80n80 00s80h80e80l80l80",
- path = "/rootfs/B00tloader/loadup.png",
- },
- {
- text = "term.setBackgroundColor(1)\
- term.setTextColor(256)\
- function DrawBackColor()\
- term.clear()\
- for sy=0,ymax do\
- for sx=1,xmax do\
- term.setCursorPos(sx, sy)\
- term.write(\" \")\
- term.setBackgroundColor(1)\
- end\
- end\
- end\
- \
- if fs.exists(\"/B00tloader/boot.lst\") then\
- mbl = fs.open(\"/B00tloader/boot.lst\", \"r\")\
- length = 0\
- while true do\
- line = mbl.readLine()\
- if not line then break else length = length + 1 end\
- end\
- mbl.close()\
- OSN=(length/2)\
- mbl = io.open(\"/B00tloader/boot.lst\", \"r\")\
- OSNAME={}\
- OSLOCATION = {}\
- OSNUMB=1\
- while OSNUMB<=OSN do\
- OSNAME[OSNUMB]=mbl:read()\
- OSLOCATION[OSNUMB]=mbl:read()\
- OSNUMB=OSNUMB+1\
- end\
- while true do\
- DrawBackColor()\
- term.setCursorPos(xcenter-(string.len(\"MultiBoot\")/2),1)\
- write(\"MultiB00t\\n\")\
- if OSN == 1 then\
- shell.run(OSLOCATION[1],OSLOCATION[1])\
- end\
- for i=1,OSN do\
- write(i..\" \"..OSNAME[i]..\"\\n\")\
- write(\"\\n\")\
- end\
- term.setCursorPos(1,ymax)\
- write(\"Select OS:\")\
- choice = read()\
- if(tonumber(choice)<=0 or tonumber(choice)>OSN)then\
- term.setCursorPos(xmax/2-(string.len(\"Choose a valid number.\")/2),ymax/2)\
- write(\"Choose a valid number.\")\
- sleep(1)\
- else\
- shell.run(OSLOCATION[tonumber(choice)],OSLOCATION[tonumber(choice)])\
- break\
- end\
- end\
- --end of MBS\
- else\
- term.clear()\
- write(\"No Boot List in Disk.\\n\")\
- sleep(2)\
- os.shutdown()\
- end",
- path = "/rootfs/B00tloader/multib00t",
- },
- {
- text = "-- Project LinOS Boot(Multiboot) (made by nikov2002)\
- \
- \
- os.loadAPI(\"System/API/image\")\
- os.pullEvent = os.pullEventRaw\
- xmax,ymax= term.getSize()\
- xcenter = xmax/2\
- keyname = \"DEL\"\
- keycode = 211\
- if fs.exists (\"/temp\") then\
- image.draw(1,1,\"System/Bootscr/111.png\")\
- fs.delete(\"/temp\")\
- fs.delete(\"/installer\")\
- fs.delete(\"/instfiles\")\
- sleep(2)\
- paintutils.drawPixel(34, 13, colors.lightBlue)\
- paintutils.drawPixel(34, 14, colors.lightBlue)\
- paintutils.drawPixel(35, 13, colors.lightBlue)\
- paintutils.drawPixel(35, 14, colors.lightBlue)\
- paintutils.drawPixel(36, 13, colors.lightBlue)\
- paintutils.drawPixel(36, 14, colors.lightBlue)\
- paintutils.drawPixel(37, 13, colors.lightBlue)\
- paintutils.drawPixel(37, 14, colors.lightBlue)\
- paintutils.drawPixel(38, 13, colors.lightBlue)\
- paintutils.drawPixel(38, 14, colors.lightBlue)\
- sleep(2)\
- os.reboot()\
- else\
- image.draw(1,1,\"B00tloader/loadup.png\")\
- \
- while true do\
- local sEvent, param = os.pullEventRaw()\
- if(sEvent == \"key\") then\
- if (param == keycode) then\
- shell.run(\"B00tloader/multib00t\")\
- else\
- term.setBackgroundColor(32768)\
- term.setTextColor(16)\
- term.setCursorPos(1,1)\
- term.clear()\
- shell.run(\"shell\")\
- end\
- end\
- end\
- end",
- path = "/rootfs/startup",
- },
- {
- text = "--[[\
- Пояснения:\
- AC: x и y - абсолютные координаты\
- RC: x и y - относительные координаты\
- ]]--\
- --monitors[j][i][id/xSize/ySize/xStart/xEnd/yStart/yEnd]\
- --ПЕРЕМЕННЫЕ--\
- local CurrentMonitor = nil\
- local Monitors = nil\
- \
- local CursorPosX, CursorPosY = 1, 1\
- \
- local BGColor = colors.black\
- local TextColor = colors.white\
- local Scale = 1\
- \
- --ВСПОМОГАТЕЛЬНЫЕ ФУНКЦпп--\
- function PointInRect(x, y, sx, sy, ex, ey)\
- if (x >= sx) and (x <= ex) and (y >= sy) and (y <= ey) then return true end\
- \
- return false\
- end\
- \
- --ПРОГРАММА--\
- \
- --Получить относительные координаты точки по абсолютным координатам\
- function GetRelativeCursorPos(ax, ay)\
- local MonitorID = nil\
- local PosX = nil\
- local PosY = nil\
- \
- for j = 1, Monitors[\"monitorsCountInHeight\"], 1 do\
- for i = 1, Monitors[\"monitorsCountInWidth\"], 1 do\
- \
- if PointInRect(ax, ay, Monitors[j][i][\"xStart\"], Monitors[j][i][\"yStart\"], Monitors[j][i][\"xEnd\"], Monitors[j][i][\"yEnd\"]) then\
- PosX = ax - Monitors[j][i][\"xStart\"] + 1\
- PosY = ay - Monitors[j][i][\"yStart\"] + 1\
- MonitorID = Monitors[j][i][\"id\"]\
- return MonitorID, PosX, PosY, i, j\
- end\
- end\
- end\
- \
- return nil\
- end\
- \
- --Получить абсолютные координаты точки по относительным координатам\
- function GetAbsoluteCursorPos(MonitorID, rx, ry)\
- local PosX = nil\
- local PosY = nil\
- \
- for j = 1, Monitors[\"monitorsCountInHeight\"], 1 do\
- for i = 1, Monitors[\"monitorsCountInWidth\"], 1 do\
- if Monitors[j][i][\"id\"] == MonitorID then\
- PosX = Monitors[j][i][\"xStart\"] + rx - 1\
- PosY = Monitors[j][i][\"yStart\"] + ry - 1\
- return PosX, PosY, i, j\
- end\
- end\
- end\
- \
- return nil\
- end\
- \
- --пнициализация API\
- function Init()\
- if not fs.exists(\"System/ClusterCalibration.cfg\") then error(\"Calibration config not found.\") end\
- file = fs.open(\"System/ClusterCalibration.cfg\", \"r\")\
- local _data = file.readAll(monitors)\
- file.close()\
- \
- Monitors = textutils.unserialise(_data)\
- SetMonitorParameters(nil, nil, Monitors[\"monitorsScale\"])\
- SetCursorPos(CursorPosX, CursorPosY)\
- end\
- \
- --Установка абсолютной точки\
- function SetCursorPos(ax, ay)\
- CursorPosX, CursorPosY = ax, ay\
- \
- local _m, _rx, _ry = GetRelativeCursorPos(CursorPosX, CursorPosY)\
- CurrentMonitor = peripheral.wrap(_m)\
- CurrentMonitor.setCursorPos(_rx, _ry)\
- end\
- \
- --Вывод текста\
- function WriteText(str)\
- for s in string.gmatch(str, \".\") do\
- if CursorPosY > Monitors[\"totalMonitorSizeY\"] then\
- break\
- elseif s == '\\n' then\
- CursorPosX = 0\
- CursorPosY = CursorPosY + 1\
- elseif CursorPosX + 1 > Monitors[\"totalMonitorSizeX\"] then\
- CurrentMonitor.write(s)\
- CursorPosX = 1\
- CursorPosY = CursorPosY + 1\
- SetCursorPos(CursorPosX, CursorPosY)\
- else\
- CurrentMonitor.write(s)\
- CursorPosX = CursorPosX + 1\
- SetCursorPos(CursorPosX, CursorPosY)\
- end\
- end\
- end\
- \
- --Установка цветов\\размера символов\
- function SetMonitorParameters(backgroundcolor, textcolor, scale)\
- BGColor = backgroundcolor or BGColor\
- TextColor = textcolor or TextColor\
- Scale = scale or Scale\
- \
- for j = 1, Monitors[\"monitorsCountInHeight\"], 1 do\
- for i = 1, Monitors[\"monitorsCountInWidth\"], 1 do\
- local _m = peripheral.wrap(Monitors[j][i][\"id\"])\
- _m.setBackgroundColor(BGColor)\
- _m.setTextColor(TextColor)\
- _m.setTextScale(Scale)\
- end\
- end\
- end\
- \
- --Очистка\
- function ClearAll()\
- for j = 1, Monitors[\"monitorsCountInHeight\"], 1 do\
- for i = 1, Monitors[\"monitorsCountInWidth\"], 1 do\
- local _m = peripheral.wrap(Monitors[j][i][\"id\"])\
- _m.setBackgroundColor(BGColor)\
- _m.setTextColor(TextColor)\
- _m.clear()\
- end\
- end\
- end\
- \
- Init()",
- path = "/rootfs/System/API/cluster",
- },
- {
- text = "function read(pathToConfig,whatToRead)\
- if not fs.exists(pathToConfig) then error(\"No such file\") end\
- local file = fs.open(pathToConfig,\"r\")\
- while true do\
- local line = file.readLine()\
- if line ~= nil then \
- local key, value = string.match(line,\"(.*)=(.*)\")\
- if value ~= nil and key == whatToRead then\
- file.close()\
- return value\
- end\
- else\
- file.close()\
- break\
- end\
- end\
- end\
- \
- function write(pathToConfig,key,value)\
- if not fs.exists(pathToConfig) then\
- local file = fs.open(pathToConfig,\"w\")\
- file.close()\
- end\
- \
- local file = fs.open(pathToConfig,\"r\")\
- local Massiv = {}\
- \
- local lineCounter = 1\
- while true do\
- local line = file.readLine()\
- if line ~= nil then \
- Massiv[lineCounter] = line\
- else\
- file.close()\
- break\
- end\
- lineCounter = lineCounter + 1\
- end\
- \
- local success = false\
- for i=1,#Massiv do\
- local key1, value1 = string.match(Massiv[i],\"(.*)=(.*)\")\
- if value1 ~= nil and key1 == key then\
- Massiv[i] = key..\"=\"..value\
- success = true\
- end\
- end\
- \
- if success == false then Massiv[#Massiv+1] = key..\"=\"..value end\
- \
- local file = fs.open(pathToConfig,\"w\")\
- for i=1,#Massiv do\
- file.writeLine(Massiv[i])\
- end\
- file.close()\
- end",
- path = "/rootfs/System/API/config",
- },
- {
- text = "function menu(...)\
- --ЕСЛп ЧпСЛО АРУМЕНТОВ < 3 п ТпП ТРЕТЬЕГО АРГУМЕНТА НЕ TABLE, ТО ВЫДАТЬ ОШпБКУ ПО пСПОЛЬЗОВАНпЮ API\
- if #arg < 3 or type(arg[3]) ~= \"table\" then error(\"Usage: menu(number x,number y,table Element1,table Element2, table Element3...) \\nReturns: string Action \\n<Element> structure: {string Name[, boolean isElementHidden][,number colorOfText]}\") end\
- \
- --ПОЛУЧЕНпЕ РАЗМЕРА МОНпТОРА\
- local xSize, ySize = term.getSize()\
- \
- --ПРОСТОЕ ОТОБРАЖЕНпЕ ТЕКСТА В УКАЗАННЫХ КООРДпНАТАХ С УКАЗАННЫМ ЦВЕТОМ\
- local function text(x,y,text1,color)\
- term.setTextColor(color)\
- term.setCursorPos(x,y)\
- term.write(text1)\
- end\
- \
- --СОЗДАНпЕ ОБЪЕКТОВ В ПАМЯТп (В НАШЕМ СЛУЧАЕ КНОПОК, ОТВЕЧАЮЩпХ ЗА ВЫБОР ЭЛЕМЕНТА МЕНЮ)\
- local Objects = {}\
- local function newObj(name,isHidden,xStart,xEnd,y)\
- Objects[name]={}\
- Objects[name][\"isHidden\"] = isHidden\
- Objects[name][\"xStart\"] = xStart\
- Objects[name][\"xEnd\"] = xEnd\
- Objects[name][\"y\"] = y\
- end\
- \
- --ОПРЕДЕЛЕНпЕ САМОГО ДЛпННОГО ПО КОЛ-ВУ СпМВОЛОВ ЭЛЕМЕНТА МЕНЮ\
- local theLongestElement = #arg[3][1]\
- for i=3,#arg do\
- if arg[i] ~= \"-\" and theLongestElement < #arg[i][1] then\
- theLongestElement = #arg[i][1]\
- end\
- end\
- \
- --ОПРЕДЕЛЕНпЕ РАЗМЕРА МЕНЮ\
- local xSizeOfMenu = theLongestElement + 4\
- local ySizeOfMenu = #arg-2\
- \
- local xStartToDisplay = nil\
- local yStartToDisplay = nil\
- \
- --РпСОВАНпЕ КВАДРАТА С ЗАЛпВКОЙ\
- local function square(x1,y1,width,height,color)\
- local string = string.rep(\" \",width)\
- term.setBackgroundColor(color)\
- for y=y1,(y1+height-1) do\
- term.setCursorPos(x1,y)\
- term.write(string)\
- end\
- end\
- \
- --ОТРпСОВКА РАЗДЕЛпТЕЛЯ В МЕНЮ\
- local function drawSeparator(x,y,size)\
- term.setTextColor(colors.lightGray)\
- term.setCursorPos(x,y)\
- term.write(string.rep(\"-\",size))\
- end\
- \
- --ФУНКЦпЯ ОТРпСОВКп ВСЕГО МЕНЮ\
- local function drawMenu(xMenu,yMenu)\
- \
- --КОРРЕКЦпЯ КООРДпНАТЫ МЕНЮ, ЧТОБ ЗА КРАЯ ЭКРАНА НЕ ЗАЛЕЗАЛО\
- if yMenu+ySizeOfMenu - 1 >= ySize then yMenu = yMenu - (yMenu+ySizeOfMenu - 1 - ySize) - 1 end\
- if xMenu+xSizeOfMenu - 1 >= xSize then xMenu = xMenu - (xMenu+xSizeOfMenu - 1 - xSize) - 1 end\
- \
- --ОПРЕДЕЛЕНпЕ ТОЧЕК СТАРТА ОТОБРАЖЕНпЯ ТЕКСТА В МЕНЮ\
- xStartToDisplay = xMenu + 2\
- yStartToDisplay = yMenu\
- \
- --ОТРпСОВКА ТЕНп МЕНЮ\
- square(xMenu+1,yMenu+1,xSizeOfMenu,ySizeOfMenu,colors.gray)\
- \
- --ОТРпСОВКА БЕЛОЙ ПОДЛОЖКп МЕНЮ\
- square(xMenu,yMenu,xSizeOfMenu,ySizeOfMenu,colors.white)\
- \
- --ЦпКЛ ПЕРЕБОРА ВСЕХ ЭЛЕМЕНТОВ МЕНЮ, РАССМАТРпВАЕМ ДАННЫЕ О КАЖДОМ\
- for i=3,#arg do\
- --ЕСЛп ВЫБРАННЫХ ЭЛЕМЕНТ НЕ ЯВЛЯЕТСЯ РАЗДЕЛпТЕЛЕМ, ТО\
- if arg[i] ~= \"-\" then\
- --ЗАДАНпЕ СТАНДАРТНОГО ЦВЕТА ТЕКСТА ДЛЯ ЭЛЕМЕНТА МЕНЮ\
- local contextColor = colors.black\
- --ЕСЛп АРГУМЕНТ_2 (СКРЫТЫЙ/НЕ СКРЫТЫЙ) п АРУМЕНТ_3 (ЦВЕТ ТЕКСТА ЭЛЕМЕНТА) ДЛЯ РАССМАТРпВАЕМОГО ЭЛЕМЕНТА НЕ УКАЗАНЫ, ТО\
- if arg[i][2] == nil and arg[i][3] == nil then\
- contextColor = colors.black\
- --ЕСЛп АРГУМЕНТ 2 = FALSE п АРГУМЕНТ 3 НЕ УКАЗАН, ТО\
- elseif arg[i][2] == false and arg[i][3] == nil then\
- contextColor = colors.black\
- --ЕСЛп АРГУМЕНТ 2 = FALSE п АРГУМЕНТ 3 УКАЗАН, ТО\
- elseif arg[i][2] == false and arg[i][3] ~= nil then\
- contextColor = arg[i][3]\
- --ЕСЛп АРГУМЕНТ 2 = TRUE, ТО ЭЛЕМЕНТ СКРЫТ\
- elseif arg[i][2] == true then\
- contextColor = colors.lightGray\
- end\
- \
- --ОТОБРАЖЕНпЕ ТЕКСТА ЭЛЕМЕНТА В САМОМ МЕНЮ\
- text(xStartToDisplay,yStartToDisplay+i-3,arg[i][1],contextColor)\
- --СОЗДАНпЕ ОБЪЕКТА ЭЛЕМЕНТА В ПАМЯТп, ЧТОБЫ ПОТОМ пМЕТЬ К НЕМУ ДОСТУП\
- newObj(arg[i][1],arg[i][2],xMenu,xMenu+xSizeOfMenu-1,yStartToDisplay+i-3)\
- \
- --А ЕСЛп ВСЕ-ТАКп ЯВЛЯЕТСЯ, ТО\
- else\
- drawSeparator(xMenu,yStartToDisplay+i-3,xSizeOfMenu)\
- end\
- end\
- end\
- \
- --СТАРТ ПРОГРАММЫ, РпСУЕМ МЕНЮ\
- drawMenu(arg[1],arg[2])\
- \
- --ОТСЛЕЖпВАНпЕ КЛпКА МЫШп\
- local event,side,xClick,yClick = os.pullEvent()\
- if event == \"monitor_touch\" then side = 1 end\
- if event == \"mouse_click\" or event == \"monitor_touch\" then\
- --ПЕРЕБОР ВСЕХ ЭЛЕМЕНТОВ МАССпВА ОБЪЕКТОВ В ПАРЕ СО ЗНАЧЕНпЕМ ЭЛЕМЕНТА (КЛЮЧ = ЗНАЧЕНпЕ, KEY = VAL)\
- for key,val in pairs(Objects) do\
- --ЕСЛп МЫ КЛпКНУЛп НА ОБЪЕКТ, п ЭТОТ ОБЪЕКТ НЕ ЯВЛЯЕТСЯ СКРЫТЫМ, ТО\
- if xClick >= Objects[key][\"xStart\"] and xClick <= Objects[key][\"xEnd\"] and yClick == Objects[key][\"y\"] and Objects[key][\"isHidden\"] == false or xClick >= Objects[key][\"xStart\"] and xClick <= Objects[key][\"xEnd\"] and yClick == Objects[key][\"y\"] and Objects[key][\"isHidden\"] == nil then\
- --НАРпСОВАТЬ ГОЛУБОЕ ВЫДЕЛЕНпЕ ЭЛЕМЕНТА МЕНЮ\
- for i=Objects[key][\"xStart\"],Objects[key][\"xEnd\"] do\
- paintutils.drawPixel(i,Objects[key][\"y\"],colors.blue)\
- end\
- --ОТОБРАЗпТЬ ТОТ ЖЕ ТЕКСТ, ТОЛЬКО БЕЛЫМ ЦВЕТОМ\
- text(xStartToDisplay,Objects[key][\"y\"],key,colors.white)\
- --ЖДАТЬ НЕКОТОРОЕ ВРЕМЯ\
- sleep(0.3)\
- --ВЕРНУТЬ ЗНАЧЕНпЕ KEY (ТО ЕСТЬ ЗНАЧЕНпЕ ВЫБРАННОГО ЭЛЕМЕНТА МЕНЮ) п ЗАВЕШпТЬ ПРОГРАММУ МЕНЮ\
- return key\
- end\
- --А ЕСЛп НпКАКОЙ ЭЛЕМЕНТ МЕНЮ НЕ БЫЛ ВЫБРАН, ТО ФУНКЦпЯ ВЕРНЕТ NIL\
- end\
- end\
- end",
- path = "/rootfs/System/API/context",
- },
- {
- text = "os.loadAPI(\"System/API/config\")\
- \
- local symbols = {\
- \"a\",\
- \"b\",\
- \"c\",\
- \"d\",\
- \"e\",\
- \"f\",\
- \"g\",\
- \"h\",\
- \"i\",\
- \"j\",\
- \"k\",\
- \"l\",\
- \"m\",\
- \"n\",\
- \"o\",\
- \"p\",\
- \"q\",\
- \"r\",\
- \"s\",\
- \"t\",\
- \"u\",\
- \"v\",\
- \"w\",\
- \"x\",\
- \"y\",\
- \"z\",\
- \"0\",\
- \"1\",\
- \"2\",\
- \"3\",\
- \"4\",\
- \"5\",\
- \"6\",\
- \"7\",\
- \"8\",\
- \"9\",\
- }\
- \
- local symbolsFromConfig = {}\
- for i=1,#symbols do\
- symbolsFromConfig[symbols[i]] = config.read(\"System/API/encryptor.cfg\",symbols[i])\
- end\
- \
- local function stringReplace(stroka,chto,nachto)\
- while true do\
- local starting = 1\
- local starting,ending = string.find(stroka,chto,starting)\
- if ending ~= nil then\
- stroka = string.sub(stroka,1,starting-1)..nachto..string.sub(stroka,ending+1,-1)\
- starting = starting + #nachto\
- else\
- break\
- end\
- end\
- return stroka\
- end\
- \
- function code(stroka)\
- local array = {}\
- for i=1,#stroka do\
- array[i] = string.sub(stroka,i,i)\
- for key,val in pairs(symbolsFromConfig) do\
- if array[i] == key then array[i] = val end\
- end\
- end\
- local text = \"\"\
- for i=1,#array do\
- text = text..array[i]\
- end\
- return text\
- end\
- \
- function decode(stroka)\
- for key,val in pairs(symbolsFromConfig) do\
- stroka = stringReplace(stroka,val,key)\
- end\
- return stroka\
- end\
- \
- \
- --[[print(\" \")\
- local cyka = \"hello world! heh kek lol \"\
- print(\"Standart=\"..cyka)\
- print(\" \")\
- local codedcyka = code(cyka)\
- print(\"Coded=\"..codedcyka)\
- print(\" \")\
- local decodedcyka = decode(codedcyka)\
- print(\"Encoded=\"..decodedcyka)\
- print(\" \")]]",
- path = "/rootfs/System/API/encryptor",
- },
- {
- text = "1=eafazf\
- 2=ezffqq\
- 3=ezfvfp\
- 4=eafooz\
- 5=eafaiz\
- 6=ezviio\
- 7=ezvzvi\
- 8=eqfooz\
- 9=eommqo\
- 0=ezivup\
- a=ealajo\
- b=eopxzj\
- c=evmsyo\
- d=ebiiql\
- e=epovuz\
- f=efivmt\
- g=ezvito\
- h=ezlfbh\
- i=eaquat\
- j=etirra\
- k=emorta\
- l=etampl\
- m=enodus\
- n=ezviri\
- o=eponis\
- p=enuihu\
- q=exyupi\
- r=ezdads\
- s=eigurd\
- t=eamati\
- u=ebalro\
- v=etshat\
- w=ealsis\
- x=ekizli\
- y=eltrya\
- z=espopu",
- path = "/rootfs/System/API/encryptor.cfg",
- },
- {
- text = "os.loadAPI(\"System/API/windows\")\
- os.loadAPI(\"System/API/image\")\
- os.loadAPI(\"System/API/context\")\
- \
- local mode = \"open\"\
- local workPath = \"\"\
- local workPathHistory = {}\
- local input = \"\"\
- \
- local xSize,ySize = term.getSize()\
- \
- local managerX = xSize-3\
- local managerY = ySize-1\
- \
- local xStart = 2\
- local yStart = 1\
- local xEnd = xStart+managerX-1\
- local yEnd = yStart+managerY-1\
- \
- local leftBarSize = 14\
- local leftBarLimit = leftBarSize-3\
- \
- local sizeOfInputBar = 26\
- local startOfInputBar = xStart+3\
- local endOfInputBar = startOfInputBar+sizeOfInputBar-1\
- local sizeOfSearchBar = managerX - sizeOfInputBar - 3 - 8 - 1\
- local startOfSearchBar = xEnd-sizeOfSearchBar\
- \
- local xStartOfDrawingApps = xStart+leftBarSize+1\
- local yStartOfDrawingApps = yStart+4\
- local xSizeOfAppsArea = managerX-leftBarSize\
- local ySizeOfAppsArea = managerY-3\
- local xAppSize = 6\
- local yAppSize = 6\
- local xSpaceBetweenApps = 2\
- local ySpaceBetweenApps = 1\
- local countOfAppsByX = math.floor(xSizeOfAppsArea/(xAppSize+xSpaceBetweenApps))\
- local countOfAppsByY = math.floor(ySizeOfAppsArea/(yAppSize+ySpaceBetweenApps))\
- local countOfDesktops = 1\
- \
- local currentDesktop = 1\
- \
- local hideFileFormat = true\
- \
- --local main = window.create(term.native(),xStart,yStart,managerX+1,managerY+1)\
- \
- --------------------ФУНКЦпп--------------------\
- \
- local function clickedAtArea(x,y,sx,sy,ex,ey)\
- if (x >= sx) and (x <= ex) and (y >= sy) and (y <= ey) then return true end \
- return false\
- end\
- \
- local Favourites = {\
- [\"Root\"] = \"\",\
- [\"Applications\"] = \"/Applications\",\
- [\"Documents\"] = \"/Documents\",\
- [\"Images\"] = \"/Images\",\
- [\"rom\"] = \"/rom\",\
- }\
- \
- local function saveConfig()\
- local path = \"System/Filemanager/Favourites.cfg\"\
- local f = fs.open(path,\"w\")\
- f.write(textutils.serialise(Favourites))\
- f.close()\
- end\
- \
- local function loadConfig()\
- local path = \"System/Filemanager/Favourites.cfg\"\
- if fs.exists(path) then\
- local f = fs.open(path,\"r\")\
- local text = f.readAll()\
- Favourites = textutils.unserialise(text)\
- f.close()\
- end\
- end\
- \
- local objects = {}\
- local function newObj(class,name,key,value)\
- objects[class] = objects[class] or {}\
- objects[class][name] = objects[class][name] or {}\
- objects[class][name][key] = value\
- end\
- \
- function drawSeparator(x1,y1,width,height,textColor,backColor,symbol)\
- local string = string.rep(symbol,width)\
- term.setBackgroundColor(backColor)\
- term.setTextColor(textColor)\
- for y=y1,(y1+height-1) do\
- windows.usualText(x1,y,string)\
- end\
- end\
- \
- local function getFoldersList(workPath)\
- \
- end\
- \
- local function drawLeftBar()\
- objects[\"Favourites\"] = {}\
- \
- windows.square(xStart,yStart+3,leftBarSize,yEnd-3,colors.white)\
- \
- local y = yStart+4\
- local Peripherals = peripheral.getNames()\
- drawSeparator(xStart+leftBarSize-1,y-1,1,ySizeOfAppsArea,colors.lightGray,colors.white,\"|\")\
- \
- local sFavourites = 0\
- for key,val in pairs(Favourites) do\
- sFavourites = sFavourites + 1\
- end\
- \
- if sFavourites > 0 then\
- windows.colorText(xStart+1,y,\"Places\",colors.gray)\
- y = y + 1\
- \
- for key,val in pairs(Favourites) do\
- newObj(\"Favourites\",key,\"x1\",xStart)\
- newObj(\"Favourites\",key,\"x2\",xStart+leftBarSize-1)\
- newObj(\"Favourites\",key,\"y1\",y)\
- newObj(\"Favourites\",key,\"path\",Favourites[key])\
- \
- if workPath == Favourites[key] then\
- windows.square(xStart,y,leftBarSize-1,1,colors.blue)\
- windows.colorText(xStart+2,y,windows.stringLimit(\"end\",key,leftBarLimit),colors.white)\
- else\
- windows.square(xStart,y,leftBarSize-1,1,colors.white)\
- windows.colorText(xStart+2,y,windows.stringLimit(\"end\",key,leftBarLimit),colors.lightGray)\
- end\
- \
- y = y + 1\
- end\
- \
- y = y + 1\
- end\
- \
- term.setBackgroundColor(colors.white)\
- if #Peripherals > 0 then\
- windows.colorText(xStart+1,y,\"Peripherals\",colors.gray)\
- y = y + 1\
- for i=1,#Peripherals do\
- windows.colorText(xStart+2,y,windows.stringLimit(\"end\",Peripherals[i],leftBarLimit),colors.lightGray)\
- y = y + 1\
- end\
- end\
- end\
- \
- local function drawTopBar()\
- local posY = yStart + 1\
- windows.square(xStart,yStart,managerX,3,colors.lightGray)\
- windows.square(xStart+3,posY,sizeOfInputBar,1,colors.white)\
- windows.colorText(xStart+3,posY,windows.stringLimit(\"start\",input,sizeOfInputBar),colors.gray)\
- \
- local text = mode\
- windows.colorTextWithBack(math.floor(xStart+managerX/2-#text/2-1),yStart,text,colors.white,colors.lightGray)\
- \
- windows.square(startOfSearchBar,posY,sizeOfSearchBar,1,colors.white)\
- windows.colorText(startOfSearchBar,posY,\"Search\",colors.lightGray)\
- newObj(\"windowControls\",\"search\",\"x1\",startOfSearchBar);newObj(\"windowControls\",\"search\",\"x2\",startOfSearchBar+sizeOfSearchBar-1);newObj(\"windowControls\",\"search\",\"y\",posY)\
- \
- local colorCyka = nil\
- if #workPathHistory == 0 then colorCyka = colors.lightGray else colorCyka = colors.black end\
- windows.colorTextWithBack(xStart+1,posY,\"<\",colorCyka,colors.white)\
- \
- local posX = startOfSearchBar - 7\
- windows.colorTextWithBack(posX,posY,\" \"..mode..\" \",colors.white,colors.lightBlue)\
- newObj(\"windowControls\",\"ok\",\"x1\",posX);newObj(\"windowControls\",\"ok\",\"x2\",posX+5);newObj(\"windowControls\",\"ok\",\"y\",posY)\
- end\
- \
- local function drawWindow()\
- windows.square(xStart,yStart+3,managerX,ySizeOfAppsArea,colors.white)\
- drawTopBar()\
- --DRAW SHADOW\
- for x=(xStart+1),(xStart+managerX) do\
- paintutils.drawPixel(x,yStart+managerY,colors.gray)\
- end\
- for y=(yStart+1),(yStart+managerY) do\
- paintutils.drawPixel(xStart+managerX,y,colors.gray)\
- end\
- end\
- \
- ------------------------------------------------------------------------------------------------------\
- \
- local function drawKonkretnoApp(x,y,name,backColor)\
- --СОЗДАНпЕ ОБЪЕКТА ПРпЛОЖЕНпЯ\
- newObj(\"apps\",name,\"x1\",x)\
- newObj(\"apps\",name,\"x2\",x+xAppSize-1)\
- newObj(\"apps\",name,\"y1\",y)\
- newObj(\"apps\",name,\"y2\",y+yAppSize-1)\
- newObj(\"apps\",name,\"fileFormat\",windows.getFileFormat(name))\
- \
- --РпСОВАНпЕ пКОНКп\
- windows.drawOSIcon(x,y,workPath,name,objects[\"apps\"][name][\"fileFormat\"])\
- \
- --ОТРпСОВКА пМЕНп ПРпЛОЖЕНпЯ\
- term.setBackgroundColor(backColor)\
- if fs.isReadOnly(workPath..\"/\"..name) then\
- term.setTextColor(colors.red)\
- else\
- term.setTextColor(colors.black)\
- end\
- if windows.isFileHidden(name) then\
- term.setTextColor(colors.gray)\
- end\
- if hideFileFormat then\
- name = windows.hideFileFormat(name)\
- end\
- name = windows.stringLimit(\"end\",name,xAppSize,true)\
- windows.usualText(math.floor(x+xAppSize/2-#name/2),y+yAppSize-1,name)\
- end\
- \
- local function drawApps(x,y,currentDesktop)\
- \
- objects[\"apps\"] = {}\
- \
- windows.square(x,y,xSizeOfAppsArea-2,ySizeOfAppsArea-2,colors.white)\
- \
- local fileList = fs.list(workPath)\
- fileList = windows.reorganizeFilesAndFolders(workPath,fileList,true,true)\
- \
- countOfDesktops = math.ceil(#fileList/(countOfAppsByY*countOfAppsByX))\
- local appCounter = 1 + currentDesktop * countOfAppsByY * countOfAppsByX - countOfAppsByY * countOfAppsByX\
- \
- for j=1,countOfAppsByY do\
- for i=1,countOfAppsByX do\
- if fileList[appCounter] then\
- drawKonkretnoApp(x+i*(xAppSize+xSpaceBetweenApps)-(xAppSize+xSpaceBetweenApps),y+j*(yAppSize+ySpaceBetweenApps)-(yAppSize+ySpaceBetweenApps),fileList[appCounter],colors.white)\
- appCounter = appCounter + 1\
- else\
- break\
- end\
- end\
- end\
- end\
- \
- ------------------------------------------------------------------------------------------------------\
- \
- local function drawManager(x,y)\
- \
- if x~=nil or y~=nil then\
- xStart = x\
- yStart = y\
- xStartOfDrawingApps = xStart+leftBarSize+1\
- yStartOfDrawingApps = yStart+4\
- end\
- \
- currentDesktop = 1\
- --windows.emptyWindow(xStart,yStart,managerX,managerY,fs.getName(workPath))\
- drawWindow()\
- --windows.colorTextWithBack(xStart,yStart,\"x\",colors.black,colors.red);windows.colorTextWithBack(xStart+1,yStart,\"-\",colors.black,colors.orange);windows.colorTextWithBack(xStart+2,yStart,\"+\",colors.black,colors.lime)\
- drawLeftBar()\
- drawApps(xStartOfDrawingApps,yStartOfDrawingApps,currentDesktop)\
- windows.scrollBar(xEnd,yStart+3,managerY-3,countOfDesktops,currentDesktop,colors.lightGray,colors.lightBlue)\
- end\
- \
- newObj(\"windowControls\",\"<\",\"x\",xStart+1);newObj(\"windowControls\",\"<\",\"y\",yStart+1)\
- \
- local function initializeProgram(mode1)\
- if mode1==\"open\" then mode = \"Open\" else mode = \"Save\" end\
- \
- loadConfig()\
- saveConfig()\
- \
- input = \"/\"..workPath\
- drawManager()\
- \
- local exit = false\
- while true do\
- \
- local breakCycles = false\
- \
- if exit then break end\
- \
- local event,side,x,y = os.pullEvent()\
- if event == \"mouse_click\" then\
- \
- for key,val in pairs(objects[\"Favourites\"]) do\
- if breakCycles then break end\
- \
- if clickedAtArea(x,y,objects[\"Favourites\"][key][\"x1\"],objects[\"Favourites\"][key][\"y1\"],objects[\"Favourites\"][key][\"x2\"],objects[\"Favourites\"][key][\"y1\"]) then\
- \
- if side == 1 then \
- if not fs.exists(objects[\"Favourites\"][key][\"path\"]) then fs.makeDir(key) end\
- workPathHistory[#workPathHistory+1] = workPath\
- workPath = objects[\"Favourites\"][key][\"path\"]\
- input = \"/\"..workPath\
- drawManager()\
- else\
- windows.square(xStart,objects[\"Favourites\"][key][\"y1\"],leftBarSize-1,1,colors.lightGray)\
- windows.colorText(xStart+2,objects[\"Favourites\"][key][\"y1\"],windows.stringLimit(\"end\",key,leftBarLimit),colors.white)\
- --sleep(0.2)\
- \
- local action = context.menu(x,y,{\"Remove from sidebar\"})\
- if action == \"Remove from sidebar\" then\
- \
- Favourites[key] = nil\
- saveConfig()\
- \
- end\
- drawManager()\
- end\
- \
- breakCycles = true\
- break\
- end\
- end\
- \
- \
- \
- for key,val in pairs(objects[\"apps\"]) do\
- if breakCycles then break end\
- if clickedAtArea(x,y,objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],objects[\"apps\"][key][\"x2\"],objects[\"apps\"][key][\"y2\"]) then\
- \
- if side == 1 then\
- if fs.isDir(workPath..\"/\"..key) and windows.getFileFormat(key) ~= \".app\" then\
- windows.square(objects[\"apps\"][key][\"x1\"]-1,objects[\"apps\"][key][\"y1\"],xAppSize+2,yAppSize,colors.blue)\
- drawKonkretnoApp(objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],key,colors.blue)\
- sleep(0.2)\
- workPathHistory[#workPathHistory+1] = workPath\
- workPath = workPath..\"/\"..key\
- input = \"/\"..workPath\
- drawManager()\
- elseif not fs.isDir(workPath..\"/\"..key) and mode == \"Save\" then\
- windows.square(objects[\"apps\"][key][\"x1\"]-1,objects[\"apps\"][key][\"y1\"],xAppSize+2,yAppSize,colors.red)\
- drawKonkretnoApp(objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],key,colors.red)\
- sleep(0.2)\
- windows.square(objects[\"apps\"][key][\"x1\"]-1,objects[\"apps\"][key][\"y1\"],xAppSize+2,yAppSize,colors.white)\
- drawKonkretnoApp(objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],key,colors.white)\
- elseif not fs.isDir(workPath..\"/\"..key) and mode ~= \"Save\" or fs.isDir(workPath..\"/\"..key) and windows.getFileFormat(key) == \".app\" and mode ~= \"Save\" then\
- windows.square(objects[\"apps\"][key][\"x1\"]-1,objects[\"apps\"][key][\"y1\"],xAppSize+2,yAppSize,colors.blue)\
- drawKonkretnoApp(objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],key,colors.blue)\
- sleep(0.2)\
- windows.square(objects[\"apps\"][key][\"x1\"]-1,objects[\"apps\"][key][\"y1\"],xAppSize+2,yAppSize,colors.white)\
- drawKonkretnoApp(objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],key,colors.white)\
- input = \"/\"..workPath..\"/\"..key\
- drawTopBar()\
- end\
- else\
- if fs.isDir(workPath..\"/\"..key) then\
- windows.square(objects[\"apps\"][key][\"x1\"]-1,objects[\"apps\"][key][\"y1\"],xAppSize+2,yAppSize,colors.lightGray)\
- drawKonkretnoApp(objects[\"apps\"][key][\"x1\"],objects[\"apps\"][key][\"y1\"],key,colors.lightGray)\
- \
- local action = context.menu(x,y,{\"Add to sidebar\"})\
- if action == \"Add to sidebar\" then\
- \
- Favourites[key] = workPath..\"/\"..key\
- saveConfig()\
- \
- end\
- drawManager()\
- end\
- end\
- \
- breakCycles = true\
- break\
- end \
- end\
- \
- if clickedAtArea(x,y,objects[\"windowControls\"][\"<\"][\"x\"],objects[\"windowControls\"][\"<\"][\"y\"],objects[\"windowControls\"][\"<\"][\"x\"],objects[\"windowControls\"][\"<\"][\"y\"]) then\
- if #workPathHistory > 0 then\
- windows.colorTextWithBack(objects[\"windowControls\"][\"<\"][\"x\"],objects[\"windowControls\"][\"<\"][\"y\"],\"<\",colors.white,colors.blue)\
- sleep(0.2)\
- workPath = workPathHistory[#workPathHistory]\
- input = \"/\"..workPath\
- workPathHistory[#workPathHistory] = nil\
- drawManager()\
- end\
- elseif clickedAtArea(x,y,objects[\"windowControls\"][\"ok\"][\"x1\"],objects[\"windowControls\"][\"ok\"][\"y\"],objects[\"windowControls\"][\"ok\"][\"x2\"],objects[\"windowControls\"][\"ok\"][\"y\"]) then\
- windows.colorTextWithBack(objects[\"windowControls\"][\"ok\"][\"x1\"],objects[\"windowControls\"][\"ok\"][\"y\"],\" \"..mode..\" \",colors.white,colors.blue)\
- sleep(0.3)\
- return string.sub(input,2,-1)\
- elseif clickedAtArea(x,y,objects[\"windowControls\"][\"search\"][\"x1\"],objects[\"windowControls\"][\"search\"][\"y\"],objects[\"windowControls\"][\"search\"][\"x2\"],objects[\"windowControls\"][\"search\"][\"y\"]) then\
- local searchResult = windows.search(xEnd-27,yStart,28,2,\"Search\")\
- if searchResult ~= nil then\
- --windows.error(\"=\"..searchResult)\
- if fs.isDir(searchResult) then\
- workPathHistory[#workPathHistory+1] = workPath\
- workPath = searchResult\
- input = \"/\"..workPath\
- else\
- workPathHistory[#workPathHistory+1] = workPath\
- workPath = string.sub(searchResult,1,#searchResult-#fs.getName(searchResult)-1)\
- input = \"/\"..workPath..\"/\"..fs.getName(searchResult)\
- end\
- end\
- drawManager()\
- \
- elseif clickedAtArea(x,y,startOfInputBar,yStart+1,endOfInputBar,yStart+1) and mode ~= \"Open\" then\
- \
- local cursor = nil\
- \
- input = input..\"/\"\
- drawTopBar()\
- \
- local accept = false\
- \
- while true do\
- \
- cursor = startOfInputBar+#input\
- if cursor > startOfInputBar+sizeOfInputBar then cursor = startOfInputBar+sizeOfInputBar-1 end\
- \
- term.setCursorPos(cursor,yStart+1)\
- term.setTextColor(colors.black)\
- term.setCursorBlink(true)\
- \
- local event1,side1,x1,y1 = os.pullEvent()\
- if event1 == \"char\" then\
- \
- input = input..side1\
- drawTopBar()\
- elseif event1 == \"key\" then\
- if side1 == 28 then\
- windows.colorTextWithBack(objects[\"windowControls\"][\"ok\"][\"x1\"],objects[\"windowControls\"][\"ok\"][\"y\"],\" \"..mode..\" \",colors.white,colors.blue)\
- sleep(0.3)\
- accept = true\
- break\
- elseif side1 == 14 then\
- if #input > 1 then\
- input = string.sub(input,1,-2)\
- drawTopBar()\
- end\
- \
- end\
- elseif event1 == \"mouse_click\" then\
- if clickedAtArea(x1,y1,objects[\"windowControls\"][\"ok\"][\"x1\"],objects[\"windowControls\"][\"ok\"][\"y\"],objects[\"windowControls\"][\"ok\"][\"x2\"],objects[\"windowControls\"][\"ok\"][\"y\"]) then\
- accept = true\
- drawTopBar()\
- else\
- drawTopBar()\
- break\
- end\
- end\
- \
- term.setCursorBlink(false)\
- end\
- \
- term.setCursorBlink(false)\
- \
- if accept then return string.sub(input,2,-1) end\
- \
- end\
- \
- elseif event == \"mouse_scroll\" then\
- if clickedAtArea(x,y,xStart+leftBarSize,yStart+1,xEnd-1,yEnd) then\
- if side == 1 then\
- currentDesktop = currentDesktop + 1\
- if currentDesktop > countOfDesktops then\
- currentDesktop = countOfDesktops\
- else\
- drawApps(xStartOfDrawingApps,yStartOfDrawingApps,currentDesktop)\
- windows.scrollBar(xEnd,yStart+3,managerY-3,countOfDesktops,currentDesktop,colors.lightGray,colors.lightBlue)\
- end\
- else\
- currentDesktop = currentDesktop - 1\
- if currentDesktop < 1 then\
- currentDesktop = 1\
- else\
- drawApps(xStartOfDrawingApps,yStartOfDrawingApps,currentDesktop)\
- windows.scrollBar(xEnd,yStart+3,managerY-3,countOfDesktops,currentDesktop,colors.lightGray,colors.lightBlue)\
- end\
- end\
- end\
- elseif event == \"key\" then\
- if side == 28 then\
- return string.sub(input,2,-1)\
- end\
- end\
- end\
- \
- end\
- \
- function open(cykaWorkPath)\
- if cykaWorkPath then workPath = cykaWorkPath end\
- \
- for i=(1-managerY),1,2 do\
- drawManager(2,i)\
- sleep(0)\
- end\
- \
- return initializeProgram(\"open\")\
- end\
- \
- function save(cykaWorkPath)\
- if cykaWorkPath then workPath = cykaWorkPath end\
- \
- for i=(1-managerY),1,2 do\
- drawManager(2,i)\
- sleep(0)\
- end\
- \
- return initializeProgram(\"save\")\
- end\
- \
- -------------------------------------\
- \
- --[[windows.clearScreen(colors.black)\
- \
- local path = open(\"\")\
- \
- term.setTextColor(colors.white)\
- windows.clearScreen(colors.black)\
- if path == \"\" then\
- windows.usualText(2,2,\"NIL!!\")\
- else\
- windows.usualText(2,2,\"Path=\"..path)\
- end]]",
- path = "/rootfs/System/API/filemanager",
- },
- {
- text = "function draw(startX,startY,image)\
- local Colors = {\
- [\"0\"] = 1,\
- [\"1\"] = 2,\
- [\"2\"] = 4,\
- [\"3\"] = 8,\
- [\"4\"] = 16,\
- [\"5\"] = 32,\
- [\"6\"] = 64,\
- [\"7\"] = 128,\
- [\"8\"] = 256,\
- [\"9\"] = 512,\
- [\"a\"] = 1024,\
- [\"b\"] = 2048,\
- [\"c\"] = 4096,\
- [\"d\"] = 8192,\
- [\"e\"] = 16384,\
- [\"f\"] = 32768\
- }\
- local Pixels = {}\
- \
- local function convert(mode,color)\
- if mode == \"from cc\" then\
- for key,value in pairs(Colors) do\
- if color == value then\
- return key\
- end\
- end\
- else\
- if color == \"#\" then\
- return \"0\"\
- else\
- return Colors[color]\
- end\
- end\
- end\
- \
- local function load(path)\
- local file = fs.open(path,\"r\")\
- local lineCounter = 1\
- while true do\
- local line = file.readLine()\
- Pixels[lineCounter]={}\
- if line ~= nil then\
- for i=1,#line,3 do\
- Pixels[lineCounter][(i+2)/3]={}\
- Pixels[lineCounter][(i+2)/3][\"symbol\"] = string.sub(line,i,i)\
- Pixels[lineCounter][(i+2)/3][\"textColor\"] = convert(\"to cc\",string.sub(line,i+1,i+1))\
- Pixels[lineCounter][(i+2)/3][\"backColor\"] = convert(\"to cc\",string.sub(line,i+2,i+2))\
- end\
- lineCounter = lineCounter + 1\
- else\
- break\
- end\
- end\
- file.close()\
- end\
- \
- load(image)\
- \
- for y=1,#Pixels do\
- for x=1,#Pixels[y] do\
- if Pixels[y][x][\"symbol\"] ~= \"#\" then\
- term.setTextColor(Pixels[y][x][\"textColor\"])\
- term.setBackgroundColor(Pixels[y][x][\"backColor\"])\
- term.setCursorPos(startX+x-1,startY+y-1)\
- term.write(Pixels[y][x][\"symbol\"])\
- end\
- end\
- end\
- \
- end",
- path = "/rootfs/System/API/image",
- },
- {
- text = "os.loadAPI(\"System/API/config\")\
- \
- local Colors = {\
- [\"text\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"text\")),\
- [\"commands\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"commands\")),\
- [\"api\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"api\")),\
- [\"string\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"string\")),\
- [\"comments\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"comments\")),\
- [\"compares\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"compares\")),\
- [\"loops\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"basics\")),\
- [\"boolean\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"boolean\")),\
- [\"number\"] = tonumber(config.read(\"System/MineCode/syntax_colors.cfg\",\"number\")),\
- }\
- \
- local KeyWords = {\
- {[\"pattern\"]=\"for\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"while\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"true\", [\"color\"]=Colors[\"boolean\"]},\
- {[\"pattern\"]=\"false\", [\"color\"]=Colors[\"boolean\"]},\
- {[\"pattern\"]=\"if\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"then\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"else\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"elseif\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"do\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"break\", [\"color\"]=colors.red},\
- {[\"pattern\"]=\"function\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"and\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"not\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"or\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"in\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"until\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"return\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"repeat\", [\"color\"]=Colors[\"loops\"]},\
- {[\"pattern\"]=\"nil\", [\"color\"]=Colors[\"boolean\"]},\
- {[\"pattern\"]=\"local\", [\"color\"]=Colors[\"loops\"]},\
- }\
- \
- local Compares = {\
- \"=\",\
- \"==\",\
- \"~=\",\
- \">\",\
- \"<\",\
- \">=\",\
- \"<=\",\
- \"+\",\
- \"-\",\
- \"*\",\
- \"/\",\
- \"%^\",\
- \"%.%.\",\
- \"%#\",\
- }\
- \
- local sKeyWords = #KeyWords\
- local sCompares = #Compares\
- \
- --Окрашивание текста по шаблону\
- local function findAndReplace(x,y,text,pattern,color,obrezatSleva,obrezatSprava,vichestIzStartaPoiska)\
- local findPos = 1\
- while true do\
- local s,e = string.find(text,pattern,findPos)\
- if s ~= nil and e ~= nil then\
- term.setTextColor(color)\
- term.setCursorPos(1-x+s+obrezatSleva,y)\
- term.write(string.sub(text,s+obrezatSleva,e-obrezatSprava))\
- else\
- break\
- end\
- findPos = e + 1 - vichestIzStartaPoiska\
- end\
- end\
- \
- --Подсветка всех ключевых слов\
- function highlight(x,y,text)\
- --Пишем сначала обычную белую строку\
- term.setTextColor(Colors[\"text\"])\
- term.setCursorPos(x,y)\
- term.write(text)\
- \
- --Красим в цвета всю хуйню из массива. Пока что надо доработать\
- for i=1,sKeyWords do\
- findAndReplace(x,y,text,\" \"..KeyWords[i][\"pattern\"]..\" \",KeyWords[i][\"color\"],0,0,0)\
- findAndReplace(x,y,text,\" \"..KeyWords[i][\"pattern\"]..\"$\",KeyWords[i][\"color\"],0,0,0)\
- findAndReplace(x,y,text,\"^\"..KeyWords[i][\"pattern\"]..\" \",KeyWords[i][\"color\"],0,0,0)\
- end\
- \
- --Красим функции\
- findAndReplace(x,y,text,\"[%a%d%_%-]*%(\",Colors[\"commands\"],0,1,0)\
- findAndReplace(x,y,text,\"%.(.*)%(\",Colors[\"commands\"],1,1,0)\
- \
- --Красим вызов АПп\
- findAndReplace(x,y,text,\"os%.loadAPI%(\",Colors[\"api\"],0,1,0) \
- \
- --Красим END, если он заканчивает строку\
- findAndReplace(x,y,text,\"end$\",Colors[\"loops\"],0,0,0) \
- \
- --Красим красным всякие сравнивалки типа =, ==, >= и т.п.\
- for i=1,sCompares do\
- findAndReplace(x,y,text,\" \"..Compares[i]..\" \",Colors[\"compares\"],0,0,0)\
- findAndReplace(x,y,text,\"(.)\"..Compares[i]..\"(.)\",Colors[\"compares\"],1,1,0)\
- findAndReplace(x,y,text,\"(.)\"..Compares[i],Colors[\"compares\"],1,0,0)\
- findAndReplace(x,y,text,Compares[i]..\"(.)\",Colors[\"compares\"],0,1,0)\
- end\
- \
- --КРАСпМ ЦпВФРЫ\
- findAndReplace(x,y,text,\"[^%a%d](%d*)[^%a%d]\",Colors[\"number\"],1,1,1)\
- findAndReplace(x,y,text,\"[^%a%d](%d*)$\",Colors[\"number\"],1,0,0)\
- \
- --Красим красным текст в кавычках\
- findAndReplace(x,y,text,\"\\\".-[^\\\"\\\"]\\\"\",Colors[\"string\"],0,0,0)\
- \
- --Красим зеленым комментарии\
- findAndReplace(x,y,text,\"%-%-.*\",Colors[\"comments\"],0,0,0)\
- \
- end\
- \
- \
- ------------------------------------------------------------------------------------------------------------------\
- \
- \
- --[[term.setBackgroundColor(colors.white)\
- term.setTextColor(colors.black)\
- term.setCursorPos(1,1)\
- term.clear()\
- \
- local strings = {\
- \"os.loadAPI(123)\",\
- \"term.setCursorPos(1,1)\",\
- \"while true do\",\
- \" if x >= 12 then\",\
- \" break\",\
- \" end\",\
- \"end\",\
- \" \",\
- \"local function hehe(heh123, 123)\",\
- \" print(heh123)\",\
- \"end\",\
- \" \",\
- \"print(\\\"Pruf Piru, chto ono ne laget\\\"..123..\\\"hehe\\\")\",\
- \"term.clear()\",\
- \"local input = cyka()\",\
- \" \",\
- \"--Comment, bitch!\",\
- }\
- \
- \
- local try = 1\
- while true do\
- term.clear()\
- highlight(1,1,\"Popitka napisaniya: \"..try)\
- \
- for i=1,#strings do\
- highlight(1,i+2,strings[i])\
- end\
- \
- sleep(0.1)\
- try = try + 1\
- end]]\
- \
- \
- --[[print(\"Write something:\")\
- \
- local stro4ka = \"\"\
- local CursorPosX = 1\
- local CursorPosY = 3\
- term.setCursorBlink(true)\
- while true do\
- term.setCursorPos(CursorPosX,CursorPosY)\
- local event,side = os.pullEvent()\
- if event == \"char\" then\
- stro4ka = stro4ka..side\
- CursorPosX = CursorPosX + 1\
- highlight(1,CursorPosY,stro4ka)\
- elseif event == \"key\" then\
- if side == 28 then\
- stro4ka = \"\"\
- CursorPosX = 1\
- CursorPosY = CursorPosY + 1\
- elseif side == 14 then\
- if #stro4ka > 0 then\
- highlight(1,CursorPosY,string.rep(\" \",#stro4ka))\
- stro4ka = string.sub(stro4ka,1,-2)\
- highlight(1,CursorPosY,stro4ka)\
- CursorPosX = CursorPosX - 1\
- end\
- end\
- end\
- end\
- \
- os.pullEvent(\"key\")]]",
- path = "/rootfs/System/API/syntax",
- },
- {
- text = "\
- -------------------------ГРАФпКА---------------------------------------------------------------------------------------------------\
- \
- -- colorText(int х_начала, int y_начала, string текст, int цвет_текста)\
- -- Отрисовка цветного текста по заданным координатам. Цвет фона остается тем же.\
- \
- \
- -- usualText(int х_начала, int y_начала, string текст)\
- -- Отрисовка обычного текста по заданным координатам.\
- \
- \
- -- square(int x_начала, int x_конца, int ширина, int высота, int цвет)\
- -- Оптимизированная отрисовка квадрата на экране (быстрее, чем стандартная КК). Подходит также для линий.\
- \
- \
- -- clearScreen(int цвет)\
- -- Заливка всего экрана выбранным цветом.\
- \
- \
- -- fadeIn(int скорость)\
- -- fadeOut(int скорость)\
- -- Плавное зажигание и угасание экрана с белого на черный и наоборот. Скорость лучше ставить на 0.\
- \
- \
- -- tv(int скорость)\
- -- Угасание экрана в стилистике старых телевизоров. Скорость лучше ставить на 0.\
- \
- \
- -- emptyWindow(int х_начала, int y_начала, int ширина, int высота, string заголовок)\
- -- Отрисовка белого окошка с тенью и заголовком вверху.\
- \
- \
- -- sampleWindow(int х_начала, int y_начала, int ширина, int высота)\
- -- Отрисовка того же окошка, но без заголовка.\
- \
- \
- -- drawProgressBar(int х_начала, int y_начала, int ширина, int высота, int цвет_передней_области, int цвет_задней_области, int процент_заполненности_шкалы)\
- -- Отрисовка шкалы прогресса с указанным процентом заполненности.\
- \
- \
- -- scrollBar(int х_начала, int y_начала, int размер_шкалы_по_высоте, int количество_всех_элементов, int текущий_элемент, int цвет_задней_области, int цвет_передней_области)\
- -- Отрисовка вертикальной шкалы прокрутки.\
- -- Количеством элементов тут является, к примеру, количество файлов в директории.\
- -- Таким образом, если количеством элементов у нас будет 100, а текущим элементом будет число 50,\
- -- то ползунок шкалы отобразится примерно по центру самой шкалы.\
- \
- -------------------------ОТРпСОВКА ОКОН-------------------------------------------------------------------------------------\
- \
- -- error(string текст_ошибки)\
- -- Отображение окна ошибки по центру экрана.\
- \
- \
- -- attention(table текст_заголовка, table текст_подзаголовка)\
- -- Отображение окна \"Внимание!\" с какой-то информацией.\
- -- Каждый элемент массива - это строка заголовка или подзаголовка, а количество строк не ограничено.\
- -- \
- -- Пример использования: attention({\"Hey!\",\"This is attention window!\"},{\"And this is information!\"})\
- \
- \
- -- input(int x_начала, int y_начала, string заголовок_окна , int ширина_окна, table поле_ввода1, table поле_ввода2 ... table поле_вводаN)\
- -- Вызывает окно с полями ввода текста.\
- -- Каждое поле - это массив вида {string название_поля, string информация_уже_записанная_в_поле}\
- -- После заполнения всех полей с клавиатуры, функция возвращает массив с введенными данными.\
- --\
- -- Если x_начала или y_начала будет равен \"auto\", то соответствующая координата\
- -- будет рассчитана автоматически и окно расположится по центру экрана по этой координате.\
- --\
- -- Пример использования: myData = input(\"auto\",\"auto\",\"Login\",20,{\"Username\",\"\"},{\"Password\",\"\"})\
- -- Если мы введем в поле Username \"Igor\", а в поле Password \"12345\",\
- -- то функция вовзратит массив вида {\"Igor\",\"12345\"}\
- --\
- -- К слову, в поле можно вставлять данные с помощью ctrl+v\
- \
- \
- -- select(table заголовок, table подзаголовок, table кнопка1, table кнопка2 ... table кнопкаN)\
- -- Функция вызывает окно с текстом и кнопками выбора. \
- --\
- -- Структура массива заголовка и подзаголовка: {string текст1, string текст2 ... string текстN}\
- -- Структура массива кнопки: {string имя_кнопки, int цвет_кнопки, int цвет_текста_кнопки}\
- --\
- -- При нажатии на кнопку функция возвращает имя нажатой кнопки.\
- --\
- -- Пример использования: pressedButton = windows.select({\"Hello!\"},{\"Do you want to load OS\",\"when computer starts?\"},{\"No\",colors.lightGray,colors.black},{\"Yes\",colors.lightBlue,colors.black})\
- \
- \
- -- aboutFile(int х_начала, int y_начала, int ширина_окна, string путь_к_файлу)\
- -- Наглядно отображает информацию о файле в красивом окошке.\
- -- Координаты корректируются автоматически.\
- \
- \
- -- progressBar(int х_начала, int y_начала, int ширина_окна, string заголовок, string информация, int скорость)\
- -- Функция отрисовывает окно с информацией и имитирует продолжительный процесс, рисуя шкалу прогресса.\
- \
- \
- -- search(int х_начала, int y_начала, int ширина_окна, int количество_элементов_по_высоте, string текст_для_поиска)\
- -- Функция рисует красивое окошка поиска по файловой системе.\
- -- Также отображается информация о файлах.\
- -- При вводе любой информации начинается поиск совпадений с именами файлов.\
- -- К регистру букв не чувствительна.\
- -- После выбора любого найденного элемента с помощью мыши, функция вовзращает путь к выбранному файлу.\
- \
- -------------------------РАБОТА С ФАЙЛАМп-------------------------------------------------------------------------------------\
- \
- -- getFileFormat(string путь_к_файлу)\
- -- Функция возвращает расширение файла по типу .zip, .app и прочие. Если расширение отсутствует, возвращает nil.\
- \
- -- hideFileFormat(string путь_к_файлу)\
- -- Если файл имеет расширение, то функция возвращает имя файла без этого расширения. Если расширения нет, возвращается то же имя.\
- \
- -- isFileHidden(string путь_к_файлу)\
- -- Если в начале имени файла есть символ \".\", то функция возвращает true. Если нет, то false.\
- \
- -- getFileSize(string путь_к_файлу)\
- -- Функция возвращает суммарный размер всех файлов в указанном пути. В том числе и размер подфайлов и поддиректорий.\
- \
- -- getFileType(string путь_к_файлу)\
- -- Функция возвращает тип файла. Например, если расширение файла .zip, то его тип - Application.\
- \
- -- stringLimit(string режим, string строка, int ограничение_строки)\
- -- Ограничитель строки с двумя режимами работы. Вот примеры:\
- --\
- -- local s = \"HelloWorldBitches!\"\
- -- print(stringLimit(\"start\", s, 10))\
- -- print(stringLimit(\"end\", s, 10))\
- --\
- -- На экране будет отображено:\
- -- ...itches!\
- -- HelloWo...\
- \
- -----------------------------------------------------------------------------------------------------------------------------------\
- \
- \
- local xSize,ySize = term.getSize()\
- local centerX,centerY = math.floor(xSize/2),math.floor(ySize/2)\
- \
- --ПОпСК ПЕРпФЕРпп\
- function findPeripheral(whatToFind)\
- local PeriList = peripheral.getNames()\
- for i=1,#PeriList do\
- if peripheral.getType(PeriList[i]) == whatToFind then\
- return PeriList[i]\
- end\
- end\
- end\
- \
- --ПОпСК БЕСПРОВОДНОГО МОДЕМА\
- function findWirelessModem()\
- local periList = peripheral.getNames()\
- for i=1,#periList do\
- if peripheral.getType(periList[i]) == \"modem\" then\
- local govno = peripheral.wrap(periList[i])\
- if govno.isWireless() then\
- return periList[i]\
- end\
- end\
- end\
- end\
- \
- --КЛпКНУЛп Лп В ЗОНУ\
- function clickedAtArea(x,y,sx,sy,ex,ey)\
- if (x >= sx) and (x <= ex) and (y >= sy) and (y <= ey) then return true end \
- return false\
- end\
- \
- --В БУЛпН, ЕПТЫ БЛЯ\
- function toboolean(s)\
- if s == \"true\" then\
- return true\
- else\
- return false\
- end\
- end\
- \
- --ЦВЕТНОЙ ТЕКСТ\
- function colorText(x,y,text,textColor)\
- term.setTextColor(textColor)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- --ЦВЕТНОЙ ТЕКСТ С ФОНОМ\
- function colorTextWithBack(x,y,text,textColor,backColor)\
- term.setTextColor(textColor)\
- term.setBackgroundColor(backColor)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- --ПРОСТОЕ ОТОБРАЖЕНпЕ ТЕКСТА ПО КООРДпНАТАМ\
- function usualText(x,y,text)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- --УНпВЕРСАЛЬНАЯ ФУНКЦпЯ ДЛЯ ОТОБРАЖЕНпЯ ТЕКСТА ПО ЦЕНТРУ ЭКРАНА\
- 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\
- \
- --РпСОВАНпЕ КВАДРАТА С ЗАЛпВКОЙ\
- function square(x1,y1,width,height,color)\
- local string = string.rep(\" \",width)\
- term.setBackgroundColor(color)\
- for y=y1,(y1+height-1) do\
- usualText(x1,y,string)\
- end\
- end\
- \
- --РпСОВАНпЕ КРУГА\
- function circle(cx, cy, radius, char, backColor, textColor)\
- local x = radius\
- local y = 0\
- local radiusError = 1 - x\
- term.setTextColor(textColor)\
- term.setBackgroundColor(backColor)\
- while (x >= y) do\
- usualText(x + cx, y + cy, char)\
- usualText(y + cx, x + cy, char)\
- usualText(-x + cx, y + cy, char)\
- usualText(-y + cx, x + cy, char)\
- usualText(-x + cx, -y + cy, char)\
- usualText(-y + cx, -x + cy, char)\
- usualText(x + cx, -y + cy, char)\
- usualText(y + cx, -x + cy, char)\
- y = y + 1\
- if (radiusError < 0) then\
- radiusError = radiusError + (2 * y + 1)\
- else\
- x = x - 1\
- radiusError = radiusError + (2 * (y - x + 1))\
- end\
- end\
- end\
- \
- --ЗАЛпВКА ЭКРАНА ЦВЕТОМ\
- function clearScreen(color)\
- term.setBackgroundColor(color)\
- term.clear()\
- end\
- \
- --ПЛАВНОЕ ВКЛЮЧЕНпЕ ЭКРАНА\
- function fadeIn(time)\
- clearScreen(colors.gray)\
- sleep(time)\
- clearScreen(colors.lightGray)\
- sleep(time)\
- clearScreen(colors.white)\
- sleep(time)\
- end\
- \
- --ПЛАВНОЕ ЗАТУХАНпЕ ЭКРАНА\
- function fadeOut(time)\
- clearScreen(colors.lightGray)\
- sleep(time)\
- clearScreen(colors.gray)\
- sleep(time)\
- clearScreen(colors.black)\
- sleep(time)\
- term.setCursorPos(1,1)\
- term.setTextColor(colors.white)\
- end\
- \
- --ПРОСТОЕ ОКНО С ПОЛОСКОЙ НАВЕРХУ\
- function emptyWindow(xStart,yStart,xWindowSize,yWindowSize,title)\
- --DRAW WINDOW\
- square(xStart,yStart,xWindowSize,1,colors.lightGray)\
- colorText(math.floor(xStart+xWindowSize/2-#title/2),yStart,title,colors.white)\
- \
- square(xStart,yStart+1,xWindowSize,yWindowSize-1,colors.white)\
- \
- --DRAW SHADOW\
- for x=(xStart+1),(xStart+xWindowSize) do\
- paintutils.drawPixel(x,yStart+yWindowSize,colors.gray)\
- end\
- for y=(yStart+1),(yStart+yWindowSize) do\
- paintutils.drawPixel(xStart+xWindowSize,y,colors.gray)\
- end\
- end\
- \
- --ПРОСТОЕ ОКНО БЕЗ ПОЛОСКп\
- function sampleWindow(xStart,yStart,xWindowSize,yWindowSize)\
- square(xStart,yStart,xWindowSize,yWindowSize,colors.white)\
- --DRAW SHADOW\
- for x=(xStart+1),(xStart+xWindowSize) do\
- paintutils.drawPixel(x,yStart+yWindowSize,colors.gray)\
- end\
- for y=(yStart+1),(yStart+yWindowSize) do\
- paintutils.drawPixel(xStart+xWindowSize,y,colors.gray)\
- end\
- end\
- \
- --ОГРАНпЧЕНпЕ ДЛпНЫ СТРОКп\
- function stringLimit(mode,text,size,noDots)\
- if string.len(text)<=size then return text end\
- if mode == \"start\" then\
- if noDots then\
- return string.sub(text,#text-size+1,-1)\
- else\
- return \"...\"..string.sub(text,#text-size+4,-1)\
- end\
- else\
- if noDots then\
- return string.sub(text,1,size)\
- else\
- return string.sub(text,1,size-3)..\"...\"\
- end\
- end\
- end\
- \
- --ПОЛУЧЕНпЕ ФОРМАТА ФАЙЛА\
- function getFileFormat(path)\
- local name = fs.getName(path)\
- local starting,ending = string.find(name,\"(.)%.[%d%w]*$\")\
- if starting == nil then\
- return nil\
- else\
- return string.sub(name,starting+1,-1)\
- end\
- end\
- \
- --ПРОВЕРКА, СКРЫТЫЙ Лп ФАЙЛ\
- function isFileHidden(path)\
- local name = fs.getName(path)\
- local starting,ending = string.find(name,\"^%.(.*)$\")\
- if starting == nil then\
- return false\
- else\
- return true\
- end\
- end\
- \
- --СКРЫТЬ РАСШпРЕНпЕ ФАЙЛА\
- function hideFileFormat(path)\
- local name = fs.getName(path)\
- local fileFormat = getFileFormat(name)\
- if fileFormat == nil then\
- return name\
- else\
- return string.sub(name,1,#name-#fileFormat)\
- end\
- end\
- \
- --ПОЛУЧЕНпЕ РАЗМЕРА ФАЙЛА пЛп ПАПКп\
- function getFileSize(path)\
- local allFilesSize = 0\
- if fs.isDir(path) then\
- local fileList = fs.list(path)\
- for i=1,#fileList do\
- allFilesSize = allFilesSize + getFileSize(path..\"/\"..fileList[i])\
- end\
- else\
- allFilesSize = allFilesSize + fs.getSize(path)\
- end\
- return allFilesSize\
- end\
- \
- --ПОЛУЧпТЬ ТпП ФАЙЛА\
- function getFileType(path)\
- local fileTypes = {\
- [\".png\"] = \"Image\",\
- [\".cfg\"] = \"Config\",\
- [\".zip\"] = \"Archive\",\
- [\".app\"] = \"Application\",\
- }\
- \
- local currentFileType = nil\
- \
- local fileFormat = getFileFormat(path)\
- if fileFormat == nil then\
- if fs.isDir(path) then\
- currentFileType = \"Folder\"\
- else\
- currentFileType = \"Lua script\"\
- end\
- else\
- currentFileType = fileTypes[fileFormat] or fileFormat\
- end\
- \
- return currentFileType\
- end\
- \
- --РЕОРГАНпЗМАЦпЯ МАССпВА ДЛЯ ОС-Кп\
- function reorganizeFilesAndFolders(workPath,massivSudaPihay,showHiddenFiles,showSystemFolders)\
- local reorganizedMassiv = {}\
- local function doGovno(i)\
- if showHiddenFiles then\
- reorganizedMassiv[#reorganizedMassiv+1] = massivSudaPihay[i]\
- else\
- if not windows.isFileHidden(workPath..\"/\"..massivSudaPihay[i]) then\
- reorganizedMassiv[#reorganizedMassiv+1] = massivSudaPihay[i]\
- end\
- end\
- end\
- local filePath = nil\
- for i=1,#massivSudaPihay do\
- filePath = workPath..\"/\"..massivSudaPihay[i]\
- if fs.isDir(filePath) and windows.getFileFormat(filePath) ~= \".app\" then\
- if showSystemFolders then\
- doGovno(i)\
- else\
- if massivSudaPihay[i] ~= \"rom\" and massivSudaPihay[i] ~= \"System\" then\
- --windows.attention({\"massiv[i] = \"..massivSudaPihay[i]},{\"heh\"})\
- doGovno(i)\
- end\
- end\
- end\
- end\
- for i=1,#massivSudaPihay do\
- filePath = workPath..\"/\"..massivSudaPihay[i]\
- if not fs.isDir(filePath) and massivSudaPihay[i] ~= \"OS\" or fs.isDir(filePath) and windows.getFileFormat(filePath) == \".app\" then\
- doGovno(i)\
- end\
- end\
- return reorganizedMassiv\
- end\
- \
- --ОТРпСОВКА пКОНКп ДЛЯ ОС\
- function drawOSIcon(xIconPos,yIconPos,workPath,name,fileFormat)\
- --ЕСЛп ЭТО НЕ ПАПКА\
- if not fs.isDir(workPath..\"/\"..name) then\
- if fileFormat == \".png\" then\
- image.draw(xIconPos,yIconPos,\"System/OS/Icons/image.png\")\
- elseif fileFormat == \".cfg\" then\
- image.draw(xIconPos,yIconPos,\"System/OS/Icons/config.png\")\
- elseif fileFormat == \".zip\" then\
- image.draw(xIconPos,yIconPos,\"System/OS/Icons/zip.png\")\
- else\
- image.draw(xIconPos,yIconPos,\"System/OS/Icons/default.png\")\
- end\
- --ЕСЛп ЭТО ПАПКА\
- else\
- local iconPath = workPath..\"/\"..name..\"/Resources/icon.png\"\
- if fileFormat == \".app\" and fs.exists(iconPath) then\
- image.draw(xIconPos,yIconPos,iconPath)\
- elseif string.sub(name,1,4)==\"disk\" then\
- image.draw(xIconPos,yIconPos,\"System/OS/Icons/disk.png\")\
- else\
- image.draw(xIconPos,yIconPos,\"System/OS/Icons/folder.png\")\
- end\
- end\
- end\
- \
- --КОРРЕКТпРОВКА СТАРТОВЫХ КООРДпНАТ\
- local function correctStartCoords(xStart,yStart,xWindowSize,yWindowSize)\
- if xStart == \"auto\" then\
- xStart = math.floor(xSize/2 - xWindowSize/2)\
- end\
- if yStart == \"auto\" then\
- yStart = math.floor(ySize/2 - yWindowSize/2)\
- end\
- return xStart,yStart\
- end\
- \
- --РпСОВАНпЕ КНОПКп\
- function button(x,y,xOffset,yOffset,text,textColor,backColor)\
- local width = xOffset*2+#text\
- local height = yOffset*2+1\
- x,y = correctStartCoords(x,y,width,height)\
- square(x,y,width,height,backColor)\
- colorText(x+xOffset,y+yOffset,text,textColor)\
- return x,y,x+width-1,y+height-1\
- end\
- \
- --ОТРпСОВКА ШКАЛЫ ПРОГРЕССА\
- local function drawProgressBar(xStart,yStart,width,height,frontColor,backColor,percent)\
- local doneSize = math.ceil(percent/100*width)\
- \
- square(xStart,yStart,width,height,backColor)\
- square(xStart,yStart,doneSize,height,frontColor)\
- end\
- \
- --ОТРпСОВКА ПОЛОСЫ ПРОКРУТКп\
- function scrollBar(xStart,yStart,height,countOfAllElements,currentElement,backColor,frontColor)\
- local percent = 1/countOfAllElements\
- local sizeOfScrollBar = math.ceil(percent * height)\
- local displayBarFrom = math.floor(yStart + height*((currentElement-1)/countOfAllElements))\
- \
- for i=yStart,(yStart+height-1) do\
- paintutils.drawPixel(xStart,i,backColor)\
- end\
- \
- for i=displayBarFrom,(displayBarFrom+sizeOfScrollBar-1) do\
- paintutils.drawPixel(xStart,i,frontColor)\
- end\
- end\
- \
- --ПОпСК ЧЕГО-ЛпБО В ФАЙЛОВОЙ СпСТЕМЕ\
- local function searchInAllFiles(path,whatToFind)\
- \
- local function poiskSovpadeniya(name)\
- local starting,ending = string.find(string.lower(name),string.lower(whatToFind))\
- if starting == nil then\
- return false\
- else\
- return true\
- end\
- end\
- \
- local searchMassiv = {}\
- \
- local function createFileMassiv(path,whatToFind)\
- local fileList = fs.list(path)\
- for i=1,#fileList do\
- if fs.isDir(path..\"/\"..fileList[i]) then\
- if poiskSovpadeniya(fileList[i]) then\
- searchMassiv[#searchMassiv+1] = {[\"path\"]=path,[\"name\"]=fileList[i],[\"isDir\"]=true,[\"fileSize\"]=getFileSize(path..\"/\"..fileList[i]),[\"fileType\"]=getFileType(path..\"/\"..fileList[i]),[\"fileFormat\"]=getFileFormat(path..\"/\"..fileList[i])}\
- end\
- createFileMassiv(path..\"/\"..fileList[i],whatToFind)\
- else\
- if poiskSovpadeniya(fileList[i]) then\
- searchMassiv[#searchMassiv+1] = {[\"path\"]=path,[\"name\"]=fileList[i],[\"isDir\"]=false,[\"fileSize\"]=getFileSize(path..\"/\"..fileList[i]),[\"fileType\"]=getFileType(path..\"/\"..fileList[i]),[\"fileFormat\"]=getFileFormat(path..\"/\"..fileList[i])}\
- end\
- end\
- end\
- end\
- createFileMassiv(path,whatToFind)\
- return searchMassiv\
- \
- end\
- \
- --ФОРМАТпРОВАННЫЙ ТЕКСТ КАК В ЧАТЕ МАЙНА ЧЕРЕЗ &6, &c, &a п Т.П.\
- local colorCodes = {\
- {[\"code\"] = \"&0\", [\"color\"] = 1},\
- {[\"code\"] = \"&1\", [\"color\"] = 2},\
- {[\"code\"] = \"&2\", [\"color\"] = 4},\
- {[\"code\"] = \"&3\", [\"color\"] = 8},\
- {[\"code\"] = \"&4\", [\"color\"] = 16},\
- {[\"code\"] = \"&5\", [\"color\"] = 32},\
- {[\"code\"] = \"&6\", [\"color\"] = 64},\
- {[\"code\"] = \"&7\", [\"color\"] = 128},\
- {[\"code\"] = \"&8\", [\"color\"] = 256},\
- {[\"code\"] = \"&9\", [\"color\"] = 512},\
- {[\"code\"] = \"&a\", [\"color\"] = 1024},\
- {[\"code\"] = \"&b\", [\"color\"] = 2048},\
- {[\"code\"] = \"&c\", [\"color\"] = 4096},\
- {[\"code\"] = \"&d\", [\"color\"] = 8192},\
- {[\"code\"] = \"&e\", [\"color\"] = 16384},\
- {[\"code\"] = \"&f\", [\"color\"] = 32768},\
- }\
- \
- function foramattedText(text)\
- local color = colors.white\
- term.setTextColor(color)\
- local sText = #text\
- local searchFrom = 1\
- \
- local exit = false\
- while true do\
- if exit then break end\
- local founded = false\
- local s,e = string.find(text,\"&\",searchFrom)\
- if s then\
- local code = string.sub(text,s,s+1)\
- for i=1,16 do\
- if code == colorCodes[i][\"code\"] then\
- \
- local cyka = string.sub(text,searchFrom,s-1)\
- term.write(cyka)\
- \
- color = colorCodes[i][\"color\"]\
- term.setTextColor(color)\
- \
- founded = true\
- searchFrom = searchFrom + #cyka + 2\
- break\
- end\
- end\
- end\
- \
- if not founded then\
- term.write(string.sub(text,searchFrom,-1))\
- exit = true\
- end\
- end\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------\
- \
- function error(text1)\
- \
- local title = \"Error\"\
- local limit = xSize - 16 - 11\
- local sizeOfText1 = #text1\
- \
- local parsedErr = {}\
- for i=1,(math.ceil(sizeOfText1/limit)) do\
- parsedErr[#parsedErr+1] = string.sub(text1,i*limit+1-limit,i*limit)\
- end\
- \
- local theLongestElement = #title\
- for i=1,#parsedErr do\
- local size = #parsedErr[i]\
- if size > theLongestElement then theLongestElement = size end\
- end\
- \
- local xWindowSize = 9 + theLongestElement + 2\
- local yWindowSize = 2 + 1 + 1 + #parsedErr + 3\
- local xStart = math.floor(xSize/2-xWindowSize/2)\
- local yStart = math.floor(ySize/2-yWindowSize/2)\
- \
- --РпСОВАНпЕ ПУСТОГО ОКНА\
- emptyWindow(xStart,yStart,xWindowSize,yWindowSize,\" \")\
- \
- --DRAW ICON\
- paintutils.drawPixel(xStart+4,yStart+2,colors.red)\
- paintutils.drawPixel(xStart+3,yStart+3,colors.red)\
- paintutils.drawPixel(xStart+4,yStart+3,colors.red)\
- paintutils.drawPixel(xStart+5,yStart+3,colors.red)\
- paintutils.drawPixel(xStart+2,yStart+4,colors.red)\
- paintutils.drawPixel(xStart+3,yStart+4,colors.red)\
- paintutils.drawPixel(xStart+4,yStart+4,colors.red)\
- paintutils.drawPixel(xStart+5,yStart+4,colors.red)\
- \
- paintutils.drawPixel(xStart+6,yStart+4,colors.red)\
- colorText(xStart+4,yStart+3,\"!\",colors.white)\
- \
- --ERROR TEXT\
- term.setBackgroundColor(colors.white)\
- \
- colorText(xStart+9,yStart+2,title,colors.gray)\
- \
- for i=1,#parsedErr do\
- colorText(xStart+9,yStart+3+i,parsedErr[i],colors.lightGray)\
- end\
- \
- --BUTTON\
- local function drawButton(color,color2)\
- for x=(xStart+xWindowSize-8),(xStart+xWindowSize-3) do\
- paintutils.drawPixel(x,yStart+yWindowSize-2,color)\
- end\
- colorText(xStart+xWindowSize-6,yStart+yWindowSize-2,\"OK\",color2)\
- end\
- drawButton(colors.lightBlue,colors.black)\
- \
- while true do\
- local event,side,x,y = os.pullEvent()\
- if event == \"mouse_click\" then\
- if x>=xStart+xWindowSize-8 and x<=xStart+xWindowSize-3 and y == yStart+yWindowSize-2 then\
- drawButton(colors.blue,colors.white)\
- sleep(0.2)\
- break\
- end\
- elseif event == \"key\" then\
- if side == 28 then\
- drawButton(colors.blue,colors.white)\
- sleep(0.2)\
- break\
- end\
- end\
- end\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------\
- \
- function attention(text1,text2)\
- \
- local sizeOfText1 = #text1\
- local sizeOfText2 = #text2\
- \
- local theLongestElement = 0\
- for i=1,sizeOfText1 do\
- if #text1[i] > theLongestElement then theLongestElement = #text1[i] end\
- end\
- for i=1,sizeOfText2 do\
- if #text2[i] > theLongestElement then theLongestElement = #text2[i] end\
- end\
- \
- local xWindowSize = 9 + theLongestElement + 2\
- local yWindowSize = 2 + sizeOfText1 + 1 + sizeOfText2 + 3\
- local xStart = math.floor(xSize/2-xWindowSize/2)\
- local yStart = math.floor(ySize/2-yWindowSize/2)\
- \
- --РпСОВАНпЕ ПУСТОГО ОКНА\
- emptyWindow(xStart,yStart,xWindowSize,yWindowSize,\" \")\
- \
- --DRAW ICON\
- paintutils.drawPixel(xStart+4,yStart+2,colors.yellow)\
- paintutils.drawPixel(xStart+3,yStart+3,colors.yellow)\
- paintutils.drawPixel(xStart+4,yStart+3,colors.yellow)\
- paintutils.drawPixel(xStart+5,yStart+3,colors.yellow)\
- paintutils.drawPixel(xStart+2,yStart+4,colors.yellow)\
- paintutils.drawPixel(xStart+3,yStart+4,colors.yellow)\
- paintutils.drawPixel(xStart+4,yStart+4,colors.yellow)\
- paintutils.drawPixel(xStart+5,yStart+4,colors.yellow)\
- paintutils.drawPixel(xStart+6,yStart+4,colors.yellow)\
- colorText(xStart+4,yStart+3,\"!\",colors.white)\
- \
- --ERROR TEXT\
- term.setBackgroundColor(colors.white)\
- for i=1,sizeOfText1 do\
- colorText(xStart+9,yStart+1+i,text1[i],colors.gray)\
- end\
- for i=1,sizeOfText2 do\
- colorText(xStart+9,yStart+3+i,text2[i],colors.lightGray)\
- end\
- \
- --BUTTON\
- local function drawButton(color,color2)\
- for x=(xStart+xWindowSize-8),(xStart+xWindowSize-3) do\
- paintutils.drawPixel(x,yStart+yWindowSize-2,color)\
- end\
- colorText(xStart+xWindowSize-6,yStart+yWindowSize-2,\"OK\",color2)\
- end\
- drawButton(colors.lightBlue,colors.black)\
- \
- while true do\
- local event,side,x,y = os.pullEvent()\
- if event == \"mouse_click\" then\
- if x>=xStart+xWindowSize-8 and x<=xStart+xWindowSize-3 and y == yStart+yWindowSize-2 then\
- drawButton(colors.blue,colors.white)\
- sleep(0.2)\
- break\
- end\
- elseif event == \"key\" then\
- if side == 28 then\
- drawButton(colors.blue,colors.white)\
- sleep(0.2)\
- break\
- end\
- end\
- end\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------\
- \
- function input(...)\
- \
- local xStart = arg[1]\
- local yStart = arg[2]\
- local title = arg[3]\
- local sizeOfInputRow = arg[4]\
- \
- local sizeOfText1 = #arg-4\
- \
- local Inputs = {}\
- \
- local allowToPressOk = true\
- \
- local inputCounter = 1\
- \
- local theLongestElement = 0\
- for i=1,sizeOfText1 do\
- if #arg[i+4][1] > theLongestElement then theLongestElement = #arg[i+4][1] end\
- end\
- \
- local xWindowSize = 2 + theLongestElement + 1 + sizeOfInputRow + 2\
- local yWindowSize = 2 + sizeOfText1 * 2 + 1 + 1\
- \
- xStart, yStart = correctStartCoords(xStart,yStart,xWindowSize,yWindowSize)\
- \
- --ЗАНОСпМ СТАРТОВОЕ ГОВНО В пНПУТС, БпЧ\
- for i=1,sizeOfText1 do\
- Inputs[i]=arg[i+4][2]\
- end\
- \
- --СОЗДАНпЕ ОБЪЕКТОВ\
- local Objects = {}\
- local function newObj(class,name,x1,y1,width,height)\
- Objects[class] = Objects[class] or {}\
- Objects[class][name] = {}\
- Objects[class][name][\"x1\"]=x1\
- Objects[class][name][\"y1\"]=y1\
- Objects[class][name][\"x2\"]=x1+width-1\
- Objects[class][name][\"y2\"]=y1+height-1\
- end\
- \
- --РпСОВАНпЕ ПУСТОГО ОКНА\
- emptyWindow(xStart,yStart,xWindowSize,yWindowSize,title)\
- \
- --BUTTON\
- local function drawButton(color,color2)\
- for x=(xStart+xWindowSize-8),(xStart+xWindowSize-3) do\
- paintutils.drawPixel(x,yStart+yWindowSize-2,color)\
- end\
- colorText(xStart+xWindowSize-6,yStart+yWindowSize-2,\"OK\",color2)\
- end\
- \
- local function drawInputs()\
- for i=1,sizeOfText1 do\
- local xPosOfInput = xStart+xWindowSize - 2 - sizeOfInputRow\
- local yPosOfInput = yStart+i*2\
- \
- local inputArgument = arg[i+4]\
- \
- term.setBackgroundColor(colors.white)\
- if inputCounter == i then\
- colorText(xStart+2,yPosOfInput,inputArgument[1],colors.gray)\
- else\
- colorText(xStart+2,yPosOfInput,inputArgument[1],colors.lightGray)\
- end\
- \
- square(xPosOfInput,yPosOfInput,sizeOfInputRow,1,colors.lightGray)\
- newObj(\"inputs\",i,xPosOfInput,yPosOfInput,sizeOfInputRow,1)\
- \
- if Inputs[i] ~= nil then\
- if inputArgument[3] == nil then\
- colorText(xPosOfInput,yPosOfInput,stringLimit(\"start\",Inputs[i],sizeOfInputRow),colors.black)\
- else\
- colorText(xPosOfInput,yPosOfInput,stringLimit(\"start\",string.rep(\"*\",#Inputs[i]),sizeOfInputRow),colors.black)\
- end\
- end\
- \
- if inputCounter > sizeOfText1 then allowToPressOk = true end\
- end\
- \
- if allowToPressOk then\
- drawButton(colors.lightBlue,colors.black)\
- else\
- drawButton(colors.lightGray,colors.black)\
- end\
- end\
- \
- drawInputs()\
- \
- local currentInput = \"\"\
- \
- while true do\
- if Inputs[inputCounter] ~= nil then currentInput = Inputs[inputCounter] end\
- \
- term.setCursorBlink(false)\
- drawInputs(inputCounter)\
- term.setCursorBlink(true)\
- \
- if #currentInput < sizeOfInputRow and inputCounter <= sizeOfText1 then\
- term.setCursorPos(xStart+xWindowSize-2-sizeOfInputRow+#currentInput,yStart+inputCounter*2)\
- elseif #currentInput >= sizeOfInputRow and inputCounter <= sizeOfText1 then\
- term.setCursorPos(xStart+xWindowSize-3,yStart+inputCounter*2)\
- else\
- term.setCursorBlink(false)\
- end\
- \
- local event,side,x,y = os.pullEvent()\
- if event == \"key\" then\
- --ЕНТЕР\
- if side == 28 then\
- if currentInput ~= \"\" then\
- currentInput = \"\"\
- else\
- Inputs[inputCounter] = currentInput \
- end\
- \
- if inputCounter < sizeOfText1 then\
- inputCounter = inputCounter + 1\
- else\
- term.setCursorBlink(false)\
- drawButton(colors.blue,colors.white)\
- sleep(0.2)\
- return Inputs\
- end\
- --БЕКСПЕЙС\
- elseif side == 14 then\
- currentInput = string.sub(currentInput,1,-2)\
- Inputs[inputCounter] = currentInput\
- --КНОПОЧКп ВВЕРХ-ВНпЗ\
- elseif side == 200 then\
- inputCounter = inputCounter - 1\
- if inputCounter < 1 then inputCounter = 1 end\
- elseif side == 208 then\
- inputCounter = inputCounter + 1\
- if inputCounter > #Inputs then inputCounter = #Inputs end\
- end\
- elseif event == \"mouse_click\" then\
- term.setCursorBlink(false)\
- if x>=xStart+xWindowSize-8 and x<=xStart+xWindowSize-3 and y == yStart+yWindowSize-2 and allowToPressOk == true then\
- drawButton(colors.blue,colors.white)\
- sleep(0.2)\
- return Inputs\
- end\
- for key,val in pairs(Objects[\"inputs\"]) do\
- if x>=Objects[\"inputs\"][key][\"x1\"] and x<=Objects[\"inputs\"][key][\"x2\"] and y==Objects[\"inputs\"][key][\"y1\"] then\
- inputCounter = key\
- break\
- end\
- end\
- elseif event == \"char\" then\
- currentInput = currentInput..side\
- Inputs[inputCounter] = currentInput\
- elseif event == \"paste\" then\
- currentInput = currentInput..side\
- Inputs[inputCounter] = currentInput\
- end\
- end\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- function tv(speed)\
- term.setBackgroundColor(colors.black)\
- for i=1,centerY do\
- term.setCursorPos(1,i)\
- term.clearLine()\
- term.setCursorPos(1,ySize-i+1)\
- term.clearLine()\
- sleep(speed)\
- end\
- for i=1,centerX do\
- paintutils.drawPixel(i,centerY+1,colors.black)\
- paintutils.drawPixel(xSize-i+1,centerY+1,colors.black)\
- sleep(speed)\
- end\
- sleep(0.2)\
- clearScreen(colors.black)\
- term.setTextColor(colors.white)\
- term.setCursorPos(1,1)\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- function select(...)\
- \
- --СОЗДАНпЕ ОБЪЕКТОВ\
- local Objects = {}\
- local function newObj(class,name,x1,y1,width,height)\
- --if not Objects[class] then Objects[class] = {} end\
- Objects[class] = Objects[class] or {}\
- Objects[class][name] = {}\
- Objects[class][name][\"x1\"]=x1\
- Objects[class][name][\"y1\"]=y1\
- Objects[class][name][\"x2\"]=x1+width-1\
- Objects[class][name][\"y2\"]=y1+height-1\
- end\
- \
- local function drawButton(x,y,name,textColor,backColor)\
- local sizeOfButton = 2+#name+2\
- square(x,y,sizeOfButton,1,backColor)\
- colorText(x+2,y,name,textColor)\
- newObj(\"buttons\",name,x,y,sizeOfButton,1)\
- end\
- \
- local text1 = arg[1]\
- local text2 = arg[2]\
- \
- local sizeOfText1 = #text1\
- local sizeOfText2 = #text2\
- local hereIsOnlyOneElement = false\
- if sizeOfText1 == 0 then hereIsOnlyOneElement = true end\
- \
- --ВЫЧпСЛЕНпЕ ДЛпНЫ ОКНА НА ОСНОВЕ ТЕКСТА\
- local theLongestElement = 0\
- for i=1,sizeOfText1 do\
- if #text1[i] > theLongestElement then theLongestElement = #text1[i] end\
- end\
- for i=1,sizeOfText2 do\
- if #text2[i] > theLongestElement then theLongestElement = #text2[i] end\
- end\
- \
- --ПЕРЕСЧЕТ ДЛпНЫ ОКНА НА ОСНОВЕ КОЛпЧЕСТВА КНОПОК\
- local countOfButtons = #arg-2\
- local sizeOfAllButtons = 0\
- for i=1,countOfButtons do\
- sizeOfAllButtons = sizeOfAllButtons + 2+#arg[2+i][1]+2 + 1\
- end\
- sizeOfAllButtons = sizeOfAllButtons - 1\
- if sizeOfAllButtons>theLongestElement then theLongestElement=sizeOfAllButtons end\
- \
- --ЗАДАНпЕ КОНКРЕТНЫХ РАЗМЕРОВ ОКНА ПОСЛЕ ВЫЧпСЛЕНпЙ\
- local xWindowSize = 2 + theLongestElement + 2\
- local yWindowSize = nil\
- if hereIsOnlyOneElement then\
- yWindowSize = 2 + sizeOfText2 + 3\
- else\
- yWindowSize = 2 + sizeOfText1 + 1 + sizeOfText2 + 3\
- end\
- \
- local xStart = math.floor(xSize/2-xWindowSize/2)\
- local yStart = math.floor(ySize/2-yWindowSize/2)\
- \
- --РпСОВАНпЕ ПУСТОГО ОКНА\
- emptyWindow(xStart,yStart,xWindowSize,yWindowSize,\" \")\
- \
- --TEXTS\
- term.setBackgroundColor(colors.white)\
- for i=1,sizeOfText1 do\
- colorText(xStart+2,yStart+1+i,text1[i],colors.gray)\
- end\
- for i=1,sizeOfText2 do\
- if hereIsOnlyOneElement then\
- colorText(xStart+2,yStart+1+sizeOfText1+i,text2[i],colors.lightGray)\
- else\
- colorText(xStart+2,yStart+2+sizeOfText1+i,text2[i],colors.lightGray)\
- end\
- end\
- \
- local xStartForButtons = xStart+xWindowSize-1 - sizeOfAllButtons - 1\
- local yStartForButtons = yStart+yWindowSize-2\
- for i=1,countOfButtons do\
- local text = arg[2+i][1]\
- local textColor = tonumber(arg[2+i][3])\
- local backColor = tonumber(arg[2+i][2])\
- \
- drawButton(xStartForButtons,yStartForButtons,text,textColor,backColor)\
- xStartForButtons = xStartForButtons + 2+#arg[2+i][1]+2+1\
- end\
- \
- while true do\
- local event,side,x,y = os.pullEvent()\
- if event == \"mouse_click\" then\
- for key,val in pairs(Objects[\"buttons\"]) do\
- if x>=Objects[\"buttons\"][key][\"x1\"] and x<=Objects[\"buttons\"][key][\"x2\"] and y==Objects[\"buttons\"][key][\"y1\"] then\
- drawButton(Objects[\"buttons\"][key][\"x1\"],Objects[\"buttons\"][key][\"y1\"],key,colors.white,colors.blue)\
- sleep(0.2)\
- return key\
- end\
- end\
- end\
- end\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- function aboutFile(x,y,xWindowSize,path)\
- os.loadAPI(\"System/API/image\")\
- \
- local name = fs.getName(path)\
- local limitOfText = xWindowSize - 2\
- local yWindowSize = 16\
- \
- --СОЗДАНпЕ ОБЪЕКТОВ\
- local Objects = {}\
- local function newObj(class,name,x1,y1,width,height)\
- Objects[class] = Objects[class] or {}\
- Objects[class][name] = {}\
- Objects[class][name][\"x1\"]=x1\
- Objects[class][name][\"y1\"]=y1\
- Objects[class][name][\"x2\"]=x1+width-1\
- Objects[class][name][\"y2\"]=y1+height-1\
- end\
- \
- --РпСОВАНпЕ КНОПКп\
- local function drawButton(x,y,name,textColor,backColor)\
- local sizeOfButton = 2+#name+2\
- square(x,y,sizeOfButton,1,backColor)\
- colorText(x+2,y,name,textColor)\
- newObj(\"buttons\",name,x,y,sizeOfButton,1)\
- end\
- \
- ---------------НЕНУЖНОЕ ГОВНО, ЛОСОСНп\
- \
- local info = {}\
- \
- info[\"fileFormat\"] = getFileFormat(path)\
- \
- info[\"fileType\"] = getFileType(path)\
- \
- info[\"fileSize\"] = math.ceil(getFileSize(path)/1024)..\"KB\"\
- \
- info[\"readOnly\"] = tostring(fs.isReadOnly(path))\
- ---------------НУЖНОЕ ГОВНО\
- \
- --КОРРЕКЦпЯ КООРДпНАТЫ GOVNA, ЧТОБ ЗА КРАЯ ЭКРАНА НЕ ЗАЛЕЗАЛО\
- if y+yWindowSize - 1 >= ySize then y = y - (y+yWindowSize - 1 - ySize) - 1 end\
- if x+xWindowSize - 1 >= xSize then x = x - (x+xWindowSize - 1 - xSize) - 1 end\
- \
- --РпСУЕМ ОКНО\
- emptyWindow(x,y,xWindowSize,yWindowSize,\"Properties\")\
- \
- --пКОНОЧКп, БпЧ\
- drawOSIcon(x+1,y+2,path,name,info[\"fileFormat\"])\
- \
- --ПОЛОСОЧКА ПОД пКОНКОЙ\
- square(x,y+7,xWindowSize,1,colors.lightGray)\
- colorText(x+1,y+7,\"Info\",colors.white)\
- \
- --ТЕКСТ СПРАВА ОТ пКОНКп\
- term.setBackgroundColor(colors.white)\
- colorText(x+8,y+3,stringLimit(\"start\",name,xWindowSize-9),colors.gray)\
- colorText(x+8,y+4,info[\"fileSize\"],colors.lightGray)\
- \
- --ТЕКСТ ПОД пКОНКОЙ\
- local textStart = y+9\
- colorText(x+1,textStart,\"Type:\",colors.gray)\
- usualText(x+1,textStart+1,\"Size:\",colors.gray)\
- usualText(x+1,textStart+2,\"Path:\",colors.gray)\
- usualText(x+1,textStart+3,\"Read only:\",colors.gray)\
- \
- colorText(x+7,textStart,info[\"fileType\"],colors.lightGray)\
- usualText(x+7,textStart+1,info[\"fileSize\"])\
- usualText(x+7,textStart+2,stringLimit(\"start\",path,xWindowSize-8))\
- usualText(x+12,textStart+3,info[\"readOnly\"])\
- \
- --КНОПКА\
- drawButton(x+xWindowSize-11,y+yWindowSize-2,\"Close\",colors.black,colors.lightBlue)\
- \
- --ОТСЛЕЖпВАНпЕ НАЖАТпЯ НА КНОПКУ\
- while true do\
- local event,side,x,y = os.pullEvent()\
- if event == \"mouse_click\" then\
- for key,val in pairs(Objects[\"buttons\"]) do\
- if x>=Objects[\"buttons\"][key][\"x1\"] and x<=Objects[\"buttons\"][key][\"x2\"] and y==Objects[\"buttons\"][key][\"y1\"] then\
- drawButton(Objects[\"buttons\"][key][\"x1\"],Objects[\"buttons\"][key][\"y1\"],key,colors.white,colors.blue)\
- sleep(0.2)\
- return key\
- end\
- end\
- end\
- end\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- function progressBar(xStart,yStart,xWindowSize,title,text,speed)\
- --СКОРРЕКТпРОВАТЬ ШпРпНУ ОКНА\
- if xWindowSize < 4+#text then\
- xWindowSize = 4+#text\
- end\
- \
- local yWindowSize = 6\
- local sizeOfProgressBar = xWindowSize - 4\
- \
- --СКОРРЕКТпРОВАТЬ КООРДЫ\
- xStart,yStart = correctStartCoords(xStart,yStart,xWindowSize,yWindowSize)\
- \
- --САМО ОКНО\
- emptyWindow(xStart,yStart,xWindowSize,yWindowSize,title)\
- \
- --ТЕКСТ ОКНА\
- term.setBackgroundColor(colors.white)\
- colorText(math.floor(xStart+(xWindowSize/2-#text/2)),yStart+2,text,colors.gray)\
- \
- --РпСОВАНпЕ ПРОГРЕСС БАРА\
- local xProgressBarPos = xStart+2\
- local yProgressBarPos = yStart+4\
- drawProgressBar(xProgressBarPos,yProgressBarPos,sizeOfProgressBar,1,colors.lightBlue,colors.lightGray,0)\
- sleep(0)\
- for i=1,100,speed do\
- drawProgressBar(xProgressBarPos,yProgressBarPos,sizeOfProgressBar,1,colors.lightBlue,colors.lightGray,i)\
- sleep(0)\
- end\
- drawProgressBar(xProgressBarPos,yProgressBarPos,sizeOfProgressBar,1,colors.lightBlue,colors.lightGray,100)\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- function search(xStart,yStart,xWindowSize,limitOfElements,searchText)\
- \
- os.loadAPI(\"System/API/image\")\
- \
- local searchList = {}\
- \
- local sizeOfOneElement = 5\
- local yWindowSize = 4 + sizeOfOneElement*limitOfElements\
- local sizeOfSearchBar = xWindowSize - #searchText - 3\
- local xStartOfSearchBar = xStart + 2 + #searchText\
- local yStartOfSearchBar = yStart + 1\
- local limitOfAllText = xWindowSize - 10\
- local xWindowEnd = xStart + xWindowSize - 1\
- local yWindowEnd = yStart + yWindowSize - 1\
- \
- local fromElement = 1\
- local searchInput = \"\"\
- \
- --СОЗДАНпЕ ОБЪЕКТОВ\
- local Objects = {}\
- local function newObj(class,name,x1,y1,width,height,fileType,fileSize,path,fileName,fileFormat)\
- Objects[class] = Objects[class] or {}\
- Objects[class][name] = {}\
- Objects[class][name][\"x1\"]=x1\
- Objects[class][name][\"y1\"]=y1\
- Objects[class][name][\"x2\"]=x1+width-1\
- Objects[class][name][\"y2\"]=y1+height-1\
- Objects[class][name][\"fileType\"]=fileType\
- Objects[class][name][\"fileSize\"]=fileSize\
- Objects[class][name][\"path\"]=path\
- Objects[class][name][\"fileName\"]=fileName\
- Objects[class][name][\"fileFormat\"]=fileFormat\
- end\
- \
- local function drawConcretnoIcon(xStart,yStart,path,name,fileType,fileSize,backColor,fileFormat)\
- drawOSIcon(xStart,yStart,path,name,fileFormat)\
- term.setBackgroundColor(backColor)\
- colorText(xStart+8,yStart,stringLimit(\"end\",name,limitOfAllText),colors.gray)\
- colorText(xStart+8,yStart+1,stringLimit(\"start\",path,limitOfAllText),colors.lightGray)\
- colorText(xStart+8,yStart+2,stringLimit(\"start\",\"Type: \"..fileType,limitOfAllText),colors.lightGray)\
- colorText(xStart+8,yStart+3,stringLimit(\"start\",\"Size: \"..math.ceil(fileSize/1024)..\"KB\",limitOfAllText),colors.lightGray)\
- \
- newObj(\"icon\",path..\"/\"..name,xStart,yStart,xWindowSize,4,fileType,fileSize,path,name,fileFormat)\
- end\
- \
- local function drawSearches(fromElement)\
- --ОБНУЛЕНпЕ ОБЪЕКТОВ\
- Objects = {}\
- newObj(\"icon\",\"cykaBlyad\",-5,-5,1,1,\"hehe\",5) \
- \
- --ОЧпСТКА ЭКРАНА ПОКАЗА\
- square(xStart,yStart+3,xWindowSize-1,yWindowSize-3,colors.white)\
- \
- if #searchList == 0 then\
- colorText(xStart+1,yStart+4,\"No mathes found.\",colors.lightGray)\
- else\
- local iconCounter = 1\
- for i=fromElement,#searchList do\
- local yIconPos = yStart+4 + iconCounter*sizeOfOneElement - sizeOfOneElement\
- \
- drawConcretnoIcon(xStart+1,yIconPos,searchList[i][\"path\"],searchList[i][\"name\"],searchList[i][\"fileType\"],searchList[i][\"fileSize\"],colors.white,searchList[i][\"fileFormat\"])\
- \
- iconCounter = iconCounter + 1\
- if iconCounter > limitOfElements then break end\
- end\
- end\
- \
- scrollBar(xWindowEnd,yStart+3,yWindowSize-3,#searchList,fromElement,colors.lightGray,colors.lightBlue)\
- end\
- \
- local function textOnSearchBar()\
- term.setBackgroundColor(colors.white)\
- usualText(xStartOfSearchBar,yStartOfSearchBar,string.rep(\" \",sizeOfSearchBar))\
- colorText(xStartOfSearchBar,yStartOfSearchBar,stringLimit(\"start\",searchInput,sizeOfSearchBar),colors.black)\
- end\
- \
- --ОКНО\
- sampleWindow(xStart,yStart,xWindowSize,yWindowSize)\
- --ГОЛУБАЯ ШТУЧКА\
- square(xStart,yStart,xWindowSize,3,colors.blue)\
- colorText(xStart+1,yStart+1,searchText,colors.white)\
- square(xStartOfSearchBar,yStartOfSearchBar,sizeOfSearchBar,1,colors.white)\
- \
- drawSearches(fromElement)\
- \
- while true do\
- textOnSearchBar(searchInput)\
- if #searchInput > sizeOfSearchBar then\
- term.setCursorPos(xStartOfSearchBar+sizeOfSearchBar-1,yStartOfSearchBar)\
- else\
- term.setCursorPos(xStartOfSearchBar+#searchInput,yStartOfSearchBar)\
- end\
- \
- term.setCursorBlink(true)\
- \
- local event,side,x,y = os.pullEvent()\
- if event == \"mouse_scroll\" then\
- term.setCursorBlink(false)\
- if side == 1 then\
- fromElement = fromElement + 1\
- if fromElement > #searchList then\
- fromElement = #searchList\
- else\
- drawSearches(fromElement)\
- end\
- else\
- fromElement = fromElement - 1\
- if fromElement < 1 then\
- fromElement = 1\
- else\
- drawSearches(fromElement)\
- end\
- end\
- elseif event == \"mouse_click\" then\
- for key,val in pairs(Objects[\"icon\"]) do\
- if x>=Objects[\"icon\"][key][\"x1\"] and x<=Objects[\"icon\"][key][\"x2\"] and y>=Objects[\"icon\"][key][\"y1\"] and y<=Objects[\"icon\"][key][\"y2\"] then\
- square(Objects[\"icon\"][key][\"x1\"]-1,Objects[\"icon\"][key][\"y1\"],xWindowSize-1,4,colors.blue)\
- drawConcretnoIcon(Objects[\"icon\"][key][\"x1\"],Objects[\"icon\"][key][\"y1\"],Objects[\"icon\"][key][\"path\"],Objects[\"icon\"][key][\"fileName\"],Objects[\"icon\"][key][\"fileType\"],Objects[\"icon\"][key][\"fileSize\"],colors.blue,Objects[\"icon\"][key][\"fileFormat\"])\
- sleep(0.3)\
- term.setCursorBlink(false)\
- return string.sub(key,2,-1)\
- end\
- end\
- term.setCursorBlink(false)\
- return nil\
- \
- elseif event == \"char\" then\
- fromElement = 1\
- searchInput = searchInput..side\
- searchList = searchInAllFiles(\"/\",searchInput)\
- drawSearches(fromElement)\
- elseif event == \"key\" then\
- if side == 14 then\
- fromElement = 1\
- searchInput = string.sub(searchInput,1,-2)\
- searchList = searchInAllFiles(\"/\",searchInput)\
- drawSearches(fromElement)\
- end\
- end\
- end\
- end\
- \
- --print(\"You selected: \"..search(2,2,28,2,\"Search\"))\
- \
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- function info(xStart,yStart,title,text)\
- local sizeOfText = #text\
- local xWindowSize = 4+sizeOfText\
- local yWindowSize = 4\
- local xStart,yStart = correctStartCoords(xStart,yStart,xWindowSize,yWindowSize)\
- \
- emptyWindow(xStart,yStart,xWindowSize,yWindowSize,title)\
- \
- term.setBackgroundColor(colors.white)\
- colorText(xStart+2,yStart+2,text,colors.gray)\
- end\
- \
- ---------------------------------------------------------------------------------------------------------------------\
- \
- --[[function fileManager(mode,workPath)\
- if workPath == nil then workPath = \"\" end\
- \
- local xSize,ySize = term.getSize()\
- \
- local managerX = xSize-3\
- local managerY = ySize-3\
- \
- local xStart = 2\
- local yStart = 2\
- \
- local main = window.create(term.native(),xStart,yStart,managerX+1,managerY+1)\
- term.redirect(main)\
- \
- local function getFoldersList(workPath)\
- \
- end\
- \
- local function drawManager()\
- local currentPath = fs.getName(workPath)\
- emptyWindow(1,1,managerX,managerY,currentPath)\
- colorTextWithBack(1,1,\"x\",colors.black,colors.red);colorTextWithBack(2,1,\"-\",colors.black,colors.orange);colorTextWithBack(3,1,\"+\",colors.black,colors.lime)\
- end\
- \
- local function clickedAtArea(x,y,sx,sy,ex,ey)\
- if (x >= sx) and (x <= ex) and (y >= sy) and (y <= ey) then return true end \
- return false\
- end\
- \
- drawManager()\
- \
- term.redirect(term.native())\
- end]]",
- path = "/rootfs/System/API/windows",
- },
- {
- text = "function parseargs(s)\
- local arg = {}\
- string.gsub(s, \"([%-%w]+)=([\\\"'])(.-)%2\", function (w, _, a)\
- arg[w] = a\
- end)\
- return arg\
- end\
- \
- function collect(s)\
- local stack = {}\
- local top = {}\
- table.insert(stack, top)\
- local ni,c,label,xarg, empty\
- local i, j = 1, 1\
- while true do\
- ni,j,c,label,xarg, empty = string.find(s, \"<(%/?)([%w:]+)(.-)(%/?)>\", i)\
- if not ni then break end\
- local text = string.sub(s, i, ni-1)\
- if not string.find(text, \"^%s*$\") then\
- table.insert(top, text)\
- end\
- if empty == \"/\" then -- empty element tag\
- table.insert(top, {label=label, xarg=parseargs(xarg), empty=1})\
- elseif c == \"\" then -- start tag\
- top = {label=label, xarg=parseargs(xarg)}\
- table.insert(stack, top) -- new level\
- else -- end tag\
- local toclose = table.remove(stack) -- remove top\
- top = stack[#stack]\
- if #stack < 1 then\
- error(\"nothing to close with \"..label)\
- end\
- if toclose.label ~= label then\
- error(\"trying to close \"..toclose.label..\" with \"..label)\
- end\
- table.insert(top, toclose)\
- end\
- i = j+1\
- end\
- local text = string.sub(s, i)\
- if not string.find(text, \"^%s*$\") then\
- table.insert(stack[#stack], text)\
- end\
- if #stack > 1 then\
- error(\"unclosed \"..stack[#stack].label)\
- end\
- return stack[1]\
- end",
- path = "/rootfs/System/API/xml",
- },
- {
- text = "function archive(chto,vochto)\
- local Massiv2 = {}\
- local function FileList(path)\
- local Massiv = fs.list(path)\
- if #Massiv==0 then\
- local Massiv2Id = #Massiv2 + 1\
- Massiv2[Massiv2Id] = {}\
- Massiv2[Massiv2Id][\"path\"] = path\
- Massiv2[Massiv2Id][\"text\"] = \"@empty@empty\"\
- else\
- for i=1,#Massiv do\
- if fs.isDir(path..\"/\"..Massiv[i]) and Massiv[i] ~= \"/rom\" and Massiv[i] ~= \"rom\" then\
- FileList(path..\"/\"..Massiv[i])\
- elseif not fs.isDir(path..\"/\"..Massiv[i]) and Massiv[i] ~= \"/rom\" and Massiv[i] ~= \"rom\" then\
- local Massiv2Id = #Massiv2 + 1\
- Massiv2[Massiv2Id] = {}\
- Massiv2[Massiv2Id][\"path\"] = path..\"/\"..Massiv[i]\
- local file = fs.open(path..\"/\"..Massiv[i],\"r\")\
- Massiv2[Massiv2Id][\"text\"] = file.readAll()\
- file.close()\
- end\
- end\
- end\
- end\
- FileList(chto)\
- file=fs.open(vochto..\".zip\",\"w\")\
- file.write(textutils.serialise(Massiv2))\
- file.close()\
- return Massiv2\
- end\
- \
- function unarchive(chto,kuda)\
- local file = fs.open(chto,\"r\")\
- Massiv = textutils.unserialise(file.readAll())\
- file.close()\
- for i=1,#Massiv do\
- if Massiv[i][\"text\"] == \"@empty@empty\" then\
- fs.makeDir(kuda..\"/\"..Massiv[i][\"path\"])\
- else\
- local file = fs.open(kuda..\"/\"..Massiv[i][\"path\"],\"w\")\
- file.write(Massiv[i][\"text\"])\
- file.close()\
- end\
- end\
- end",
- path = "/rootfs/System/API/zip",
- },
- {
- text = "local xSize, ySize = term.getSize()\
- \
- local fileImage = 0\
- local fileDocument = 0\
- local fileOther = 0\
- local computerLabel = os.getComputerLabel()\
- if computerLabel == nil then computerLabel = \"not set\" end\
- \
- --------------------MODEM FIND----------------------------\
- function findModem()\
- local PeriList = peripheral.getNames()\
- for i=1,#PeriList do\
- if peripheral.getType(PeriList[i]) == \"modem\" then\
- return PeriList[i]\
- end\
- end\
- end\
- \
- local computerModem = findModem()\
- if computerModem == nil then computerModem = \"not found\" end\
- \
- local function clearScreen(color)\
- term.setBackgroundColor(color)\
- term.clear()\
- end\
- \
- local function fadeIn(time)\
- clearScreen(colors.gray)\
- sleep(time)\
- clearScreen(colors.lightGray)\
- sleep(time)\
- clearScreen(colors.white)\
- sleep(time)\
- end\
- \
- local function fadeOut(time)\
- clearScreen(colors.lightGray)\
- sleep(time)\
- clearScreen(colors.gray)\
- sleep(time)\
- clearScreen(colors.black)\
- sleep(time)\
- term.setCursorPos(1,1)\
- term.setTextColor(colors.white)\
- end\
- \
- local function getSizeOfAll()\
- local sizeOfAll1 = 0\
- local function files(path)\
- local massiv = fs.list(path)\
- for i=1,#massiv do\
- if fs.isDir(massiv[i]) then\
- files(path..\"/\"..massiv[i])\
- else\
- sizeOfAll1 = sizeOfAll1 + fs.getSize(path..\"/\"..massiv[i])\
- end\
- end\
- end\
- files(\"\")\
- return sizeOfAll1\
- end\
- \
- local function getFileFormat(file)\
- local start,ending = string.find(file,\"%.%w*$\")\
- if start == nil then\
- return nil\
- else\
- return string.sub(file,start,ending)\
- end\
- end\
- \
- local function getSizeOfFormat()\
- local sizeOfAll1 = 0\
- local function files(path)\
- local massiv = fs.list(path)\
- for i=1,#massiv do\
- if fs.isDir(massiv[i]) then\
- files(path..\"/\"..massiv[i])\
- else\
- local f = getFileFormat(path..\"/\"..massiv[i])\
- local s = fs.getSize(path..\"/\"..massiv[i])\
- if f == \".png\" then\
- fileImage = fileImage + s\
- elseif f == \".cfg\" or f == \".log\" then\
- fileDocument = fileDocument + s\
- elseif f == nil then\
- fileOther = fileOther + s\
- end\
- end\
- end\
- end\
- files(\"\")\
- return sizeOfAll1\
- end\
- \
- local function writeText(text,x,y)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- local function infoText(key,keyColor,value,x,y)\
- term.setCursorPos(x,y)\
- term.setTextColor(keyColor)\
- term.write(key..\": \")\
- term.setTextColor(colors.lightGray)\
- term.write(value)\
- end\
- \
- getSizeOfFormat()\
- \
- local sizeOfAll = getSizeOfAll()\
- local freeSpace = fs.getFreeSpace(\"\")\
- local totalSpace = freeSpace + sizeOfAll\
- local lengthOfPolosa = xSize-6\
- local lengthOfAll = math.floor(lengthOfPolosa*(math.ceil(sizeOfAll/totalSpace*100))/100)\
- local lengthOfDocuments = math.floor(lengthOfPolosa*math.ceil(fileDocument/sizeOfAll*100)/100)\
- local lengthOfImages = math.floor(lengthOfPolosa*math.ceil(fileImage/sizeOfAll*100)/100)\
- \
- -------------------------------------------------------------\
- fadeIn(0.05)\
- \
- local xStart = math.floor(xSize/2-lengthOfPolosa/2)\
- local yStart = ySize-3\
- \
- \
- local function displayBar(time)\
- while true do\
- for y=yStart,(yStart+1) do\
- for x=(xStart+1),(xStart+lengthOfPolosa) do\
- paintutils.drawPixel(x,y,colors.gray)\
- end\
- end\
- for y=yStart,(yStart+1) do\
- for x=(xStart+1),(xStart+lengthOfAll) do\
- paintutils.drawPixel(x,y,colors.black)\
- end\
- end\
- \
- ------------------------------\
- sleep(2)\
- ------------------------------\
- \
- for y=yStart,(yStart+1) do\
- for x=(xStart+1),(xStart+lengthOfPolosa) do\
- paintutils.drawPixel(x,y,colors.lime)\
- end\
- end\
- for y=yStart,(yStart+1) do\
- for x=(xStart+1),(xStart+lengthOfDocuments) do\
- paintutils.drawPixel(x,y,colors.red)\
- end\
- end\
- for y=yStart,(yStart+1) do\
- for x=(xStart+1+lengthOfDocuments),(xStart+lengthOfDocuments+lengthOfImages) do\
- paintutils.drawPixel(x,y,colors.yellow)\
- end\
- end\
- ------------------------------\
- sleep(2)\
- ------------------------------\
- end\
- end\
- \
- \
- \
- for i=1,xSize do\
- paintutils.drawPixel(i,1,colors.gray)\
- end\
- term.setTextColor(colors.lightGray)\
- writeText(\"About\",math.floor(xSize/2-string.len(\"About\")/2),1)\
- \
- term.setBackgroundColor(colors.white)\
- infoText(\"Computer label\",colors.gray,computerLabel,2,3)\
- infoText(\"Computer ID\",colors.gray,tostring(os.getComputerID()),2,4)\
- infoText(\"Connected modem\",colors.gray,computerModem,2,5)\
- infoText(\"Aviable space\",colors.gray,math.ceil(totalSpace/1024)..\" KB\",2,6)\
- infoText(\"Used space\",colors.black,math.ceil(sizeOfAll/1024)..\" KB\",2,8)\
- infoText(\"Free space\",colors.gray,math.ceil(freeSpace/1024)..\" KB\",2,9)\
- infoText(\"Documents\",colors.red,math.ceil(fileDocument/1024)..\" KB\",2,10)\
- infoText(\"Images\",colors.yellow,math.ceil(fileImage/1024)..\" KB\",2,11)\
- infoText(\"Other\",colors.lime,math.ceil(fileOther/1024)..\" KB\",2,12)\
- \
- local function touch()\
- while true do\
- event = os.pullEvent()\
- if event == \"key\" or event == \"mouse_click\" then break end\
- end\
- end\
- \
- parallel.waitForAny(displayBar,touch)\
- \
- fadeOut(0.05)",
- path = "/rootfs/System/Apps/About",
- },
- {
- text = "-- Project LinOS Bootstrap (made by nikov2002)\
- \
- \
- os.loadAPI(\"System/API/image\")\
- image.draw(1,1,\"/System/Bootscr/boot.png\")\
- sleep(2)\
- shell.run (\"/System/Apps/Desktop\")",
- path = "/rootfs/System/Apps/Bootstrap",
- },
- {
- text = "-- Project LinOS Customisation (made by nikov2002)\
- \
- \
- os.loadAPI(\"System/API/image\")\
- \
- function textWrite(x,y,text)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- local function square(x1,y1,width,height,color)\
- local string = string.rep(\" \",width)\
- term.setBackgroundColor(color)\
- for y=y1,(y1+height-1) do\
- textWrite(x1,y,string)\
- end\
- end\
- \
- function firstTab()\
- square(2,1,11,1,colors.lightBlue)\
- textWrite(2,1,\" Background \")\
- term.setBackgroundColor(colors.white)\
- term.setTextColor(colors.gray)\
- textWrite(2,3,\"Background Color:\")\
- paintutils.drawPixel(4,3,8)\
- paintutils.drawPixel(5,3,8)\
- paintutils.drawPixel(4,4,8)\
- paintutils.drawPixel(5,4,8)\
- paintutils.drawPixel(6,3,128)\
- paintutils.drawPixel(7,3,128)\
- paintutils.drawPixel(6,4,128)\
- paintutils.drawPixel(7,4,128)\
- paintutils.drawPixel(8,3,16384)\
- paintutils.drawPixel(9,3,16384)\
- paintutils.drawPixel(8,4,16384)\
- paintutils.drawpixel(9,4,16384)\
- end\
- \
- function secondTab()\
- end\
- \
- function drawEvery()\
- square(1,1,51,19,colors.white)\
- square(1,1,51,1,colors.lightGray)\
- end\
- \
- drawEvery()\
- firstTab()",
- path = "/rootfs/System/Apps/CustSettinn",
- },
- {
- text = "-- Project LinOS (made by nikov2002) APIS and \"Photoshop\" by EliteClubSessions (Igor_Pavlov)\
- \
- \
- os.loadAPI(\"System/API/windows\")\
- os.loadAPI(\"System/API/image\")\
- os.loadAPI(\"System/API/context\")\
- os.loadAPI(\"System/API/config\")\
- \
- if not term.isColor() then error(\"This program will work only on advanced computer.\") end\
- colbg = 8\
- colt = 32768\
- tbc = 1\
- term.setBackgroundColor(colbg)\
- term.setTextColor(colt)\
- topBar = 128\
- \
- local xSize, ySize = term.getSize()\
- \
- function appsbuddon()\
- image.draw(1,18,\"/System/OS/Icons/apps.png\")\
- end\
- \
- function textWrite(x,y,text)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- function timetop()\
- term.setBackgroundColor(topBar)\
- term.setTextColor(tbc)\
- term.setCursorPos(46,1)\
- local time = textutils.formatTime(os.time(),true)\
- term.setBackgroundColor(topBar)\
- print(\" \",time,\" \")\
- end\
- \
- function searchFromFiles()\
- term.setCursorPos(1,1)\
- term.setBackgroundColor(topBar)\
- term.setTextColor(tbc)\
- term.setCursorPos(22,1)\
- print(\" Search \")\
- end\
- \
- function titleBar()\
- term.setCursorPos(1,1) \
- term.setBackgroundColor(topBar)\
- term.setTextColor(tbc)\
- term.setCursorPos(1,1)\
- print(\" LinOS Customise \")\
- timetop()\
- searchFromFiles()\
- end\
- \
- function drawDesktop()\
- term.clear()\
- term.setBackgroundColor(colbg)\
- term.setTextColor(colt)\
- titleBar()\
- appsbuddon()\
- end\
- \
- function ContextMenu()\
- local contextAction = context.menu(1,2,{\"Reboot\"},{\"Shutdown\"},{\"AboutCC\"},\"-\",{\"By nikov2002\",true})\
- if contextAction == \"Reboot\" then\
- os.reboot()\
- elseif contextAction == \"Shutdown\" then\
- os.shutdown()\
- elseif contextAction == \"AboutCC\" then\
- shell.run(\"/System/Apps/About\")\
- end\
- end\
- \
- function ContextMenu1()\
- local contextAction1 = context.menu(10,2,{\"Not ready yet\",true})\
- end\
- \
- drawDesktop()\
- \
- while true do\
- local event, button, X, Y = os.pullEventRaw()\
- if event == \"mouse_click\" then\
- if X >=1 and X <=7 and Y==1 and button ==1 then\
- term.setBackgroundColor(colbg)\
- ContextMenu()\
- elseif X >=1 and X <=3 and Y >=18 and Y <=19 and button ==1 then\
- term.setBackgroundColor(colbg)\
- shell.run (\"/System/Apps/Drawer\")\
- elseif X >=22 and X <=30 and Y==1 and button==1 then\
- windows.search(14,2,25,2,\"Search\")\
- elseif X >=10 and X <=20 and Y==1 and button==1 then\
- ContextMenu1()\
- else\
- term.setBackgroundColor(colbg)\
- drawDesktop()\
- end\
- end\
- end",
- path = "/rootfs/System/Apps/Desktop",
- },
- {
- text = "-- Project LinOS Appdrawer (made by nikov2002)\
- \
- local Args = {...}\
- os.loadAPI(\"System/API/windows\")\
- os.loadAPI(\"System/API/image\")\
- if not term.isColor() then error(\"This program will work only on advanced computer.\") end\
- \
- --[[local standartErrorFunction = error\
- error = windows.error]]\
- \
- local xSize, ySize = term.getSize()\
- local centerX = math.floor(xSize/2)\
- local centerY = math.floor(ySize/2)\
- local appWidth = 10\
- local appHeight = 6\
- \
- local countOfAppsByX = math.floor((xSize-2)/(appWidth+2))\
- local countOfAppsByY = math.floor((ySize-5)/(appHeight+1))\
- local countOfAppsOnDesktop = countOfAppsByX*countOfAppsByY\
- \
- local countOfDesktops = nil\
- \
- local startDisplayAllAppsFromX = centerX - math.floor((countOfAppsByX*(appWidth+2)-2)/2) + 1\
- local startDisplayAllAppsFromY = centerY - math.floor((countOfAppsByY*(appHeight+1)-1)/2) + 1\
- \
- local currentDesktop = 1\
- local currentBackground = colors.lightBlue\
- \
- local Obj = {}\
- local ObjBottom = {}\
- local ObjApp = {}\
- \
- local clipboardName = nil\
- \
- local workPath = \"/apps\"\
- local workPathHistory = {}\
- \
- local function newObjApp(name,x1,y1,width,height,id,fileFormat)\
- ObjApp[name]={}\
- ObjApp[name][\"x1\"]=x1\
- ObjApp[name][\"y1\"]=y1\
- ObjApp[name][\"x2\"]=x1+width-1\
- ObjApp[name][\"y2\"]=y1+height-1\
- ObjApp[name][\"id\"]=id\
- ObjApp[name][\"fileFormat\"]=fileFormat\
- end\
- \
- local function newObj(name,x1,y1,width,height)\
- Obj[name]={}\
- Obj[name][\"x1\"]=x1\
- Obj[name][\"y1\"]=y1\
- Obj[name][\"x2\"]=x1+width-1\
- Obj[name][\"y2\"]=y1+height-1\
- end\
- \
- local function newObjBottom(name,x1,y1,width,height)\
- ObjBottom[name]={}\
- ObjBottom[name][\"x1\"]=x1\
- ObjBottom[name][\"y1\"]=y1\
- ObjBottom[name][\"x2\"]=x1+width-1\
- ObjBottom[name][\"y2\"]=y1+height-1\
- end\
- \
- local function stringLimit(text,size)\
- if string.len(text)<=size then return text end\
- return string.sub(text,1,size-3)..\"...\"\
- end\
- \
- local function stringLimitFromStart(text,size)\
- if string.len(text)<=size then return text end\
- return \"...\"..string.sub(text,string.len(text)-size+4,string.len(text))\
- end\
- \
- local function usualText(x,y,text)\
- term.setCursorPos(x,y)\
- term.write(text)\
- end\
- \
- function appsbuddon()\
- image.draw(1,18,\"/System/OS/Icons/apps.png\")\
- end\
- \
- local function square(x1,y1,width,height,color)\
- local string = string.rep(\" \",width)\
- term.setBackgroundColor(color)\
- for y=y1,(y1+height-1) do\
- usualText(x1,y,string)\
- end\
- end\
- \
- local function clearScreen(color)\
- term.setBackgroundColor(color)\
- term.clear()\
- end\
- \
- local function prepareToExit()\
- clearScreen(colors.black)\
- term.setTextColor(colors.white)\
- term.setCursorPos(1,1)\
- end\
- \
- local function programFinished()\
- local xCusor,yCursor = term.getCursorPos()\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.white)\
- usualText(1,yCursor+1,\"Press any key to quit.\")\
- \
- while true do\
- local event = os.pullEvent()\
- if event == \"monitor_touch\" or event == \"mouse_click\" or event == \"key\" then break end\
- end\
- end\
- \
- \
- \
- local function drawKonkretnoApp(x,y,name,background,id)\
- \
- newObjApp(name,x,y,appWidth,appHeight,id,windows.getFileFormat(name))\
- \
- windows.drawOSIcon(x+2,y,workPath,name,ObjApp[name][\"fileFormat\"],showSystemFolders)\
- \
- term.setBackgroundColor(background)\
- if fs.isReadOnly(workPath..\"/\"..name) then\
- term.setTextColor(colors.red)\
- else\
- term.setTextColor(colors.black)\
- end\
- if windows.isFileHidden(name) then\
- term.setTextColor(colors.gray)\
- end\
- if hideFileFormat then\
- name = windows.hideFileFormat(name)\
- end\
- name = stringLimit(name,10)\
- usualText(math.floor(x+5-#name/2),y+5,name)\
- \
- end\
- \
- local function displayApps(workPath,currentDesktop,background)\
- \
- ObjApp = {}\
- ObjBottom = {}\
- \
- --clearScreen(background)\
- square(0,0,52,20,background)\
- \
- local files = fs.list(workPath)\
- \
- files = windows.reorganizeFilesAndFolders(workPath,files,showHiddenFiles,showSystemFolders)\
- \
- local countOfFiles = #files\
- countOfDesktops = math.ceil(countOfFiles/(countOfAppsByY*countOfAppsByX))\
- \
- local bottomButtonsStartX = nil\
- if #workPathHistory == 0 then\
- bottomButtonsStartX = centerX - math.floor((countOfDesktops*2+1)/2)\
- else\
- bottomButtonsStartX = centerX - math.floor((countOfDesktops*2-1)/2)\
- end\
- local bottomY = ySize-1\
- for i=1,countOfDesktops do\
- local bottomX = bottomButtonsStartX + i * 2\
- if currentDesktop == i then\
- paintutils.drawPixel(bottomX,bottomY,colors.white)\
- else\
- paintutils.drawPixel(bottomX,bottomY,colors.lightGray)\
- end\
- newObjBottom(i,bottomX,bottomY,1,1)\
- end\
- if #workPathHistory>0 then\
- paintutils.drawPixel(bottomButtonsStartX,bottomY,colors.white)\
- term.setTextColor(colors.black)\
- usualText(bottomButtonsStartX,bottomY,\"<\")\
- newObj(\"<\",bottomButtonsStartX,bottomY,1,1)\
- end\
- \
- \
- local appCounter = 1 + currentDesktop * countOfAppsByY * countOfAppsByX - countOfAppsByY * countOfAppsByX\
- for y = 1,countOfAppsByY do\
- for x = 1,countOfAppsByX do\
- if files[appCounter] ~= nil then\
- drawKonkretnoApp(startDisplayAllAppsFromX+x*(appWidth+2)-(appWidth+2),startDisplayAllAppsFromY+y*(appHeight+1)-(appHeight+1),files[appCounter],background,appCounter)\
- appCounter = appCounter + 1\
- else\
- break\
- end\
- end\
- end\
- appsbuddon()\
- end\
- local function launchFile(path,fileFormat,arguments)\
- if fileFormat == nil then\
- local success,err = loadfile(path)\
- if success ~= nil then\
- prepareToExit()\
- if arguments == nil then\
- shell.run(path)\
- else\
- shell.run(path..\" \"..arguments)\
- end\
- programFinished()\
- else\
- windows.error(err)\
- end\
- elseif fileFormat == \".app\" then\
- path = path..\"/main\"\
- local success,err = loadfile(path)\
- if success ~= nil then\
- prepareToExit()\
- if arguments == nil then\
- shell.run(path)\
- else\
- shell.run(path..\" \"..arguments)\
- end\
- --programFinished()\
- else\
- windows.error(err)\
- end\
- end\
- end\
- \
- \
- local function gotoDirectory(path)\
- workPathHistory[#workPathHistory+1] = workPath\
- workPath = path\
- currentDesktop = 1\
- end\
- \
- displayApps(workPath,currentDesktop,currentBackground)\
- \
- local exitFromProgram = false\
- while true do\
- if exitFromProgram then break end\
- \
- local appCounter = 1 + currentDesktop * countOfAppsByY * countOfAppsByX - countOfAppsByY * countOfAppsByX\
- \
- local event,side,x,y = os.pullEvent()\
- \
- if event == \"monitor_touch\" then side = 1 end\
- if event == \"mouse_click\" or event == \"monitor_touch\" then\
- \
- if side == 1 then\
- \
- local exit1 = false\
- \
- if #workPathHistory > 0 then\
- if x==Obj[\"<\"][\"x1\"] and y==Obj[\"<\"][\"y1\"] and #workPathHistory > 0 then\
- \
- term.setBackgroundColor(colors.blue)\
- term.setTextColor(colors.white)\
- usualText(Obj[\"<\"][\"x1\"],Obj[\"<\"][\"y1\"],\"<\")\
- sleep(0.2)\
- \
- workPath = workPathHistory[#workPathHistory]\
- workPathHistory[#workPathHistory] = nil\
- currentDesktop = 1\
- displayApps(workPath,currentDesktop,currentBackground)\
- exit1 = true\
- end\
- end\
- \
- for i=1,#ObjBottom do\
- if exit1 then break end\
- if x==ObjBottom[i][\"x1\"] and y==ObjBottom[i][\"y1\"] then\
- currentDesktop = i\
- displayApps(workPath,currentDesktop,currentBackground)\
- exit1=true\
- end\
- end\
- \
- for key,val in pairs(ObjApp) do\
- if exit1 then break end\
- for i=appCounter,(appCounter+countOfAppsOnDesktop-1) do\
- if exit1 then break end\
- if ObjApp[key][\"id\"] == i then\
- if x>=ObjApp[key][\"x1\"] and x<=ObjApp[key][\"x2\"] and y>=ObjApp[key][\"y1\"] and y<=ObjApp[key][\"y2\"] then\
- square(ObjApp[key][\"x1\"],ObjApp[key][\"y1\"],appWidth,appHeight,colors.blue)\
- drawKonkretnoApp(ObjApp[key][\"x1\"],ObjApp[key][\"y1\"],key,colors.blue,ObjApp[key][\"id\"])\
- sleep(0.2)\
- \
- local fileFormat = ObjApp[key][\"fileFormat\"]\
- \
- if not fs.isDir(workPath..\"/\"..key) then\
- \
- if key ~= \"OS\" and key ~= \"os\" and fileFormat == nil then\
- launchFile(workPath..\"/\"..key,fileFormat)\
- else\
- windows.attention({\"Can't open this\"},{\"Unknown file extension\"})\
- end\
- \
- exit1 = true\
- displayApps(workPath,currentDesktop,currentBackground)\
- else\
- if fileFormat == \".app\" then\
- launchFile(workPath..\"/\"..key,fileFormat)\
- displayApps(workPath,currentDesktop,currentBackground)\
- else\
- gotoDirectory(workPath..\"/\"..key)\
- appCounter = 1\
- displayApps(workPath,currentDesktop,currentBackground) \
- end\
- \
- exit1 = true\
- end\
- end\
- end\
- end\
- end\
- term.setCursorBlink(false)\
- \
- elseif event == \"mouse_scroll\" then\
- if side == -1 then\
- currentDesktop = currentDesktop + 1\
- if currentDesktop > countOfDesktops then\
- currentDesktop = countOfDesktops\
- else\
- displayApps(workPath,currentDesktop,currentBackground)\
- end\
- end\
- end\
- end\
- if x>=1 and x<=3 and y>=18 and y<=19 then\
- shell.run (\"/System/Apps/Desktop\")\
- else\
- end\
- end\
- prepareToExit()\
- --windows.tv(0)",
- path = "/rootfs/System/Apps/Drawer",
- },
- {
- text = " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04 04 04 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 4f 4f 4f 4f 4f 4f 4f 4f 4f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 4fLff 4f 4f 4f 4f 4f 4f 4f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 4fLffL4fi4fn4fO4fS4f 4f 4f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0fLff 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04 04 04 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00I80n80s80t80a80l80l80i80n80g80:80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 08 08 08 08 08 80 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03:88:88 88 88 88 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
- path = "/rootfs/System/Bootscr/111.png",
- },
- {
- text = " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04 04 04 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04>4f_4f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0f 0f 0f 0f 0f 0f 0f 0f 0f 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 04 04 04 04 04 04 04 04 04 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 80 80L80i80n80O80S80 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
- path = "/rootfs/System/Bootscr/boot.png",
- },
- {
- text = "{\
- rom = \"/rom\",\
- Images = \"/Images\",\
- Documents = \"/Documents\",\
- Root = \"\",\
- }",
- path = "/rootfs/System/Filemanager/Favourites.cfg",
- },
- {
- text = ".07.07.07\
- .07.07.07",
- path = "/rootfs/System/OS/Icons/apps.png",
- },
- {
- text = "###-80-80-80-80###\
- ###-80-80-80-80###\
- ###-80-80-80-80###\
- ###.e0ce0fe0ge0###",
- path = "/rootfs/System/OS/Icons/config.png",
- },
- {
- text = " 0f 0f 0f 0f 0f 0f\
- 0f>4f_0f 0f 0f 0f\
- 0f 0f 0f 0f 0f 0f\
- 0f 0f 0f 0f 0f 0f",
- path = "/rootfs/System/OS/Icons/default.png",
- },
- {
- text = " 07 07 07 07 07 07\
- 07 5f 5f 5f 5f 07\
- 08 f8 08 f8.e8.58\
- 08d78i78s78k78 08",
- path = "/rootfs/System/OS/Icons/disk.png",
- },
- {
- text = " 04 04############\
- -04-04-04-04-04-04\
- 04 04 04 04 04 04\
- ff4of4lf4df4ef4rf4",
- path = "/rootfs/System/OS/Icons/folder.png",
- },
- {
- text = " 30 3b 3b 3b 3b 30\
- 30 0bP0bS0b 0b 30\
- 30 fb fb fb fb 30\
- 30.f0pf0nf0gf0 30",
- path = "/rootfs/System/OS/Icons/image.png",
- },
- {
- text = " 80 80 80 80 80 80\
- 80 80O70S70 80 80\
- 80 80 80 80 80 80\
- 80v80380.80080 80",
- path = "/rootfs/System/OS/Icons/os.png",
- },
- {
- text = ",70-70-70-70,70###\
- |70 70 70 00|70###\
- z07i07p07 70|70###\
- |70_70_70_70|70###",
- path = "/rootfs/System/OS/Icons/zip.png",
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement