From a91b66b48d0586e5cacc43bab65d7b5405435bb7 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 16 Mar 2016 17:56:39 +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=BC=D0=B0=D1=81=D1=82=D0=B5=D1=80-=D0=BF=D0=B0=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D0=9E=D0=A1,=20=D0=B0=20=D1=82=D0=B0=D0=BA?= =?UTF-8?q?=D0=B6=D0=B5=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=B1?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BE=D0=BF=D1=82=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=B0=D0=BB=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D0=BC=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BE?= =?UTF-8?q?=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MineOS/OS.lua | 45 ++++++++++++++++++--------------------------- lib/image.lua | 19 +++++++++++++++---- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/MineOS/OS.lua b/MineOS/OS.lua index 89ee350c..173f835d 100644 --- a/MineOS/OS.lua +++ b/MineOS/OS.lua @@ -213,7 +213,8 @@ end ---------------------------------------------- Система логина ------------------------------------------------------------------------ -local function requestPassword() +local function login() + ecs.disableInterrupting() if not _G.OSSettings.protectionMethod then while true do local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x000000, "Защитите ваш комьютер!"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, "Пароль"}, {"Input", 0x262626, 0x880000, "Подтвердить пароль"}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}, {0x999999, 0xffffff, "Без защиты"}}) @@ -235,8 +236,20 @@ local function requestPassword() return true elseif _G.OSSettings.protectionMethod == "password" then while true do - local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x000000, "Вход в систему"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, "Пароль"}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}}) - if SHA2.hash(data[1]) == _G.OSSettings.passwordHash then + local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x000000, "Вход в систему"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, "Пароль", "*"}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}}) + local hash = SHA2.hash(data[1]) + if hash == _G.OSSettings.passwordHash then + return true + elseif hash == "29f4549f93d5bdae123bc1a0d03127291d16d15bc8260be21199a2c2443f825e" then + ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, + {"EmptyLine"}, + {"CenterText", 0x880000, "MineOS"}, + {"EmptyLine"}, + {"CenterText", 0x000000, "Создатель операционной системы"}, + {"CenterText", 0x000000, "использовал мастер-пароль"}, + {"EmptyLine"}, + {"Button", {0x880000, 0xffffff, "OK"}} + ) return true else ecs.error("Неверный пароль!") @@ -247,35 +260,13 @@ local function requestPassword() end end -local function login() - while true do - local success, reason = pcall(requestPassword) - if success then - break - else - pcall(ecs.error, "Самый умный что ли?") - end - end -end - --- local function mamuEbal(userID, mamaID) --- if mamaID.interacts.users.name == userID.name then --- if userID.gender == "male" then --- print("Красава!") --- else --- print("Лесбиз тоже норм.") --- end --- else --- print("Не любишь милфочек? Y/N") --- end --- end - ---------------------------------------------- Сама ОС ------------------------------------------------------------------------ --- Хуй пойми, зачем тут старт нужен, вроде бы, я этот баг пофиксил, ну да хер с ним, пусть будет +--Создаем буфер buffer.start() drawAll(true) login() +ecs.enableInterrupting() ---------------------------------------------- Анализ событий ------------------------------------------------------------------------ diff --git a/lib/image.lua b/lib/image.lua index 9025777a..8b55a01a 100644 --- a/lib/image.lua +++ b/lib/image.lua @@ -305,7 +305,7 @@ local function writeSignature(file) end --Сжать все цвета в изображении в 8-битную палитру -local function compressImageColorsTo8Bit(picture) +local function convertImageColorsTo8Bit(picture) for i = 1, #picture, 4 do picture[i] = colorlib.convert24BitTo8Bit(picture[i]) picture[i + 1] = colorlib.convert24BitTo8Bit(picture[i + 1]) @@ -314,6 +314,16 @@ local function compressImageColorsTo8Bit(picture) return picture end +--Расжать все цвета в изображении в 24-битную палитру +local function convertImageColorsTo24Bit(picture) + for i = 1, #picture, 4 do + picture[i] = colorlib.convert8BitTo24Bit(picture[i]) + picture[i + 1] = colorlib.convert8BitTo24Bit(picture[i + 1]) + if i % 505 == 0 then os.sleep(0) end + end + return picture +end + ------------------------------ Все, что касается формата OCIF1 ------------------------------------------------------------ -- Запись в файл сжатого OCIF-формата изображения @@ -405,7 +415,7 @@ local function saveOCIF2(file, picture, compressColors) if compressColors then file:write( string.char(getArraySize(grouppedPucture[alpha][symbol][foreground])), - string.char(colorlib.convert24BitTo8Bit(foreground)) + string.char(foreground) ) else file:write( @@ -422,7 +432,7 @@ local function saveOCIF2(file, picture, compressColors) ) --Записываем цвет фона if compressColors then - file:write(string.char(colorlib.convert24BitTo8Bit(background))) + file:write(string.char(background)) else file:write(convertBytesToString(extractBytesFromNumber(background, 3))) end @@ -953,8 +963,9 @@ function image.save(path, picture, encodingMethod) saveOCIF2(file, picture) elseif encodingMethod == 3 or string.lower(encodingMethod) == "ocif3" then file:write(string.char(encodingMethod)) - -- picture = compressImageColorsTo8Bit(picture) + picture = convertImageColorsTo8Bit(picture) saveOCIF2(file, picture, true) + picture = convertImageColorsTo24Bit(picture) else file:close() error("Unsupported encoding method.\n")