фуафуаф

This commit is contained in:
Igor Timofeev
2016-09-18 16:33:44 +03:00
parent c8ba01f8ba
commit 2736df9cd2
3 changed files with 77 additions and 98 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -283,7 +283,6 @@
name="lib/advancedLua.lua",
url="IgorTimofeev/OpenComputers/master/lib/advancedLua.lua",
type="Library",
preLoadFile=true,
version=1.02,
},
{
@@ -311,7 +310,6 @@
name="lib/files.lua",
url="IgorTimofeev/OpenComputers/master/lib/files.lua",
type="Library",
preLoadFile=true,
version=1.0,
},
{

View File

@@ -1,43 +1,33 @@
local component = require("component")
local computer = require("computer")
local term = require("term")
local unicode = require("unicode")
local event = require("event")
local fs = require("filesystem")
local seri = require("serialization")
local serialization = require("serialization")
local shell = require("shell")
local gpu = component.gpu
local args = {...}
local skipCheck = args[1] == "skipcheck"
local args, options = shell.parse( ... )
-----------------Проверка компа на соответствие сис. требованиям--------------------------
------------------------------------- Проверка компа на соответствие сис. требованиям -------------------------------------
shell.execute("cd ..")
shell.setWorkingDirectory("")
--Создаем массив говна
-- Создаем массив говна
local govno = {}
print(" ")
print("Analyzing computer for matching system requirements...")
--Проверяем, не планшет ли это
-- Проверяем, не планшет ли это
if component.isAvailable("tablet") then table.insert(govno, "Tablet PC detected - You can't install MineOS on tablet because of primitive GPU and Screen.") end
--Проверяем GPU
if gpu.maxResolution() < 150 then table.insert(govno, "Bad GPU or Screen - MineOS requires Tier 3 GPU and Tier 3 Screen.") end
--Проверяем оперативку
if math.floor(computer.totalMemory() / 1024 ) < 1536 then table.insert(govno, "Not enough RAM - MineOS requires at least 1536 KB RAM.") end
if fs.get("bin/edit.lua") == nil or fs.get("bin/edit.lua").isReadOnly() then table.insert(govno, "You can't install MineOS on floppy disk. Run \"install\" in command line and install OpenOS from floppy to HDD first. After that you're be able to install MineOS from Pastebin.") end
-- Проверяем GPU
if component.gpu.maxResolution() < 150 then table.insert(govno, "Bad GPU or Screen - MineOS requires Tier 3 GPU and Tier 3 Screen.") end
-- Проверяем оперативку
if math.floor(computer.totalMemory() / 1024 ) < 2048 then table.insert(govno, "Not enough RAM - MineOS requires at least 1536 KB RAM.") end
-- Проверяем, не флоппи-диск ли это
if fs.get("/bin/edit.lua") == nil or fs.get("/bin/edit.lua").isReadOnly() then table.insert(govno, "You can't install MineOS on floppy disk. Run \"install\" in command line and install OpenOS from floppy to HDD first. After that you're be able to install MineOS from Pastebin.") end
--Если нашло какое-то несоответствие сис. требованиям, то написать, что именно не так
if #govno > 0 and not skipCheck then
if #govno > 0 and not options.skipcheck then
print(" ")
for i = 1, #govno do
print(govno[i])
end
for i = 1, #govno do print(govno[i]) end
print(" ")
return
else
@@ -45,20 +35,16 @@ else
print(" ")
end
------------------------------------------------------------------------------------------
------------------------------------- Создание базового дерьмища -------------------------------------
local lang
local applications
local padColor = 0x262626
local installerScale = 1
local timing = 0.2
local GitHubUserUrl = "https://raw.githubusercontent.com/"
-----------------------------СТАДИЯ ПОДГОТОВКИ-------------------------------------------
local function request(url)
local function internetRequest(url)
local success, response = pcall(component.internet.request, url)
if success then
local responseData = ""
@@ -70,7 +56,7 @@ local function request(url)
if responseChunk then
return false, responseChunk
else
return responseData
return true, responseData
end
end
end
@@ -81,27 +67,23 @@ end
--БЕЗОПАСНАЯ ЗАГРУЗОЧКА
local function getFromGitHubSafely(url, path)
local success, reason = request(url)
local success, reason = internetRequest(url)
if success then
fs.makeDirectory(fs.path(path) or "")
fs.remove(path)
local file = io.open(path, "w")
file:write(success)
file:write(reason)
file:close()
return success
return reason
else
io.stderr:write("Can't download \"" .. url .. "\"!\n")
return -1
error("Can't download \"" .. url .. "\"!\n")
end
end
local GitHubUserUrl = "https://raw.githubusercontent.com/"
--------------------------------- Стадия стартовой загрузки всего необходимого ---------------------------------
------------------------------------- Стадия стартовой загрузки всего необходимого -------------------------------------
print("Downloading file list")
applications = seri.unserialize(getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/Applications.txt", "MineOS/System/OS/Applications.txt"))
applications = serialization.unserialize(getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/Applications.txt", "/MineOS/System/OS/Applications.txt"))
print(" ")
for i = 1, #applications do
@@ -113,33 +95,31 @@ end
print(" ")
------------------------------------- Стадия инициализации загруженных библиотек -------------------------------------
package.loaded.ecs = nil
package.loaded.ECSAPI = nil
_G.ecs = require("ECSAPI")
_G.image = require("image")
_G.files = require("files")
local imageOS = image.load("MineOS/System/OS/Icons/OS_Logo.pic")
local imageLanguages = image.load("MineOS/System/OS/Icons/Languages.pic")
local imageDownloading = image.load("MineOS/System/OS/Icons/Downloading.pic")
local imageOK = image.load("MineOS/System/OS/Icons/OK.pic")
local imageOS = image.load("/MineOS/System/OS/Icons/OS_Logo.pic")
local imageLanguages = image.load("/MineOS/System/OS/Icons/Languages.pic")
local imageDownloading = image.load("/MineOS/System/OS/Icons/Downloading.pic")
local imageOK = image.load("/MineOS/System/OS/Icons/OK.pic")
if not skipCheck then ecs.setScale(installerScale) end
ecs.setScale(installerScale)
local xSize, ySize = gpu.getResolution()
local windowWidth = 80
local windowHeight = 2 + 16 + 2 + 3 + 2
local xSize, ySize = component.gpu.getResolution()
local windowWidth, windowHeight = 80, 25
local xWindow, yWindow = math.floor(xSize / 2 - windowWidth / 2), math.ceil(ySize / 2 - windowHeight / 2)
local xWindowEnd, yWindowEnd = xWindow + windowWidth - 1, yWindow + windowHeight - 1
-------------------------------------------------------------------------------------------
------------------------------------- Базовые функции для работы с будущим окном -------------------------------------
local function clear()
ecs.blankWindow(xWindow, yWindow, windowWidth, windowHeight)
end
--ОБЪЕКТЫ
local obj = {}
local function newObj(class, name, ...)
obj[class] = obj[class] or {}
@@ -166,22 +146,17 @@ local function waitForClickOnButton(buttonName)
end
end
------------------------------ВЫБОР ЯЗЫКА------------------------------------
------------------------------------- Стадия выбора языка и настройки системы -------------------------------------
ecs.prepareToExit()
local downloadWallpapers, showHelpTips, downloadAllApps = false, false, false
local installOption, downloadWallpapers, showHelpTips
do
clear()
image.draw(math.ceil(xSize / 2 - 30), yWindow + 2, imageLanguages)
--кнопа
drawButton("Select language",false)
waitForClickOnButton("Select language")
local data = ecs.universalWindow("auto", "auto", 36, 0x262626, true,
@@ -192,17 +167,17 @@ do
{"EmptyLine"},
{"CenterText", ecs.colors.orange, "Change some OS properties"},
{"EmptyLine"},
{"Switch", 0xF2B233, 0xffffff, 0xFFFFFF, "Download all Apps", true},
{"Selector", 0xFFFFFF, 0xF2B233, "Full installation", "Install only must-have apps", "Install only libraries"},
{"EmptyLine"},
{"Switch", 0xF2B233, 0xffffff, 0xFFFFFF, "Download wallpapers", true},
{"Switch", 0xF2B233, 0xFFFFFF, 0xFFFFFF, "Download wallpapers", true},
{"EmptyLine"},
{"Switch", 0xF2B233, 0xffffff, 0xFFFFFF, "Show help tips in OS", true},
{"EmptyLine"},
{"Button", {ecs.colors.orange, 0x262626, "OK"}}
)
downloadAllApps, downloadWallpapers, showHelpTips = data[2], data[3], data[4]
installOptions, downloadWallpapers, showHelpTips = data[2], data[3], data[4]
--УСТАНАВЛИВАЕМ НУЖНЫЙ ЯЗЫК
-- Устанавливаем базовую конфигурацию системы
_G.OSSettings = {
showHelpOnApplicationStart = showHelpTips,
language = data[1],
@@ -216,18 +191,17 @@ do
ecs.saveOSSettings()
--Качаем язык
-- Загружаем локализацию инсталлера
ecs.info("auto", "auto", " ", " Installing language packages...")
local pathToLang = "MineOS/System/OS/Installer/Language.lang"
local pathToLang = "/MineOS/System/OS/Installer/Language.lang"
getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/Installer/" .. _G.OSSettings.language .. ".lang", pathToLang)
getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/MineOS/License/" .. _G.OSSettings.language .. ".txt", "MineOS/System/OS/License.txt")
getFromGitHubSafely(GitHubUserUrl .. "IgorTimofeev/OpenComputers/master/MineOS/License/" .. _G.OSSettings.language .. ".txt", "/MineOS/System/OS/License.txt")
--Ставим язык
lang = files.loadTableFromFile(pathToLang)
local file = io.open(pathToLang, "r"); lang = serialization.unserialize(file:read("*a")); file:close()
end
------------------------------СТАВИТЬ ЛИ ОСЬ------------------------------------
------------------------------------- Проверка, желаем ли мы вообще ставить ось -------------------------------------
do
clear()
@@ -235,8 +209,8 @@ do
image.draw(math.ceil(xSize / 2 - 15), yWindow + 2, imageOS)
--Текстик по центру
gpu.setBackground(ecs.windowColors.background)
gpu.setForeground(ecs.colors.gray)
component.gpu.setBackground(ecs.windowColors.background)
component.gpu.setForeground(ecs.colors.gray)
ecs.centerText("x", yWindowEnd - 5 , lang.beginOsInstall)
--кнопа
@@ -257,7 +231,7 @@ do
--Читаем файл с лиц соглл
local lines = {}
local file = io.open("MineOS/System/OS/License.txt", "r")
local file = io.open("/MineOS/System/OS/License.txt", "r")
for line in file:lines() do
table.insert(lines, line)
end
@@ -265,10 +239,6 @@ do
--Штуку рисуем
ecs.textField(xText, yText, TextWidth, TextHeight, lines, from, 0xffffff, 0x262626, 0x888888, ecs.colors.blue)
--Инфо рисуем
--ecs.centerText("x", yWindowEnd - 5 ,"Принимаете ли вы условия лицензионного соглашения?")
--кнопа
drawButton(lang.acceptLicense, false)
@@ -293,10 +263,10 @@ end
-------------------------- Подготавливаем файловую систему ----------------------------------
--Создаем стартовые пути и прочие мелочи чисто для эстетики
local desktopPath = "MineOS/Desktop/"
local dockPath = "MineOS/System/OS/Dock/"
local applicationsPath = "MineOS/Applications/"
local picturesPath = "MineOS/Pictures/"
local desktopPath = "/MineOS/Desktop/"
local dockPath = "/MineOS/System/OS/Dock/"
local applicationsPath = "/MineOS/Applications/"
local picturesPath = "/MineOS/Pictures/"
fs.remove(desktopPath)
fs.remove(dockPath)
@@ -305,7 +275,7 @@ fs.remove(dockPath)
-- fs.makeDirectory(picturesPath)
fs.makeDirectory(dockPath)
--------------------------СТАДИЯ ЗАГРУЗКИ-----------------------------------
------------------------------ Загрузка всего ------------------------------------------
do
local barWidth = math.floor(windowWidth * 2 / 3)
@@ -325,16 +295,23 @@ do
ecs.progressBar(xBar, yBar, barWidth, 1, 0xcccccc, ecs.colors.blue, 0)
os.sleep(timing)
-- Создаем список того, что будем загружать, в зависимости от выбранных ранее опций
local thingsToDownload = {}
for i = 1, #applications do
if
(applications[i].type == "Wallpaper" and downloadWallpapers)
or
(applications[i].type == "Application" and (downloadAllApps or applications[i].forceDownload))
or
if
(applications[i].type == "Library" or applications[i].type == "Icon")
or
(applications[i].forceDownload)
(
(installOptions ~= "Install only libraries")
and
(
(applications[i].forceDownload)
or
(applications[i].type == "Wallpaper" and downloadWallpapers)
or
(applications[i].type == "Application" and installOptions == "Full installation")
)
)
then
table.insert(thingsToDownload, applications[i])
end
@@ -342,8 +319,8 @@ do
applications[i] = nil
end
-- Загружаем все из списка
for app = 1, #thingsToDownload do
--ВСЕ ДЛЯ ГРАФОНА
drawInfo(xBar, yBar + 1, lang.downloading .. " " .. thingsToDownload[app]["name"])
local percent = app / #thingsToDownload * 100
ecs.progressBar(xBar, yBar, barWidth, 1, 0xcccccc, ecs.colors.blue, percent)
@@ -352,28 +329,29 @@ do
end
os.sleep(timing)
if installOptions == "Install only libraries" then ecs.prepareToExit(); computer.shutdown(true) end
end
--Создаем базовые обои рабочего стола
-- Создаем базовые обои рабочего стола
if downloadWallpapers then
ecs.createShortCut(desktopPath .. "Pictures.lnk", picturesPath)
ecs.createShortCut("MineOS/System/OS/Wallpaper.lnk", picturesPath .. "Raspberry.pic")
ecs.createShortCut("/MineOS/System/OS/Wallpaper.lnk", picturesPath .. "Raspberry.pic")
end
--Автозагрузка
-- Создаем файл автозагрузки
local file = io.open("autorun.lua", "w")
file:write("local success, reason = pcall(loadfile(\"OS.lua\")); if not success then print(\"Ошибка: \" .. tostring(reason)) end")
file:close()
--------------------------СТАДИЯ ПЕРЕЗАГРУЗКИ КОМПА-----------------------------------
------------------------------ Стадия перезагрузки ------------------------------------------
ecs.blankWindow(xWindow,yWindow,windowWidth,windowHeight)
image.draw(math.floor(xSize/2 - 16), math.floor(ySize/2 - 11), imageOK)
--Текстик по центру
gpu.setBackground(ecs.windowColors.background)
gpu.setForeground(ecs.colors.gray)
component.gpu.setBackground(ecs.windowColors.background)
component.gpu.setForeground(ecs.colors.gray)
ecs.centerText("x",yWindowEnd - 5, lang.needToRestart)
--Кнопа
@@ -381,4 +359,7 @@ drawButton(lang.restart, false)
waitForClickOnButton(lang.restart)
ecs.prepareToExit()
computer.shutdown(true)
computer.shutdown(true)