Переебошим ебалу

This commit is contained in:
Igor Timofeev 2018-02-21 17:06:47 +03:00
parent a73abc8aad
commit c6a23e4722
8 changed files with 38 additions and 30 deletions

View File

@ -45,6 +45,16 @@
publicationName="Web",
},
},
localizations = {
{
path="/MineOS/System/Localizations/Russian.lang",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Localizations/OS/Russian.lang",
},
{
path="/MineOS/System/Localizations/English.lang",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Localizations/OS/English.lang",
},
},
duringInstall = {
-- Либы
{
@ -92,14 +102,6 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/OS.lua",
publicationName="MineOS",
},
{
path="/MineOS/System/Localization/Russian.lang",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Localization/Russian.lang",
},
{
path="/MineOS/System/Localization/English.lang",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Localization/English.lang",
},
-- Ассоциации контекстного меню
{
path="/MineOS/System/Extensions/Lua/ContextMenu.lua",

View File

@ -13,7 +13,7 @@ local args, options = shell.parse(...)
local URLs = {
applicationList = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Files.cfg",
installer = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Installer/",
installerLocalization = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Localizations/Installer/",
EFI = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/EFI.lua",
license = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/License/",
}
@ -177,7 +177,7 @@ end
local function loadLocalization(language)
MineOSCore.properties.language = language
localization = table.fromString(web.request(URLs.installer .. MineOSCore.properties.language .. ".lang"))
localization = table.fromString(web.request(URLs.installerLocalization .. MineOSCore.properties.language .. ".lang"))
end
stages[1] = function()
@ -185,13 +185,15 @@ stages[1] = function()
local y = addImageToStage(3, images.languages)
y = y + 3
local comboBox = stageContainer:addChild(GUI.comboBox(math.floor(stageContainer.width / 2 - 15), y, 30, 3, 0xFFFFFF, 0x555555, 0xAAAAAA, 0xDDDDDD))
loadLocalization("Russian")
comboBox:addItem("Russian").onTouch = function()
loadLocalization("Russian")
end
comboBox:addItem("English").onTouch = function()
loadLocalization("English")
for i = 1, #applicationList.localizations do
local name = fs.name(applicationList.localizations[i].path)
comboBox:addItem(fs.hideExtension(name)).onTouch = function()
loadLocalization(name)
end
end
comboBox:getItem(1).onTouch()
end
------------------------------------------------------------------------------------------------------------------------------------
@ -248,6 +250,11 @@ stages[4] = function()
end
end
for i = 1, #applicationList.localizations do
table.insert(applicationList.duringInstall, applicationList.localizations[i])
applicationList.localizations[i] = nil
end
for i = 1, #applicationList.duringInstall do
fileLabel.text = localization.downloading .. " " .. string.limit(applicationList.duringInstall[i].path, width - unicode.len(localization.downloading) - 1, "center")
progressBar.value = math.round(i / #applicationList.duringInstall * 100)

23
OS.lua
View File

@ -292,17 +292,16 @@ end
local function createOSWindow()
MineOSInterface.mainContainer = GUI.fullScreenContainer()
-- MineOSInterface.mainContainer.passScreenEvents = true
-- MineOSInterface.mainContainer.draw = function()
-- GUI.drawContainerContent(MineOSInterface.mainContainer)
-- local limit = 70
-- local lines = string.wrap(debug.traceback(), limit)
-- buffer.square(1, 1, limit, #lines, 0x0, 0xFFFFFF, " ", 0.2)
-- for i = 1, #lines do
-- buffer.text(1, i, 0xFFFFFF, lines[i])
-- end
-- local overrideDraw = MineOSInterface.mainContainer.draw
-- MineOSInterface.mainContainer.draw = function(...)
-- overrideDraw(...)
-- local freeMemory, totalMemory = computer.freeMemory() / 1024, computer.totalMemory() / 1024
-- local y = MineOSInterface.mainContainer.y
-- buffer.text(MineOSInterface.mainContainer.x, y, 0xFF0000, "Free: " .. string.format("%.2f", freeMemory)); y = y + 1
-- buffer.text(MineOSInterface.mainContainer.x, y, 0xFF0000, "Total: " .. string.format("%.2f", totalMemory)); y = y + 1
-- buffer.text(MineOSInterface.mainContainer.x, y, 0xFF0000, "Used: " .. string.format("%.2f", totalMemory - freeMemory)); y = y + 1
-- end
MineOSInterface.mainContainer.background = MineOSInterface.mainContainer:addChild(GUI.object(1, 1, 1, 1))
@ -985,7 +984,7 @@ end
---------------------------------------------- Сама ОС ------------------------------------------------------------------------
MineOSCore.localization = table.fromFile(MineOSPaths.localizationFiles .. MineOSCore.properties.language .. ".lang")
MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFiles)
createOSWindow()
changeResolution()

View File

@ -29,12 +29,12 @@ function MineOSCore.getLocalization(pathToLocalizationFolder)
if filesystem.exists(localizationFileName) then
return table.fromFile(localizationFileName)
else
error("Localization file \"" .. localizationFileName .. "\" doesn't exists")
return table.fromFile(pathToLocalizationFolder .. filesystem.list(pathToLocalizationFolder)())
end
end
function MineOSCore.getCurrentApplicationLocalization()
return MineOSCore.getLocalization(MineOSCore.getCurrentApplicationResourcesDirectory() .. "Localization/")
return MineOSCore.getLocalization(MineOSCore.getCurrentApplicationResourcesDirectory() .. "Localizations/")
end
-----------------------------------------------------------------------------------------------------------------------------------