diff --git a/Files.cfg b/Files.cfg index d4e5ee54..2859c0ac 100644 --- a/Files.cfg +++ b/Files.cfg @@ -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", diff --git a/Installer/Installer.lua b/Installer.lua similarity index 98% rename from Installer/Installer.lua rename to Installer.lua index be36249e..fb7b35d9 100644 --- a/Installer/Installer.lua +++ b/Installer.lua @@ -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) diff --git a/Installer/English.lang b/Localizations/Installer/English.lang similarity index 100% rename from Installer/English.lang rename to Localizations/Installer/English.lang diff --git a/Installer/Russian.lang b/Localizations/Installer/Russian.lang similarity index 100% rename from Installer/Russian.lang rename to Localizations/Installer/Russian.lang diff --git a/Localization/English.lang b/Localizations/OS/English.lang similarity index 100% rename from Localization/English.lang rename to Localizations/OS/English.lang diff --git a/Localization/Russian.lang b/Localizations/OS/Russian.lang similarity index 100% rename from Localization/Russian.lang rename to Localizations/OS/Russian.lang diff --git a/OS.lua b/OS.lua index 7876b477..1dc46860 100755 --- a/OS.lua +++ b/OS.lua @@ -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() diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index 3a76ddf4..830f8637 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -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 -----------------------------------------------------------------------------------------------------------------------------------