From 4a70e20a69fdaae1b9fcbdb500d332d9149459e7 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Tue, 15 Sep 2015 21:34:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B1=D0=B5=D1=82=D0=B0-=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E?= =?UTF-8?q?=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B8=20"=D0=9E=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F",=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0=20=D0=BB=D0=B8=D1=88=D1=8C=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BE=D0=BA=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/Control/Control.lua | 87 ++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/Applications/Control/Control.lua b/Applications/Control/Control.lua index 090dc956..179eff72 100644 --- a/Applications/Control/Control.lua +++ b/Applications/Control/Control.lua @@ -21,13 +21,14 @@ local colors = { topButtonsText = 0x262626, } -local topButtons = {"О системе", "Диски", "Экран", "Память"} +local topButtons = {"О системе", "Диски", "Экран", "Обновления"} local spaceBetweenTopButtons, offsetTopButtons = 2, 2 local currentMode = 1 local osIcon = image.load("System/OS/Installer/OS_Logo.png") local hddIcon = image.load("System/OS/Icons/HDD.png") local floppyIcon = image.load("System/OS/Icons/Floppy.png") +local updateIcon = image.load("System/OS/Icons/Update.png") local x, y = "auto", "auto" local width, height = 84, 26 @@ -41,6 +42,11 @@ local drawHDDFrom = 1 local HDDs local bootAddress = computer.getBootAddress() +local updates, oldApps +local drawUpdatesFrom = 1 +local xUpdatesList, yUpdatesList +local countOfChoses + ------------------------------------------------------------------------------------------------------------------------------- --СОЗДАНИЕ ОБЪЕКТОВ @@ -87,6 +93,37 @@ local function drawTopBar() end end +local function drawUpdatesList() + + local selectSymbol, nonSelectSymbol = "✔", " " + local limit = 40 + local xPos, yPos = xUpdatesList, yUpdatesList + + --ОЧИЩАЕМ ЭТУ ПИЗДУ, ЗАЕБАЛО, БЛЯДЬ + ecs.square(xPos, yPos, limit + 2, 15, colors.main) + + for i = drawUpdatesFrom, (drawUpdatesFrom + 4) do + if not updates[i] then break end + --Коробка для галочки + ecs.border(xPos, yPos, 5, 3, colors.main, 0x262626) + --Галочка + if updates[i].needToUpdate then + ecs.colorText(xPos + 2, yPos + 1, 0x880000, selectSymbol) + countOfChoses = countOfChoses + 1 + end + --Имя проги + local text = "§f" .. (fs.name(updates[i].name) or updates[i].name) .. (function() if updates[i].needToUpdate then return "§e, версия ".. updates[i].version .." (новее)" else return "§8, версия ".. updates[i].version end end)() + ecs.smartText(xPos + 6, yPos + 1, ecs.stringLimit("end", text, limit)) + text = nil + + yPos = yPos + 3 + end + + --Скроллбар + ecs.srollBar(x + width - 3, y + heightOfTopBar + 2, 1, 15, #updates, drawUpdatesFrom, 0xdddddd, ecs.colors.blue) + +end + local function drawMain() ecs.square(x, y + heightOfTopBar, width, height - heightOfTopBar, colors.main) local xPos, yPos @@ -138,15 +175,53 @@ local function drawMain() --Скроллбар ecs.srollBar(x + width - 1, y + heightOfTopBar, 1, height - heightOfTopBar, #HDDs, drawHDDFrom, 0xdddddd, ecs.colors.blue) - elseif currentMode == 3 then + elseif currentMode == 4 then - else + obj["Updates"] = {} + xPos, yPos = x + 3, y + heightOfTopBar + 3 + image.draw(xPos, yPos, updateIcon) + + yPos = yPos - 1 + xPos = xPos + 35 + countOfChoses = 0 + + --Если нет еще апдейтов, то получить новые апдейты + if not updates then updates, countOfUpdates = ecs.getAppsToUpdate(true) end + + --Рисуем выборы + if countOfUpdates > 0 then + + xUpdatesList, yUpdatesList = xPos, yPos + drawUpdatesList(xPos, yPos) + + --Кнопы + yPos = yPos + 16 + if countOfChoses > 0 then + local _, _, xEnd, _ = ecs.drawAdaptiveButton(xPos, yPos, 2, 1, "Обновить", ecs.colors.blue, 0xffffff) + xPos = xEnd + 2 + end + + local _, _, xEnd, _ = ecs.drawAdaptiveButton(xPos, yPos, 2, 1, "Выбрать все", ecs.colors.blue, 0xffffff) + xPos = xEnd + 2 + + _, _, xEnd, _ = ecs.drawAdaptiveButton(xPos, yPos, 2, 1, "Снять выбор", ecs.colors.blue, 0xffffff) + xPos = xEnd + 2 + + else + yPos = yPos + 8 + ecs.colorTextWithBack(xPos, yPos, 0x000000, colors.main, "Обновлений не обнаружено!") + ecs.colorText(xPos, yPos + 1, 0xaaaaaa, "У вас самое новое ПО.") + end + end end ------------------------------------------------------------------------------------------------------------------------------- + +ecs.prepareToExit() + local oldPixels = ecs.rememberOldPixels(x, y, x + width - 1, y + height - 1) drawTopBar() drawMain() @@ -230,6 +305,12 @@ while true do else if drawHDDFrom < #HDDs then drawHDDFrom = drawHDDFrom + 1; drawMain() end end + elseif currentMode == 4 then + if e[5] == 1 then + if drawUpdatesFrom > 1 then drawUpdatesFrom = drawUpdatesFrom - 1; drawUpdatesList() end + else + if drawUpdatesFrom < #updates then drawUpdatesFrom = drawUpdatesFrom + 1; drawUpdatesList() end + end end