Advertisement
sosochka

Main.lua

Jan 7th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.09 KB | None | 0 0
  1.  
  2. -- Checking for required components
  3. local function getComponentAddress(name)
  4.     return component.list(name)() or error("Required " .. name .. " component is missing")
  5. end
  6.  
  7. local EEPROMAddress, internetAddress, GPUAddress =
  8.     getComponentAddress("eeprom"),
  9.     getComponentAddress("internet"),
  10.     getComponentAddress("gpu")
  11.  
  12. -- Binding GPU to screen in case it's not done yet
  13. component.invoke(GPUAddress, "bind", getComponentAddress("screen"))
  14. local screenWidth, screenHeight = component.invoke(GPUAddress, "getResolution")
  15.  
  16. local repositoryURL = "https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/"
  17. local installerURL = "Installer/"
  18. local EFIURL = "EFI/Minified.lua"
  19.  
  20. local installerPath = "/MineOS installer/"
  21. local installerPicturesPath = installerPath .. "Installer/Pictures/"
  22. local OSPath = "/"
  23.  
  24. local temporaryFilesystemProxy, selectedFilesystemProxy
  25.  
  26. --------------------------------------------------------------------------------
  27.  
  28. -- Working with components directly before system libraries are downloaded & initialized
  29. local function centrize(width)
  30.     return math.floor(screenWidth / 2 - width / 2)
  31. end
  32.  
  33. local function centrizedText(y, color, text)
  34.     component.invoke(GPUAddress, "fill", 1, y, screenWidth, 1, " ")
  35.     component.invoke(GPUAddress, "setForeground", color)
  36.     component.invoke(GPUAddress, "set", centrize(#text), y, text)
  37. end
  38.  
  39. local function title()
  40.     local y = math.floor(screenHeight / 2 - 1)
  41.     centrizedText(y, 0x2D2D2D, "MineOS")
  42.  
  43.     return y + 2
  44. end
  45.  
  46. local function progress(value)
  47.     local width = 26
  48.     local x, y, part = centrize(width), title(), math.ceil(width * value)
  49.    
  50.     component.invoke(GPUAddress, "setForeground", 0x878787)
  51.     component.invoke(GPUAddress, "set", x, y, string.rep("─", part))
  52.     component.invoke(GPUAddress, "setForeground", 0xC3C3C3)
  53.     component.invoke(GPUAddress, "set", x + part, y, string.rep("─", width - part))
  54. end
  55.  
  56. local function filesystemPath(path)
  57.     return path:match("^(.+%/).") or ""
  58. end
  59.  
  60. local function filesystemName(path)
  61.     return path:match("%/?([^%/]+%/?)$")
  62. end
  63.  
  64. local function filesystemHideExtension(path)
  65.     return path:match("(.+)%..+") or path
  66. end
  67.  
  68. local function rawRequest(url, chunkHandler)
  69.     local internetHandle, reason = component.invoke(internetAddress, "request", repositoryURL .. url:gsub("([^%w%-%_%.%~])", function(char)
  70.         return string.format("%%%02X", string.byte(char))
  71.     end))
  72.  
  73.     if internetHandle then
  74.         local chunk, reason
  75.         while true do
  76.             chunk, reason = internetHandle.read(math.huge) 
  77.            
  78.             if chunk then
  79.                 chunkHandler(chunk)
  80.             else
  81.                 if reason then
  82.                     error("Internet request failed: " .. tostring(reason))
  83.                 end
  84.  
  85.                 break
  86.             end
  87.         end
  88.  
  89.         internetHandle.close()
  90.     else
  91.         error("Connection failed: " .. url)
  92.     end
  93. end
  94.  
  95. local function request(url)
  96.     local data = ""
  97.    
  98.     rawRequest(url, function(chunk)
  99.         data = data .. chunk
  100.     end)
  101.  
  102.     return data
  103. end
  104.  
  105. local function download(url, path)
  106.     selectedFilesystemProxy.makeDirectory(filesystemPath(path))
  107.  
  108.     local fileHandle, reason = selectedFilesystemProxy.open(path, "wb")
  109.     if fileHandle then 
  110.         rawRequest(url, function(chunk)
  111.             selectedFilesystemProxy.write(fileHandle, chunk)
  112.         end)
  113.  
  114.         selectedFilesystemProxy.close(fileHandle)
  115.     else
  116.         error("File opening failed: " .. tostring(reason))
  117.     end
  118. end
  119.  
  120. local function deserialize(text)
  121.     local result, reason = load("return " .. text, "=string")
  122.     if result then
  123.         return result()
  124.     else
  125.         error(reason)
  126.     end
  127. end
  128.  
  129. -- Clearing screen
  130. component.invoke(GPUAddress, "setBackground", 0xE1E1E1)
  131. component.invoke(GPUAddress, "fill", 1, 1, screenWidth, screenHeight, " ")
  132.  
  133. -- Checking minimum system requirements
  134. do
  135.     local function warning(text)
  136.         centrizedText(title(), 0x878787, text)
  137.  
  138.         local signal
  139.         repeat
  140.             signal = computer.pullSignal()
  141.         until signal == "key_down" or signal == "touch"
  142.  
  143.         computer.shutdown()
  144.     end
  145.  
  146.     if component.invoke(GPUAddress, "getDepth") ~= 8 then
  147.         warning("Tier 3 GPU and screen are required")
  148.     end
  149.  
  150.     if computer.totalMemory() < 1024 * 1024 * 2 then
  151.         warning("At least 2x Tier 3.5 RAM modules are required")
  152.     end
  153.  
  154.     -- Searching for appropriate temporary filesystem for storing libraries, images, etc
  155.     for address in component.list("filesystem") do
  156.         local proxy = component.proxy(address)
  157.         if proxy.spaceTotal() >= 2 * 1024 * 1024 then
  158.             temporaryFilesystemProxy, selectedFilesystemProxy = proxy, proxy
  159.             break
  160.         end
  161.     end
  162.  
  163.     -- If there's no suitable HDDs found - then meow
  164.     if not temporaryFilesystemProxy then
  165.         warning("At least Tier 2 HDD is required")
  166.     end
  167. end
  168.  
  169. -- First, we need a big ass file list with localizations, applications, wallpapers
  170. progress(0)
  171. local files = deserialize(request(installerURL .. "Files.cfg"))
  172.  
  173. -- After that we could download required libraries for installer from it
  174. for i = 1, #files.installerFiles do
  175.     progress(i / #files.installerFiles)
  176.     download(files.installerFiles[i], installerPath .. files.installerFiles[i])
  177. end
  178.  
  179. -- Initializing simple package system for loading system libraries
  180. package = {loading = {}, loaded = {}}
  181.  
  182. function require(module)
  183.     if package.loaded[module] then
  184.         return package.loaded[module]
  185.     elseif package.loading[module] then
  186.         error("already loading " .. module .. ": " .. debug.traceback())
  187.     else
  188.         package.loading[module] = true
  189.  
  190.         local handle, reason = temporaryFilesystemProxy.open(installerPath .. "Libraries/" .. module .. ".lua", "rb")
  191.         if handle then
  192.             local data, chunk = ""
  193.             repeat
  194.                 chunk = temporaryFilesystemProxy.read(handle, math.huge)
  195.                 data = data .. (chunk or "")
  196.             until not chunk
  197.  
  198.             temporaryFilesystemProxy.close(handle)
  199.            
  200.             local result, reason = load(data, "=" .. module)
  201.             if result then
  202.                 package.loaded[module] = result() or true
  203.             else
  204.                 error(reason)
  205.             end
  206.         else
  207.             error("File opening failed: " .. tostring(reason))
  208.         end
  209.  
  210.         package.loading[module] = nil
  211.  
  212.         return package.loaded[module]
  213.     end
  214. end
  215.  
  216. -- Initializing system libraries
  217. local filesystem = require("Filesystem")
  218. filesystem.setProxy(temporaryFilesystemProxy)
  219.  
  220. bit32 = bit32 or require("Bit32")
  221. local image = require("Image")
  222. local text = require("Text")
  223. local number = require("Number")
  224.  
  225. local screen = require("Screen")
  226. screen.setGPUAddress(GPUAddress)
  227.  
  228. local GUI = require("GUI")
  229. local system = require("System")
  230. local paths = require("Paths")
  231.  
  232. --------------------------------------------------------------------------------
  233.  
  234. -- Creating main UI workspace
  235. local workspace = GUI.workspace()
  236. workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x1E1E1E))
  237.  
  238. -- Main installer window
  239. local window = workspace:addChild(GUI.window(1, 1, 80, 24))
  240. window.localX, window.localY = math.ceil(workspace.width / 2 - window.width / 2), math.ceil(workspace.height / 2 - window.height / 2)
  241. window:addChild(GUI.panel(1, 1, window.width, window.height, 0xE1E1E1))
  242.  
  243. -- Top menu
  244. local menu = workspace:addChild(GUI.menu(1, 1, workspace.width, 0xF0F0F0, 0x787878, 0x3366CC, 0xE1E1E1))
  245. local installerMenu = menu:addContextMenuItem("MineOS", 0x2D2D2D)
  246.  
  247. installerMenu:addItem("🗘", "Reboot").onTouch = function()
  248.     computer.shutdown(true)
  249. end
  250.  
  251. installerMenu:addItem("⏻", "Shutdown").onTouch = function()
  252.     computer.shutdown()
  253. end
  254.  
  255. -- Main vertical layout
  256. local layout = window:addChild(GUI.layout(1, 1, window.width, window.height - 2, 1, 1))
  257.  
  258. local stageButtonsLayout = window:addChild(GUI.layout(1, window.height - 1, window.width, 1, 1, 1))
  259. stageButtonsLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
  260. stageButtonsLayout:setSpacing(1, 1, 3)
  261.  
  262. local function loadImage(name)
  263.     return image.load(installerPicturesPath .. name .. ".pic")
  264. end
  265.  
  266. local function newInput(width, ...)
  267.     return GUI.input(1, 1, width, 1, 0xF0F0F0, 0x787878, 0xC3C3C3, 0xF0F0F0, 0x878787, "", ...)
  268. end
  269.  
  270. local function newSwitchAndLabel(width, color, text, state)
  271.     return GUI.switchAndLabel(1, 1, width, 6, color, 0xD2D2D2, 0xF0F0F0, 0xA5A5A5, text .. ":", state)
  272. end
  273.  
  274. local function addTitle(color, text)
  275.     return layout:addChild(GUI.text(1, 1, color, text))
  276. end
  277.  
  278. local function addImage(before, after, name)
  279.     if before > 0 then
  280.         layout:addChild(GUI.object(1, 1, 1, before))
  281.     end
  282.  
  283.     local picture = layout:addChild(GUI.image(1, 1, loadImage(name)))
  284.     picture.height = picture.height + after
  285.  
  286.     return picture
  287. end
  288.  
  289. local function addStageButton(text)
  290.     local button = stageButtonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xC3C3C3, 0x878787, 0xA5A5A5, 0x696969, text))
  291.     button.colors.disabled.background = 0xD2D2D2
  292.     button.colors.disabled.text = 0xB4B4B4
  293.  
  294.     return button
  295. end
  296.  
  297. local prevButton = addStageButton("<")
  298. local nextButton = addStageButton(">")
  299.  
  300. local localization
  301. local stage = 1
  302. local stages = {}
  303.  
  304. local usernameInput = newInput(30, "")
  305. local passwordInput = newInput(30, "", false, "•")
  306. local passwordSubmitInput = newInput(30, "", false, "•")
  307. local usernamePasswordText = GUI.text(1, 1, 0xCC0040, "")
  308. local withoutPasswordSwitchAndLabel = newSwitchAndLabel(30, 0x66DB80, "", false)
  309.  
  310. local wallpapersSwitchAndLabel = newSwitchAndLabel(30, 0xFF4980, "", true)
  311. local applicationsSwitchAndLabel = newSwitchAndLabel(30, 0x33DB80, "", true)
  312. local localizationsSwitchAndLabel = newSwitchAndLabel(30, 0x33B6FF, "", true)
  313.  
  314. local acceptSwitchAndLabel = newSwitchAndLabel(30, 0x9949FF, "", false)
  315.  
  316. local localizationComboBox = GUI.comboBox(1, 1, 26, 1, 0xF0F0F0, 0x969696, 0xD2D2D2, 0xB4B4B4)
  317. for i = 1, #files.localizations do
  318.     localizationComboBox:addItem(filesystemHideExtension(filesystemName(files.localizations[i]))).onTouch = function()
  319.         -- Obtaining localization table
  320.         localization = deserialize(request(installerURL .. files.localizations[i]))
  321.  
  322.         -- Filling widgets with selected localization data
  323.         usernameInput.placeholderText = localization.username
  324.         passwordInput.placeholderText = localization.password
  325.         passwordSubmitInput.placeholderText = localization.submitPassword
  326.         withoutPasswordSwitchAndLabel.label.text = localization.withoutPassword
  327.         wallpapersSwitchAndLabel.label.text = localization.wallpapers
  328.         applicationsSwitchAndLabel.label.text = localization.applications
  329.         localizationsSwitchAndLabel.label.text = localization.languages
  330.         acceptSwitchAndLabel.label.text = localization.accept
  331.     end
  332. end
  333.  
  334. local function addStage(onTouch)
  335.     table.insert(stages, function()
  336.         layout:removeChildren()
  337.         onTouch()
  338.         workspace:draw()
  339.     end)
  340. end
  341.  
  342. local function loadStage()
  343.     if stage < 1 then
  344.         stage = 1
  345.     elseif stage > #stages then
  346.         stage = #stages
  347.     end
  348.  
  349.     stages[stage]()
  350. end
  351.  
  352. local function checkUserInputs()
  353.     local nameEmpty = #usernameInput.text == 0
  354.     local nameVaild = usernameInput.text:match("^%w[%w%s_]+$")
  355.     local passValid = withoutPasswordSwitchAndLabel.switch.state or #passwordInput.text == 0 or #passwordSubmitInput.text == 0 or passwordInput.text == passwordSubmitInput.text
  356.  
  357.     if (nameEmpty or nameVaild) and passValid then
  358.         usernamePasswordText.hidden = true
  359.         nextButton.disabled = nameEmpty or not nameVaild or not passValid
  360.     else
  361.         usernamePasswordText.hidden = false
  362.         nextButton.disabled = true
  363.  
  364.         if nameVaild then
  365.             usernamePasswordText.text = localization.passwordsArentEqual
  366.         else
  367.             usernamePasswordText.text = localization.usernameInvalid
  368.         end
  369.     end
  370. end
  371.  
  372. local function checkLicense()
  373.     nextButton.disabled = not acceptSwitchAndLabel.switch.state
  374. end
  375.  
  376. prevButton.onTouch = function()
  377.     stage = stage - 1
  378.     loadStage()
  379. end
  380.  
  381. nextButton.onTouch = function()
  382.     stage = stage + 1
  383.     loadStage()
  384. end
  385.  
  386. acceptSwitchAndLabel.switch.onStateChanged = function()
  387.     checkLicense()
  388.     workspace:draw()
  389. end
  390.  
  391. withoutPasswordSwitchAndLabel.switch.onStateChanged = function()
  392.     passwordInput.hidden = withoutPasswordSwitchAndLabel.switch.state
  393.     passwordSubmitInput.hidden = withoutPasswordSwitchAndLabel.switch.state
  394.     checkUserInputs()
  395.  
  396.     workspace:draw()
  397. end
  398.  
  399. usernameInput.onInputFinished = function()
  400.     checkUserInputs()
  401.     workspace:draw()
  402. end
  403.  
  404. passwordInput.onInputFinished = usernameInput.onInputFinished
  405. passwordSubmitInput.onInputFinished = usernameInput.onInputFinished
  406.  
  407. -- Localization selection stage
  408. addStage(function()
  409.     prevButton.disabled = true
  410.  
  411.     addImage(0, 1, "Languages")
  412.     layout:addChild(localizationComboBox)
  413.  
  414.     workspace:draw()
  415.     localizationComboBox:getItem(1).onTouch()
  416. end)
  417.  
  418. -- Filesystem selection stage
  419. addStage(function()
  420.     prevButton.disabled = false
  421.     nextButton.disabled = false
  422.  
  423.     layout:addChild(GUI.object(1, 1, 1, 1))
  424.     addTitle(0x696969, localization.select)
  425.    
  426.     local diskLayout = layout:addChild(GUI.layout(1, 1, layout.width, 11, 1, 1))
  427.     diskLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
  428.     diskLayout:setSpacing(1, 1, 1)
  429.  
  430.     local HDDImage = loadImage("HDD")
  431.  
  432.     local function select(proxy)
  433.         selectedFilesystemProxy = proxy
  434.  
  435.         for i = 1, #diskLayout.children do
  436.             diskLayout.children[i].children[1].hidden = diskLayout.children[i].proxy ~= selectedFilesystemProxy
  437.         end
  438.     end
  439.  
  440.     local function updateDisks()
  441.         local function diskEventHandler(workspace, disk, e1)
  442.             if e1 == "touch" then
  443.                 select(disk.proxy)
  444.                 workspace:draw()
  445.             end
  446.         end
  447.  
  448.         local function addDisk(proxy, picture, disabled)
  449.             local disk = diskLayout:addChild(GUI.container(1, 1, 14, diskLayout.height))
  450.             disk.blockScreenEvents = true
  451.  
  452.             disk:addChild(GUI.panel(1, 1, disk.width, disk.height, 0xD2D2D2))
  453.  
  454.             disk:addChild(GUI.button(1, disk.height, disk.width, 1, 0xCC4940, 0xE1E1E1, 0x990000, 0xE1E1E1, localization.erase)).onTouch = function()
  455.                 local list, path = proxy.list("/")
  456.                 for i = 1, #list do
  457.                     path = "/" .. list[i]
  458.  
  459.                     if proxy.address ~= temporaryFilesystemProxy.address or path ~= installerPath then
  460.                         proxy.remove(path)
  461.                     end
  462.                 end
  463.  
  464.                 updateDisks()
  465.             end
  466.  
  467.             if disabled then
  468.                 picture = image.blend(picture, 0xFFFFFF, 0.4)
  469.                 disk.disabled = true
  470.             end
  471.  
  472.             disk:addChild(GUI.image(4, 2, picture))
  473.             disk:addChild(GUI.label(2, 7, disk.width - 2, 1, disabled and 0x969696 or 0x696969, text.limit(proxy.getLabel() or proxy.address, disk.width - 2))):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
  474.             disk:addChild(GUI.progressBar(2, 8, disk.width - 2, disabled and 0xCCDBFF or 0x66B6FF, disabled and 0xD2D2D2 or 0xC3C3C3, disabled and 0xC3C3C3 or 0xA5A5A5, math.floor(proxy.spaceUsed() / proxy.spaceTotal() * 100), true, true, "", "% " .. localization.used))
  475.  
  476.             disk.eventHandler = diskEventHandler
  477.             disk.proxy = proxy
  478.         end
  479.  
  480.         diskLayout:removeChildren()
  481.        
  482.         for address in component.list("filesystem") do
  483.             local proxy = component.proxy(address)
  484.             if proxy.spaceTotal() >= 1 * 1024 * 1024 then
  485.                 addDisk(
  486.                     proxy,
  487.                     proxy.spaceTotal() < 1 * 1024 * 1024 and floppyImage or HDDImage,
  488.                     proxy.isReadOnly() or proxy.spaceTotal() < 2 * 1024 * 1024
  489.                 )
  490.             end
  491.         end
  492.  
  493.         select(selectedFilesystemProxy)
  494.     end
  495.    
  496.     updateDisks()
  497. end)
  498.  
  499. -- User profile setup stage
  500. addStage(function()
  501.     checkUserInputs()
  502.  
  503.     addImage(0, 0, "User")
  504.     addTitle(0x696969, localization.setup)
  505.  
  506.     layout:addChild(usernameInput)
  507.     layout:addChild(passwordInput)
  508.     layout:addChild(passwordSubmitInput)
  509.     layout:addChild(usernamePasswordText)
  510.     layout:addChild(withoutPasswordSwitchAndLabel)
  511. end)
  512.  
  513. -- Downloads customization stage
  514. addStage(function()
  515.     nextButton.disabled = false
  516.  
  517.     addImage(0, 0, "Settings")
  518.     addTitle(0x696969, localization.customize)
  519.  
  520.     layout:addChild(wallpapersSwitchAndLabel)
  521.     layout:addChild(applicationsSwitchAndLabel)
  522.     layout:addChild(localizationsSwitchAndLabel)
  523. end)
  524.  
  525. -- License acception stage
  526. addStage(function()
  527.     checkLicense()
  528.  
  529.     local lines = text.wrap({request("LICENSE")}, layout.width - 2)
  530.     local textBox = layout:addChild(GUI.textBox(1, 1, layout.width, layout.height - 3, 0xF0F0F0, 0x696969, lines, 1, 1, 1))
  531.  
  532.     layout:addChild(acceptSwitchAndLabel)
  533. end)
  534.  
  535. -- Downloading stage
  536. addStage(function()
  537.     stageButtonsLayout:removeChildren()
  538.    
  539.     -- Creating user profile
  540.     layout:removeChildren()
  541.     addImage(1, 1, "User")
  542.     addTitle(0x969696, localization.creating)
  543.     workspace:draw()
  544.  
  545.     -- Renaming if possible
  546.     if not selectedFilesystemProxy.getLabel() then
  547.         selectedFilesystemProxy.setLabel("MineOS HDD")
  548.     end
  549.  
  550.     local function switchProxy(runnable)
  551.         filesystem.setProxy(selectedFilesystemProxy)
  552.         runnable()
  553.         filesystem.setProxy(temporaryFilesystemProxy)
  554.     end
  555.  
  556.     -- Creating system paths
  557.     local userSettings, userPaths
  558.     switchProxy(function()
  559.         paths.create(paths.system)
  560.         userSettings, userPaths = system.createUser(
  561.             usernameInput.text,
  562.             localizationComboBox:getItem(localizationComboBox.selectedItem).text,
  563.             not withoutPasswordSwitchAndLabel.switch.state and passwordInput.text or nil,
  564.             wallpapersSwitchAndLabel.switch.state
  565.         )
  566.     end)
  567.  
  568.     -- Downloading files
  569.     layout:removeChildren()
  570.     addImage(3, 2, "Downloading")
  571.  
  572.     local container = layout:addChild(GUI.container(1, 1, layout.width - 20, 2))
  573.     local progressBar = container:addChild(GUI.progressBar(1, 1, container.width, 0x66B6FF, 0xD2D2D2, 0xA5A5A5, 0, true, false))
  574.     local cyka = container:addChild(GUI.label(1, 2, container.width, 1, 0x969696, "")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
  575.  
  576.     -- Creating final filelist of things to download
  577.     local downloadList = {}
  578.  
  579.     local function getData(item)
  580.         if type(item) == "table" then
  581.             return item.path, item.id, item.version, item.shortcut
  582.         else
  583.             return item
  584.         end
  585.     end
  586.  
  587.     local function addToList(state, key)
  588.         if state then
  589.             local selectedLocalization, path, localizationName = localizationComboBox:getItem(localizationComboBox.selectedItem).text
  590.            
  591.             for i = 1, #files[key] do
  592.                 path = getData(files[key][i])
  593.  
  594.                 if filesystem.extension(path) == ".lang" then
  595.                     localizationName = filesystem.hideExtension(filesystem.name(path))
  596.  
  597.                     if
  598.                         -- If ALL loacalizations need to be downloaded
  599.                         localizationsSwitchAndLabel.switch.state or
  600.                         -- If it's required localization file
  601.                         localizationName == selectedLocalization or
  602.                         -- Downloading English "just in case" for non-english localizations
  603.                         selectedLocalization ~= "English" and localizationName == "English"
  604.                     then
  605.                         table.insert(downloadList, files[key][i])
  606.                     end
  607.                 else
  608.                     table.insert(downloadList, files[key][i])
  609.                 end
  610.             end
  611.         end
  612.     end
  613.  
  614.     addToList(true, "required")
  615.     addToList(true, "localizations")
  616.     addToList(true, "requiredWallpapers")
  617.     addToList(applicationsSwitchAndLabel.switch.state, "optional")
  618.     addToList(wallpapersSwitchAndLabel.switch.state, "optionalWallpapers")
  619.  
  620.     -- Downloading files from created list
  621.     local versions, path, id, version, shortcut = {}
  622.     for i = 1, #downloadList do
  623.         path, id, version, shortcut = getData(downloadList[i])
  624.  
  625.         cyka.text = text.limit(localization.installing .. " \"" .. path .. "\"", container.width, "center")
  626.         workspace:draw()
  627.  
  628.         -- Download file
  629.         download(path, OSPath .. path)
  630.  
  631.         -- Adding system versions data
  632.         if id then
  633.             versions[id] = {
  634.                 path = OSPath .. path,
  635.                 version = version or 1,
  636.             }
  637.         end
  638.  
  639.         -- Create shortcut if possible
  640.         if shortcut then
  641.             switchProxy(function()
  642.                 system.createShortcut(
  643.                     userPaths.desktop .. filesystem.hideExtension(filesystem.name(filesystem.path(path))),
  644.                     OSPath .. filesystem.path(path)
  645.                 )
  646.             end)
  647.         end
  648.  
  649.         progressBar.value = math.floor(i / #downloadList * 100)
  650.         workspace:draw()
  651.     end
  652.  
  653.     -- Flashing EEPROM
  654.     layout:removeChildren()
  655.     addImage(1, 1, "EEPROM")
  656.     addTitle(0x969696, localization.flashing)
  657.     workspace:draw()
  658.    
  659.     component.invoke(EEPROMAddress, "set", request(EFIURL))
  660.     component.invoke(EEPROMAddress, "setLabel", "MineOS EFI")
  661.     component.invoke(EEPROMAddress, "setData", selectedFilesystemProxy.address)
  662.  
  663.  
  664.     -- Saving system versions
  665.     switchProxy(function()
  666.         filesystem.writeTable(paths.system.versions, versions, true)
  667.     end)
  668.  
  669.     -- Done info
  670.     layout:removeChildren()
  671.     addImage(1, 1, "Done")
  672.     addTitle(0x969696, localization.installed)
  673.     addStageButton(localization.reboot).onTouch = function()
  674.         computer.shutdown(true)
  675.     end
  676.     workspace:draw()
  677.  
  678.     -- Removing temporary installer directory
  679.     temporaryFilesystemProxy.remove(installerPath)
  680. end)
  681.  
  682. --------------------------------------------------------------------------------
  683.  
  684. loadStage()
  685. workspace:start()
  686.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement