Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OS = {
- [ "MiOS/system/API/pastebin" ] = "--Thanks to standart pastebin program\
- function run(paste)\
- local response = http.get(\
- \"http://pastebin.com/raw/\"..textutils.urlEncode( paste )\
- )\
- \
- local sResponse = response.readAll()\
- response.close()\
- local func = loadstring(sResponse)\
- return func()\
- end",
- [ "MiOS/system/logo.pic" ] = "55 55 88888 88888\
- 5d5 5d5 5 87778 87777\
- 5 5 5 5 d 8 8 8\
- 5 d5d 5 5 8 8 88888\
- 5 5 5 5 8 8 77778\
- 5 d 5 5 8 8 8\
- 5 5 5 88888 88888\
- d d d 77777 77777",
- [ "MiOS/system/localization/english" ] = "{\
- \"MiOS\",\
- \"Press \",\
- \" to open menu\",\
- \">\",\
- \"Menu\",\
- \"Enter name!\",\
- \"Press key\",\
- \"Name\",\
- \"Password\",\
- \"Hello, \",\
- \"Computer will restart\",\
- menu2 = {\
- \"Set background color\",\
- \"Set text color\",\
- \"Set input text color\",\
- \"Set menu button\",\
- \"Change language\",\
- \"Edit user\",\
- \"Other\",\
- },\
- menu2Colors = {\
- \"White\",\
- \"Orange\",\
- \"Magenta\",\
- \"Light Blue\",\
- \"Yellow\",\
- \"Lime\",\
- \"Pink\",\
- \"Gray\",\
- \"Light Gray\",\
- \"Cyan\",\
- \"Purple\",\
- \"Blue\",\
- \"Brown\",\
- \"Green\",\
- \"Red\",\
- \"Black\",\
- },\
- menu2Colors1 = {\
- \"White\",\
- \"Light Gray\",\
- \"Gray\",\
- \"Black\",\
- },\
- login = {\
- \"Hello\",\
- \"Step 1/Create User\",\
- \"Name\",\
- \"Enter name!\",\
- \"Step 2/Create Password\",\
- \"Password\",\
- \"Thanks!\",\
- \"Login\",\
- \"Incorrect password!\",\
- \"Change language\",\
- table = {\
- \"I need the password\",\
- \"I don't need a password\",\
- },\
- },\
- menu3 = {\
- \"Draw logo\",\
- \"Start from disk\"\
- },\
- menu4 = {\
- \"New update\",\
- \"Updating\",\
- \"Update\",\
- \"No updates\",\
- \"We recommend you to install the updates\",\
- table = {\
- \"I need the update\",\
- \"I don't need a update\",\
- },\
- },\
- menu1 = {\
- \"Edit system\",\
- \"Update\",\
- \"Reboot\",\
- \"Shutdown\",\
- },\
- }",
- [ "MiOS/system/color" ] = "{ colored = {\
- \"white\",\
- \"orange\",\
- \"magenta\",\
- \"lightBlue\",\
- \"yellow\",\
- \"lime\",\
- \"pink\",\
- \"gray\",\
- \"lightGray\",\
- \"cyan\",\
- \"purple\",\
- \"blue\",\
- \"brown\",\
- \"green\",\
- \"red\",\
- \"black\",\
- },\
- notColored = {\
- \"white\",\
- \"lightGray\",\
- \"gray\",\
- \"black\",\
- },\
- }",
- [ "MiOS/system/shell.lua" ] = "local contextMenu = mainGUI.loadFunction(\"contextMenu\")\
- local readString = mainGUI.loadFunction(\"readString\")\
- local tumbler = mainGUI.loadFunction(\"tumbler\")\
- local logo = paintutils.loadImage(\"MiOS/system/logo.pic\")\
- local settings = osSettings.loadSettings()\
- local localization = osSettings.loadLocalization()\
- local cHistory = {}\
- local currentVersion = \"Last Build\"\
- local dirs = osSettings.loadDirs()\
- local color = osSettings.loadColors()\
- if fs.exists(\"MiOS/system/localization/\" ..settings.language) then\
- \009settings.language = \"english\"\
- end\
- if term.isColor then\
- \009color = color.colored\
- else\
- \009localization.menu2Colors = localization.menu2Colors1\
- \009color = color.notColored\
- end\
- local function drawLogo()\
- \009if settings.setting[1] == true and term.isColor() then\
- \009\009paintutils.drawImage(logo, 27, 10)\
- \009\009term.setBackgroundColor(colors.white)\
- \009end\
- end\
- \
- local menu1Functions = {}\
- \009menu1Functions[1] = function()\
- \009\009local var1\
- \009\009local set, set2\
- \009\009local login, password, col\
- \009\009local x,y\
- \009\009local language = {}\
- \009\009local language2 = {}\
- \009\009local localiz = {}\
- \009\009term.clear()\
- \009\009mainGUI.nameBar(localization.menu1[1])\
- \009\009drawLogo()\
- \009\009var1 = contextMenu:new(3,3,localization.menu2)\
- \009\009set = mainGUI.findInTable(localization.menu2, var1:use())\
- \009\009if set >= 1 and set <= 3 then\
- \009\009\009term.clear()\
- \009\009\009mainGUI.nameBar(localization.menu2[set])\
- \009\009\009drawLogo()\
- \009\009\009var1 = contextMenu:new(3,3,localization.menu2Colors)\
- \009\009\009set2 = mainGUI.findInTable(localization.menu2Colors, var1:use())\
- \009\009\009settings.color[set] = colors[color[set2]]\
- \009\009\009osSettings.rewrite(settings)\
- \009\009elseif set == 4 then\
- \009\009\009term.clear()\
- \009\009\009mainGUI.nameBar(localization.menu2[set])\
- \009\009\009drawLogo()\
- \009\009\009mainGUI.writeOnCenter(localization[7])\
- \009\009\009event, settings.button = os.pullEvent(\"key\")\
- \009\009\009term.clear()\
- \009\009\009mainGUI.nameBar(localization.menu2[set])\
- \009\009\009drawLogo()\009\
- \009\009\009osSettings.rewrite(settings)\
- \009\009\009sleep(1)\
- \009\009elseif set == 5 then\
- \009\009\009term.clear()\
- \009\009\009mainGUI.nameBar(localization.menu2[set])\
- \009\009\009drawLogo()\
- \009\009\009language = fs.list(dirs[3])\
- \009\009\009for i = 1, #language do\
- \009\009\009\009language2[i] = string.upper(string.sub(language[i], 1, 1)) ..string.sub(language[i], 2)\
- \009\009\009end\
- \009\009\009var1 = contextMenu:new(3,3,language2)\
- \009\009\009settings.language = language[mainGUI.findInTable(language2,var1:use())]\
- \009\009\009mainGUI.winAnimation()\
- \009\009\009mainGUI.writeOnCenter(localization[11])\
- \009\009\009mainGUI.waitForUser()\
- \009\009\009osSettings.rewrite(settings)\
- \009\009\009os.reboot()\
- \009\009elseif set == 6 then\
- \009\009\009term.clear()\
- \009\009\009x,y = mainGUI.getCenter(20,1)\
- \009\009\009login, password = logSystem.login()\
- \009\009\009var1 = readString:new(x,y,nil,20,colors.black,localization[8])\
- \009\009\009var2 = readString:new(x,y+2,nil,20,colors.black,localization[9])\
- \009\009\009mainGUI.nameBar(localization.menu2[4])\
- \009\009\009while true do\
- \009\009\009\009drawLogo()\
- \009\009\009\009term.setTextColor(colors.black)\
- \009\009\009\009term.setCursorPos(x+22,y)\
- \009\009\009\009write(login)\
- \009\009\009\009term.setCursorPos(x+22,y+2)\
- \009\009\009\009write(password)\
- \009\009\009\009var1:draw()\
- \009\009\009\009var2:draw()\
- \009\009\009\009login = var1:use()\
- \009\009\009\009password = var2:use()\
- \009\009\009\009if login ~= \"\" then\
- \009\009\009\009\009local user = fs.open(dirs[4], \"w\")\
- \009\009\009\009\009user.writeLine(login)\
- \009\009\009\009\009user.writeLine(password)\
- \009\009\009\009\009user.close()\
- \009\009\009\009\009os.setComputerLabel(login)\
- \009\009\009\009\009break\
- \009\009\009\009end\
- \009\009\009\009mainGUI.winAnimation(\"w\")\
- \009\009\009\009mainGUI.nameBar(localization[6])\
- \009\009\009end\
- \009\009elseif set == 7 then\
- \009\009\009while true do\
- \009\009\009\009for i = 1, #localization.menu3 do\
- \009\009\009\009\009localiz[i] = localization.menu3[i] ..\"/\" ..tostring(settings.setting[i])\
- \009\009\009\009end\
- \009\009\009\009term.clear()\
- \009\009\009\009term.setBackgroundColor(colors.white)\
- \009\009\009\009mainGUI.nameBar(localization.menu2[set])\
- \009\009\009\009drawLogo()\
- \009\009\009\009var1 = contextMenu:new(3,3,localiz)\
- \009\009\009\009set = mainGUI.findInTable(localiz, var1:use())\
- \009\009\009\009if settings.setting[set] == true then\
- \009\009\009\009\009settings.setting[set] = false\
- \009\009\009\009else\
- \009\009\009\009\009settings.setting[set] = true\
- \009\009\009\009end\
- \009\009\009\009osSettings.rewrite(settings)\
- \009\009\009end\
- \009\009end\
- \009end\
- \009menu1Functions[2] = function()\
- \009\009local ver = pastebin.run(\"0sEdXR0B\")\
- \009\009local x,y\
- \009\009local var1\
- \009\009term.clear()\
- \009\009mainGUI.winAnimation()\
- \009\009if ver ~= currentVersion then\
- \009\009\009mainGUI.writeOnCenter(localization.menu4[1] ..\" \" ..ver)\
- \009\009\009mainGUI.waitForUser()\
- \009\009\009mainGUI.nameBar(localization.menu4[3])\
- \009\009\009x,y = mainGUI.getCenter(string.len(localization.menu4.table[2]),2)\
- \009\009\009var1 = contextMenu:new(x,y, localization.menu4.table)\
- \009\009\009var1:draw()\
- \009\009\009if var1:use() == localization.menu4.table[1] then\
- \009\009\009\009mainGUI.winAnimation()\
- \009\009\009\009mainGUI.writeOnCenter(localization.menu4[2])\
- \009\009\009\009pastebin.run(\"q5VCDuKq\")\
- \009\009\009\009mainGUI.waitForUser()\
- \009\009\009\009os.reboot()\
- \009\009\009else\
- \009\009\009\009mainGUI.winAnimation()\
- \009\009\009\009mainGUI.writeOnCenter(localization.menu4[5])\
- \009\009\009\009mainGUI.waitForUser()\
- \009\009\009end\
- \009\009else\
- \009\009\009mainGUI.writeOnCenter(localization.menu4[4])\
- \009\009\009mainGUI.waitForUser()\
- \009\009end\
- \009end\
- \009menu1Functions[3] = function()\
- \009\009os.reboot()\
- \009end\
- \009menu1Functions[4] = function()\
- \009\009os.shutdown()\
- \009end\
- \
- local function checkForButton()\
- \009while true do\
- \009\009sleep(0)\
- \009\009local event, key = os.pullEvent(\"key\")\
- \009\009if key == settings.button then\
- \009\009\009break\
- \009\009end\
- \009end\
- end\
- \
- local function menu()\
- \009local var1\
- \009term.setCursorBlink(false)\
- \009term.setBackgroundColor(colors.white)\
- \009term.clear()\
- \009mainGUI.nameBar(localization[5])\
- \009drawLogo()\
- \009var1 = contextMenu:new(3,3,localization.menu1)\
- \009menu1Functions[mainGUI.findInTable(localization.menu1, var1:use())]()\
- end\
- \
- local function main()\
- \009local sLine\
- \009while true do\
- \009\009term.setBackgroundColor(settings.color[1])\
- \009\009term.clear()\
- \009\009mainGUI.nameBar(localization[1] ..\" \" ..currentVersion)\
- \009\009term.setTextColor(settings.color[2])\
- \009\009term.setCursorPos(1,2)\
- \009\009print(localization[2] ..keys.getName(settings.button) ..localization[3])\
- \009\009while true do\
- \009\009\009shell.setDir(dirs[5])\
- \009\009\009write(localization[4])\
- \009\009\009term.setTextColor(settings.color[3])\
- \009\009\009sLine = read(nil, cHistory, shell.complete)\
- \009\009\009shell.run(sLine)\
- \009\009\009if term.getBackgroundColor() ~= settings.color[1] then\
- \009\009\009\009break\
- \009\009\009end\
- \009\009\009term.setTextColor(settings.color[2])\
- \009\009end\
- \009end\
- end\
- \
- local login, password = logSystem.login()\
- term.clear()\
- mainGUI.writeOnCenter(localization[10] ..login)\
- mainGUI.waitForUser()\
- mainGUI.winAnimation(\"w\")\
- \
- \
- while true do\
- \009parallel.waitForAny(main,checkForButton)\
- \009parallel.waitForAny(menu,checkForButton)\
- end",
- [ "MiOS/system/API/mainGUI" ] = "function colorPalette()\
- \009local oldColor, color\
- \009oldColor = term.getBackgroundColor()\
- \009if oldColor == colors.gray then\
- \009\009color = colors.lightGray\
- \009else\
- \009\009color = colors.gray\
- \009end\
- \
- \009local oldTextColor = term.getTextColor()\
- \009if term.getBackgroundColor() == colors.white then\
- \009\009term.setTextColor(colors.black)\
- \009else\
- \009\009term.setTextColor(colors.white)\
- \009end\
- \
- \009return oldColor, color, oldTextColor\
- end\
- function getCenter(xSize, ySize)\
- \009if not x or y then\
- \009\009x,y = term.getSize()\
- \009end\
- \009if not xSize then\
- \009\009xSize = 0\
- \009end\
- \009if not ySize then\
- \009\009ySize = 0\
- \009end\
- \009x = math.floor(x/2 - xSize/2)\
- \009y = math.floor(y/2 - ySize/2)\
- \009\
- \009return x,y\
- end\
- function readLine( _sReplaceChar, _size )\
- term.setCursorBlink( true )\
- \
- local sLine = \"\"\
- local nHistoryPos\
- local nPos = 0\
- if _sReplaceChar then\
- _sReplaceChar = string.sub( _sReplaceChar, 1, 1 )\
- end\
- \
- if _size == nil then\
- \009_size = 99\
- end\
- \
- local w = term.getSize()\
- local sx = term.getCursorPos()\
- \
- local function redraw( _bClear )\
- local nScroll = 0\
- if sx + nPos >= w then\
- nScroll = (sx + nPos) - w\
- end\
- \
- local cx,cy = term.getCursorPos()\
- term.setCursorPos( sx, cy )\
- local sReplace = (_bClear and \" \") or _sReplaceChar\
- if sReplace then\
- write( string.rep( sReplace, math.max( string.len(sLine) - nScroll, 0 ) ) )\
- else\
- write( string.sub( sLine, nScroll + 1 ) )\
- end\
- \
- term.setCursorPos( sx + nPos - nScroll, cy )\
- end\
- \
- redraw()\
- \
- while true do\
- local sEvent, param = os.pullEvent()\
- if sEvent == \"char\" and string.len(sLine) ~= _size then\
- redraw( true )\
- sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )\
- nPos = nPos + 1\
- redraw()\
- elseif sEvent == \"key\" then\
- if param == keys.enter then\
- break\
- elseif param == keys.left then\
- if nPos > 0 then\
- redraw( true )\
- nPos = nPos - 1\
- redraw()\
- end\
- elseif param == keys.right then \
- if nPos < string.len(sLine) then\
- redraw( true )\
- nPos = nPos + 1\
- redraw()\
- end\
- elseif param == keys.backspace then\
- if nPos > 0 then\
- redraw( true )\
- sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )\
- nPos = nPos - 1\
- redraw()\
- end\
- elseif param == keys.home then\
- if nPos > 0 then\
- redraw( true )\
- nPos = 0\
- redraw()\
- end\
- elseif param == keys.delete then\
- if nPos < string.len(sLine) then\
- redraw( true )\
- sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 ) \
- redraw()\
- end\
- elseif param == keys[\"end\"] then\
- if nPos < string.len(sLine ) then\
- redraw( true )\
- nPos = string.len(sLine)\
- redraw()\
- end\
- end\
- elseif sEvent == \"term_resize\" then\
- w = term.getSize()\
- redraw()\
- elseif sEvent == \"mouse_click\" then\
- \009break\
- end\
- end\
- \
- local cx, cy = term.getCursorPos()\
- term.setCursorBlink( false )\
- term.setCursorPos( w + 1, cy )\
- print()\
- \
- return sLine\
- end\
- function drawPixelG(xPos, yPos, xSize, ySize, color)\
- \009local oldColor = term.getBackgroundColor()\
- \009term.setBackgroundColor(color)\
- \009for i = xPos, xSize+xPos-1, 1 do\
- \009\009for g = yPos, ySize+yPos-1, 1 do\
- \009\009\009term.setCursorPos(i,g)\
- \009\009\009write(\" \")\
- \009\009end\
- \009end\
- \009term.setBackgroundColor(oldColor)\
- end\
- function drawPixel(xPos, yPos, color)\
- \009local oldColor = term.getBackgroundColor()\
- \009term.setBackgroundColor(color)\
- \009term.setCursorPos(xPos,yPos)\
- \009write(\" \")\
- \009term.setBackgroundColor(oldColor)\
- end\
- \
- ---------------------------------------------\
- contextMenu = {}\
- function contextMenu:new(xPos,yPos,table)\
- \
- \009local lenght = string.len(table[1])\
- \009for i = 1, #table do\
- \009\009element = string.len(table[i])\
- \009\009if element > lenght then\
- \009\009\009lenght = element\
- \009\009end\
- \009end\
- \
- \009local oldColor, color = colorPalette()\
- \
- \009local arg = {}\
- \009\009arg.xPos = xPos\
- \009\009arg.yPos = yPos\
- \009\009arg.table = table\
- \009\009arg.oldColor = oldColor\
- \009\009arg.color = color\
- \009\009arg.oldTextColor = oldTextColor\
- \009\009arg.lenght = lenght\
- \
- \009function arg:draw(sel)\
- \009\009term.setCursorPos(self.xPos,self.yPos)\
- \009\009for i = 1, #table do\
- \009\009\009if i ~= sel then\
- \009\009\009\009term.setBackgroundColor(self.oldColor)\
- \009\009\009\009for g = 1, self.lenght+1 do\
- \009\009\009\009\009write(\" \")\
- \009\009\009\009end\
- \009\009\009\009term.setCursorPos(self.xPos,self.yPos+i-1)\
- \009\009\009\009write(\" \" ..self.table[i])\
- \009\009\009\009term.setCursorPos(self.xPos,self.yPos+i)\
- \009\009\009else\
- \009\009\009\009term.setCursorPos(self.xPos+1,self.yPos+i-1)\
- \009\009\009\009term.setBackgroundColor(self.color)\
- \009\009\009\009for g = 1, self.lenght do\
- \009\009\009\009\009write(\" \")\
- \009\009\009\009end\
- \009\009\009\009term.setCursorPos(self.xPos,self.yPos+i-1)\
- \009\009\009\009write(\">\" ..self.table[i])\
- \009\009\009\009term.setCursorPos(self.xPos,self.yPos+i)\
- \009\009\009end\
- \009\009end\
- \009end\
- \
- \009function arg:use()\
- \009\009self:draw(1)\
- \009\009self.oldColor = term.getBackgroundColor()\
- \009\009local ch\
- \009\009local function keyboard()\
- \009\009\009term.setCursorPos(self.xPos+1,self.yPos)\
- \009\009\009local cursorPos = 0\
- \009\009\009while true do\
- \
- \009\009\009\009local event, button, x, y = os.pullEvent()\
- \
- \009\009\009\009if event == \"key\" then \
- \009\009\009\009\009if button == 200 and cursorPos ~= 0 or event == \"mouse_scroll\" and button == -1 and cursorPos ~= 0 then\
- \009\009\009\009\009\009term.setCursorPos(self.xPos,self.yPos+cursorPos)\
- \
- \009\009\009\009\009\009cursorPos = cursorPos - 1\
- \009\009\009\009\009\009self:draw(cursorPos+1)\
- \
- \009\009\009\009\009elseif button == 208 and cursorPos ~= #table-1 then\
- \009\009\009\009\009\009term.setCursorPos(self.xPos,self.yPos+cursorPos)\
- \
- \009\009\009\009\009\009cursorPos = cursorPos + 1\
- \009\009\009\009\009\009self:draw(cursorPos+1)\
- \009\009\009\009\009elseif button == 28 then\
- \009\009\009\009\009\009ch = self.table[cursorPos+1]\
- \009\009\009\009\009\009break\
- \009\009\009\009\009end\
- \009\009\009\009elseif event == \"mouse_scroll\" then\
- \009\009\009\009\009if button == -1 and cursorPos ~= 0 then\
- \009\009\009\009\009\009term.setCursorPos(self.xPos,self.yPos+cursorPos)\
- \
- \009\009\009\009\009\009cursorPos = cursorPos - 1\
- \009\009\009\009\009\009self:draw(cursorPos+1)\
- \
- \009\009\009\009\009elseif button == 1 and cursorPos ~= #table-1 then\
- \009\009\009\009\009\009term.setCursorPos(self.xPos,self.yPos+cursorPos)\
- \
- \009\009\009\009\009\009cursorPos = cursorPos + 1\
- \009\009\009\009\009\009self:draw(cursorPos+1)\
- \009\009\009\009\009elseif button == 28 then\
- \009\009\009\009\009\009ch = self.table[cursorPos+1]\
- \009\009\009\009\009\009break\
- \009\009\009\009\009end\
- \009\009\009\009elseif event == \"mouse_click\" then\
- \009\009\009\009\009if y >= self.yPos and y <= self.yPos+#self.table-1 and x <= self.xPos+self.lenght and x >= self.xPos then\
- \009\009\009\009\009\009self:draw(y-self.yPos+1)\
- \009\009\009\009\009\009sleep(0.3)\
- \009\009\009\009\009\009ch = self.table[y-self.yPos+1]\
- \009\009\009\009\009\009break\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009\009term.setCursorPos(self.xPos,self.yPos+cursorPos)\
- \009\009\009end\
- \009\009end\
- \009\009keyboard()\
- \009\009term.setBackgroundColor(self.oldColor)\
- \009\009return ch\
- \009end\
- setmetatable(arg, self)\
- self.__index = self; return arg\
- end\
- ---------------------------------------------\
- tumbler = {}\
- function tumbler:new(xPos,yPos,table,table1)\
- \009local tHistory = {}\
- \009local oldColor, color, oldTextColor = colorPalette()\
- \009if table1 then\
- \009\009tHistory = table1\
- \009end\
- \
- \009local arg = {}\
- \009\009arg.xPos = xPos\
- \009\009arg.yPos = yPos\
- \009\009arg.table = table\
- \009\009arg.table1 = table1\
- \009\009arg.tHistory = tHistory\
- \009\009arg.oldColor = oldColor\
- \009\009arg.color = color\
- \009\009arg.oldTextColor = oldTextColor\
- \
- \009function arg:draw()\
- \009\009for i = 1, #self.table do\
- \009\009\009term.setCursorPos(self.xPos+2, self.yPos+i-1)\
- \009\009\009write(table[i])\
- \009\009end\
- \009\009term.setBackgroundColor(self.color)\
- \009\009for i = 1, #self.table do\
- \009\009\009term.setCursorPos(self.xPos, self.yPos+i-1)\
- \009\009\009if self.tHistory[i] == true then\
- \009\009\009\009write(\"O\")\
- \009\009\009else\
- \009\009\009\009write(\" \")\
- \009\009\009end\
- \009\009end\
- \009term.setBackgroundColor(self.oldColor)\
- \009term.setTextColor(self.oldTextColor)\
- \009end\
- \009function tumbler:use()\
- \009\009self:draw()\
- \009\009while true do\
- \009\009\009local event, button, x, y = os.pullEvent(\"mouse_click\")\
- \009\009\009if y-self.yPos+1 <= #self.table and y-self.yPos+1 >= 1 and x == self.xPos then\
- \009\009\009\009if self.tHistory[y-yPos+1] == false or self.tHistory[y-yPos+1] == nil then\
- \009\009\009\009\009self.tHistory = {}\
- \009\009\009\009\009self.tHistory[y-self.yPos+1] = true\
- \009\009\009\009end\
- \009\009\009else\
- \009\009\009\009return self.tHistory\
- \009\009\009end\
- \009\009\009self:draw()\
- \009\009end\
- \009end\
- \009setmetatable(arg, self)\
- \009self.__index = self; return arg\
- end\
- ---------------------------------------------\
- local readString = {}\
- function readString:new( xPos, yPos, _sReplaceChar, _size, color, text)\
- \009local arg = {}\
- \009\009arg.xPos = xPos\
- \009\009arg.yPos = yPos\
- \009\009arg._sReplaceChar = _sReplaceChar\
- \009\009arg._size = _size\
- \009\009arg.color = color\
- \009\009arg.text = text\
- \009function arg:draw()\
- \009\009drawPixelG(self.xPos,self.yPos, self._size, 1, self.color)\
- \009end\
- \009function arg:use()\
- \009\009self:draw()\
- \009\009local function textDraw(color)\
- \009\009\009if arg.text then\
- \009\009\009\009if color ~= colors.gray then\
- \009\009\009\009\009term.setTextColor(colors.gray)\
- \009\009\009\009\009write(arg.text)\
- \009\009\009\009else\
- \009\009\009\009\009term.setTextColor(colors.black)\
- \009\009\009\009\009write(arg.text)\
- \009\009\009\009end\
- \009\009\009\009term.setCursorPos(self.xPos,self.yPos)\
- \009\009\009end\
- \009\009end\
- \009\009term.setCursorPos(self.xPos,self.yPos)\
- \009\009local oldColor = term.getBackgroundColor()\
- \009\009term.setBackgroundColor(self.color)\
- \009\009local oldTextColor = term.getTextColor()\
- \009\009if term.getBackgroundColor() == colors.white then\
- \009\009\009textDraw(colors.black)\
- \009\009\009term.setTextColor(colors.black)\
- \009\009else\
- \009\009\009textDraw(colors.white)\
- \009\009\009term.setTextColor(colors.white)\
- \009\009end\
- \009\009local result = readLine(self._sReplaceChar,self._size)\
- \009\009term.setTextColor(oldTextColor)\
- \009\009return result\
- \009end\
- \009setmetatable(arg, self)\
- \009self.__index = self; return arg\
- end\
- function loadFunction(var)\
- \009if var == \"contextMenu\" then\
- \009\009return contextMenu\
- \009elseif var == \"tumbler\" then\
- \009\009return tumbler\
- \009elseif var == \"readString\" then\
- \009\009return readString\
- \009end\
- end\
- -----------------------------------------------------\
- function winAnimation(black)\
- \009local xSize, ySize = term.getSize()\
- \009if black == \"b\" then\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.clear()\
- \009\009sleep(0.03)\
- \009elseif black == \"w\" then\
- \009\009term.setBackgroundColor(colors.white)\
- \009\009term.clear()\
- \009\009sleep(0.03)\
- \009end\
- \009term.setBackgroundColor(colors.lightGray)\
- \009term.clear()\
- \009sleep(0.03)\
- \009term.setBackgroundColor(colors.gray)\
- \009term.clear()\
- \009sleep(0.03)\
- \009term.setBackgroundColor(colors.lightGray)\
- \009term.clear()\
- \009sleep(0.03)\
- \009term.setBackgroundColor(colors.white)\
- \009term.clear()\
- \009sleep(0.03)\
- end\
- \
- function nameBar(text)\
- \009local secondColor = colors.gray\
- \009local textColor = colors.white\
- \009local oldColor = term.getBackgroundColor()\
- \009local oldTextColor = term.getTextColor()\
- \009local xSize, ySize = term.getSize()\
- \
- \009term.clear()\
- \009drawPixelG(1, 1, xSize, 1, secondColor)\
- \009term.setCursorPos(2,1)\
- \009term.setBackgroundColor(secondColor)\
- \009term.setTextColor(textColor)\
- \009write(text)\
- \009term.setBackgroundColor(oldColor)\
- \009term.setTextColor(oldTextColor)\
- end\
- \
- function waitForUser()\
- \009sleep(0.1)\
- \009local event = os.pullEvent()\
- \009if event == \"key\" or event == \"mouse_click\" then\
- \009\009return\
- \009end\
- end\
- \
- function writeOnCenter(text)\
- \009local x,y = getCenter(string.len(text),1)\
- \009term.setCursorPos(x,y)\
- \009write(text)\
- end\
- \
- function findInTable(table, str)\
- \009for i = 1, #table do\
- \009\009if table[i] == str then\
- \009\009\009return i\
- \009\009end\
- \009end\
- \009return nil\
- end\
- \
- function getLongestElement(table)\
- \009local len = 0\
- \009for i = 1, #table do\
- \009\009if string.len(table[i]) > len then\
- \009\009\009len = string.len(table[i])\
- \009\009end\
- \009end\
- \009return len\
- end",
- [ "MiOS/system/API/osSettings" ] = "function loadDirs()\
- \009file = fs.open(\"MiOS/system/dirs\",\"r\")\
- \009data = file.readAll()\
- \009file.close()\
- \009return textutils.unserialize(data)\
- end\
- \
- function loadSettings()\
- \009local dirs = loadDirs()\
- \009if fs.exists(dirs[6]) then\
- \009\009local file = fs.open(dirs[6], \"r\")\
- \009\009local table = file.readAll()\
- \009\009file.close()\
- \009\009settings = textutils.unserialize(table)\
- \009else\
- \009\009settings = {\
- \009\009\009\009color = {\009colors.white, \
- \009\009\009\009\009\009\009colors.black, \
- \009\009\009\009\009\009\009colors.black},\
- \009\009\009\009button = 56,\
- \009\009\009\009setting = {\
- \009\009\009\009\009true,\
- \009\009\009\009\009false,\
- \009\009\009\009},\
- \009\009\009\009language = \"english\"\
- \009\009\009\009}\
- \009end\
- \009return settings\
- end\
- \
- function loadLocalization()\
- \009local dirs = loadDirs()\
- \009local settings = loadSettings()\
- \009file = fs.open(dirs[3] ..settings.language,\"r\")\
- \009data = file.readAll()\
- \009file.close()\
- \009return textutils.unserialize(data)\
- end\
- \
- function loadColors()\
- \009local dirs = loadDirs()\
- \009local settings = loadSettings()\
- \009file = fs.open(dirs[2],\"r\")\
- \009data = file.readAll()\
- \009file.close()\
- \009return textutils.unserialize(data)\
- end\
- \
- function rewrite(settings)\
- \009local dirs = loadDirs()\
- \009local file = fs.open(dirs[6],\"w\")\
- \009file.write(textutils.serialize(settings))\
- \009file.close()\
- end",
- [ "MiOS/system/localization/french" ] = "{\
- \"Pmi\",\
- \"La presse \",\
- \" pour ouvrir le menu\",\
- \">\",\
- \"Menu\",\
- \"Entrez le nom!\",\
- \"Appuyez sur la touche\",\
- \"Nom\",\
- \"Mot de passe\",\
- \"Bonjour, \",\
- \"L'ordinateur va redémarrer\",\
- menu2 = {\
- \"Définir la couleur d'arrière-plan\",\
- \"Définir la couleur du texte\",\
- \"D'entrée de jeu la couleur du texte\",\
- \"Définir le bouton de menu\",\
- \"Changer de langue\",\
- \"Modifier l'utilisateur\",\
- \"Les autres\",\
- },\
- menu2Colors = {\
- \"Blanc\",\
- \"Orange\",\
- \"Magenta\",\
- \"La Lumière Bleue\",\
- \"Jaune\",\
- \"La chaux\",\
- \"Rose\",\
- \"Gris\",\
- \"Gris Clair\",\
- \"Cyan\",\
- \"Violet\",\
- \"Bleu\",\
- \"Le brun\",\
- \"Vert\",\
- \"Rouge\",\
- \"Noir\",\
- },\
- menu2Colors1 = {\
- \"Blanc\",\
- \"Gris Clair\",\
- \"Gris\",\
- \"Noir\",\
- },\
- login = {\
- \"Bonjour\",\
- \"Étape 1/Créer Un Utilisateur\",\
- \"Nom\",\
- \"Entrez le nom!\",\
- \"Étape 2/Créer Un Mot De Passe\",\
- \"Mot de passe\",\
- \"Merci!\",\
- \"Login\",\
- \"Mot de passe Incorrect!\",\
- \"Changer de langue\",\
- table = {\
- \"J'ai besoin du mot de passe\",\
- \"Je n'ai pas besoin d'un mot de passe\",\
- },\
- },\
- menu3 = {\
- \"Dessiner logo\",\
- \"Démarrer à partir du disque\"\
- },\
- menu4 = {\
- \"Nouvelle mise à jour\",\
- \"Mise à jour\",\
- \"Mise à jour\",\
- \"Pas de mises à jour\",\
- \"Nous vous recommandons d'installer les mises à jour\",\
- table = {\
- \"J'ai besoin de la mise à jour\",\
- \"Je n'ai pas besoin d'une mise à jour\",\
- },\
- },\
- menu1 = {\
- \"Modifier le système\",\
- \"Mise à jour\",\
- \"Reboot\",\
- \"Shutdown\",\
- },\
- }",
- [ "MiOS/system/dirs" ] = "{\
- \"MiOS/system/logo.pic\",\
- \"MiOS/system/color\",\
- \"MiOS/system/localization/\",\
- \"MiOS/user/user.txt\",\
- \"MiOS/user/files\",\
- \"MiOS/user/settings.txt\",\
- }",
- startup = "os.loadAPI(\"MiOS/system/API/mainGUI\")\
- os.loadAPI(\"MiOS/system/API/logSystem\")\
- os.loadAPI(\"MiOS/system/API/osSettings\")\
- os.loadAPI(\"MiOS/system/API/pastebin\")\
- settings.set(\"bios.use_multishell\", false)\
- local setting = osSettings.loadSettings()\
- settings.set(\"shell.allow_disk_startup\", setting.setting[2])\
- settings.save(\".settings\")\
- shell.run(\"MiOS/system/shell.lua\")",
- [ ".settings" ] = "{\
- [ \"bios.use_multishell\" ] = false,\
- [ \"shell.autocomplete\" ] = true,\
- [ \"shell.allow_disk_startup\" ] = false,\
- [ \"shell.allow_startup\" ] = true,\
- [ \"lua.autocomplete\" ] = true,\
- [ \"list.show_hidden\" ] = false,\
- [ \"edit.autocomplete\" ] = true,\
- }",
- [ "MiOS/system/API/logSystem" ] = "function login()\
- \009local var1, table\
- \009local x, y\
- \009local login, password\
- \009local readString = mainGUI.loadFunction(\"readString\")\
- \009local contextMenu = mainGUI.loadFunction(\"contextMenu\")\
- \009local localization = osSettings.loadLocalization()\
- \009local settings = osSettings.loadSettings()\
- \009local dirs = osSettings.loadDirs()\
- \009local language, language2 = {}, {}\
- \009term.setTextColor(colors.black)\
- \
- \009if not fs.exists(dirs[4]) then\
- \009\009mainGUI.winAnimation()\
- \009\009mainGUI.nameBar(localization.login[10])\
- \009\009language = fs.list(dirs[3])\
- \009\009for i = 1, #language do\
- \009\009\009language2[i] = string.upper(string.sub(language[i], 1, 1)) ..string.sub(language[i], 2)\
- \009\009end\
- \009\009x,y = mainGUI.getCenter(mainGUI.getLongestElement(language2),#language2)\
- \009\009var1 = contextMenu:new(x,y,language2)\
- \009\009settings.language = language[mainGUI.findInTable(language2,var1:use())]\
- \009\009osSettings.rewrite(settings)\
- \009\009localization = osSettings.loadLocalization()\
- \009\009\
- \009\009mainGUI.winAnimation()\
- \009\009mainGUI.writeOnCenter(localization.login[1])\
- \009\009mainGUI.waitForUser()\
- \009\009mainGUI.winAnimation()\
- \
- \009\009mainGUI.nameBar(localization.login[2])\
- \009\009while true do\
- \009\009\009x,y = mainGUI.getCenter(20,1)\
- \009\009\009var1 = readString:new(x,y,nil,20,colors.black,localization.login[3])\
- \009\009\009var1:draw()\
- \009\009\009login = var1:use()\
- \009\009\009mainGUI.winAnimation(\"w\")\
- \009\009\009if login == \"\" then\
- \009\009\009\009mainGUI.nameBar(localization.login[4])\
- \009\009\009else\
- \009\009\009\009break\
- \009\009\009end\
- \009\009end\
- \
- \009\009x,y = mainGUI.getCenter(string.len(localization.login.table[2]),2)\
- \009\009mainGUI.nameBar(localization.login[5])\
- \009\009var1 = contextMenu:new(x,y, localization.login.table)\
- \009\009var1:draw()\
- \009\009if var1:use() == localization.login.table[1] then\
- \009\009\009x,y = mainGUI.getCenter(20,1)\
- \009\009\009var1 = readString:new(x,y+2,\"*\",20,colors.black,localization.login[6])\
- \009\009\009var1:draw()\
- \009\009\009password = var1:use()\
- \009\009end\
- \
- \009\009local file = fs.open(dirs[4], \"w\")\
- \009\009file.writeLine(login)\
- \009\009file.writeLine(password)\
- \009\009file.close()\
- \
- \009\009mainGUI.winAnimation(\"w\")\
- \009\009mainGUI.writeOnCenter(localization.login[7])\
- \009\009mainGUI.waitForUser()\
- \009\009os.reboot()\
- \009end\
- \009mainGUI.winAnimation(\"w\")\
- \
- \009local file = fs.open(dirs[4], \"r\")\
- \009login = file.readLine()\
- \009password = file.readLine()\
- \009file.close()\
- \
- \009term.setTextColor(colors.black)\
- \009mainGUI.nameBar(localization.login[8])\
- \
- \009if password ~= \"\" then\
- \009\009while true do\
- \009\009\009x,y = mainGUI.getCenter(20,1)\
- \009\009\009var1 = readString:new(x,y+2,\"*\",20,colors.black,localization.login[6])\
- \009\009\009mainGUI.writeOnCenter(login)\
- \009\009\009var1:draw()\
- \009\009\009if var1:use() ~= password then\
- \009\009\009\009mainGUI.winAnimation(\"w\")\
- \009\009\009\009mainGUI.nameBar(localization.login[9])\
- \009\009\009else\
- \009\009\009\009mainGUI.winAnimation(\"w\")\
- \009\009\009\009break\
- \009\009\009end\
- \009\009end\
- \009end\
- \009return login, password\
- end",
- }
- path = {
- "MiOS/system/logo.pic",
- "MiOS/system/shell.lua",
- "MiOS/system/color",
- "MiOS/system/API/osSettings",
- "MiOS/system/API/mainGUI",
- "MiOS/system/API/logSystem",
- "MiOS/system/API/pastebin",
- "MiOS/system/localization/english",
- "MiOS/system/localization/french",
- "MiOS/system/dirs",
- "startup",
- ".settings",
- }
- for i = 1, #path do
- file = fs.open(path[i],"w")
- file.writeLine(OS[path[i]])
- file.close()
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement