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

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", 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 = { duringInstall = {
-- Либы -- Либы
{ {
@ -92,14 +102,6 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/OS.lua", url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/OS.lua",
publicationName="MineOS", 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", path="/MineOS/System/Extensions/Lua/ContextMenu.lua",

View File

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

23
OS.lua
View File

@ -292,17 +292,16 @@ end
local function createOSWindow() local function createOSWindow()
MineOSInterface.mainContainer = GUI.fullScreenContainer() MineOSInterface.mainContainer = GUI.fullScreenContainer()
-- MineOSInterface.mainContainer.passScreenEvents = true
-- local overrideDraw = MineOSInterface.mainContainer.draw
-- MineOSInterface.mainContainer.draw = function() -- MineOSInterface.mainContainer.draw = function(...)
-- GUI.drawContainerContent(MineOSInterface.mainContainer) -- overrideDraw(...)
-- local limit = 70 -- local freeMemory, totalMemory = computer.freeMemory() / 1024, computer.totalMemory() / 1024
-- local lines = string.wrap(debug.traceback(), limit) -- local y = MineOSInterface.mainContainer.y
-- buffer.square(1, 1, limit, #lines, 0x0, 0xFFFFFF, " ", 0.2) -- buffer.text(MineOSInterface.mainContainer.x, y, 0xFF0000, "Free: " .. string.format("%.2f", freeMemory)); y = y + 1
-- for i = 1, #lines do -- buffer.text(MineOSInterface.mainContainer.x, y, 0xFF0000, "Total: " .. string.format("%.2f", totalMemory)); y = y + 1
-- buffer.text(1, i, 0xFFFFFF, lines[i]) -- buffer.text(MineOSInterface.mainContainer.x, y, 0xFF0000, "Used: " .. string.format("%.2f", totalMemory - freeMemory)); y = y + 1
-- end
-- end -- end
MineOSInterface.mainContainer.background = MineOSInterface.mainContainer:addChild(GUI.object(1, 1, 1, 1)) 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() createOSWindow()
changeResolution() changeResolution()

View File

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