mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-07 19:52:40 +01:00
Много фич, исправлений и удобностей в использовании либ
This commit is contained in:
parent
03c46d91a4
commit
db4c613e8a
@ -5,6 +5,7 @@
|
||||
local libraries = {
|
||||
buffer = "doubleBuffering",
|
||||
MineOSCore = "MineOSCore",
|
||||
GUI = "GUI",
|
||||
component = "component",
|
||||
computer = "computer",
|
||||
event = "event",
|
||||
@ -14,16 +15,9 @@ local libraries = {
|
||||
unicode = "unicode",
|
||||
archive = "archive",
|
||||
serialization = "serialization",
|
||||
GUI = "GUI",
|
||||
}
|
||||
|
||||
local components = {
|
||||
["gpu"] = "gpu",
|
||||
}
|
||||
|
||||
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end
|
||||
for comp in pairs(components) do if not _G[comp] then _G[comp] = _G.component[components[comp]] end end
|
||||
libraries, components = nil, nil
|
||||
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -31,7 +25,7 @@ local colors = {
|
||||
topBar = 0xdddddd,
|
||||
main = 0xffffff,
|
||||
leftBar = 0xeeeeee,
|
||||
leftBarTransparency = 35,
|
||||
leftBarTransparency = 25,
|
||||
leftBarSelection = ecs.colors.blue,
|
||||
leftBarSelectionText = 0xFFFFFF,
|
||||
closes = {close = ecs.colors.red, hide = ecs.colors.orange, full = ecs.colors.green},
|
||||
@ -46,8 +40,6 @@ local colors = {
|
||||
|
||||
local pathToComputerIcon = "MineOS/System/OS/Icons/Computer.pic"
|
||||
local pathToConfig = "MineOS/System/Finder/Config.cfg"
|
||||
local lang = files.loadTableFromFile("MineOS/System/OS/Languages/" .. _G.OSSettings.language .. ".lang")
|
||||
|
||||
local workPathHistory = {}
|
||||
local currentWorkPathHistoryElement = 1
|
||||
|
||||
@ -63,7 +55,7 @@ local sizes = {}
|
||||
local fileList = {}
|
||||
local config = {}
|
||||
local obj = {}
|
||||
local sortingMethods = {[0] = lang.sortByTypeShort, [1] = lang.sortByNameShort, [2] = lang.sortByDateShort, [lang.sortByTypeShort] = 0, [lang.sortByNameShort] = 1, [lang.sortByDateShort] = 2}
|
||||
local sortingMethods = {[0] = MineOSCore.localization.sortByTypeShort, [1] = MineOSCore.localization.sortByNameShort, [2] = MineOSCore.localization.sortByDateShort, [MineOSCore.localization.sortByTypeShort] = 0, [MineOSCore.localization.sortByNameShort] = 1, [MineOSCore.localization.sortByDateShort] = 2}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -156,12 +148,7 @@ end
|
||||
|
||||
--Рисем цветные кружочки слева вверху
|
||||
local function drawCloses()
|
||||
local x, y = sizes.xFinder + 1, sizes.yFinder
|
||||
local backgroundColor = _G.OSSettings.interfaceColor or colors.topBar
|
||||
local symbol = "●"
|
||||
obj.close = GUI.button(x, y, 1, 1,backgroundColor, colors.closes.close, backgroundColor, 0x000000, symbol)
|
||||
obj.hide = GUI.button(obj.close.x + obj.close.width + 1, y, 1, 1, backgroundColor, colors.closes.hide, backgroundColor, 0x000000, symbol)
|
||||
obj.full = GUI.button(obj.hide.x + obj.hide.width + 1, y, 1, 1, backgroundColor, colors.closes.full, backgroundColor, 0x000000, symbol)
|
||||
obj.windowActionButtons = GUI.windowActionButtons(sizes.xFinder + 1, sizes.yFinder)
|
||||
end
|
||||
|
||||
local function drawSearchBar(justDrawNotEvent)
|
||||
@ -169,7 +156,7 @@ local function drawSearchBar(justDrawNotEvent)
|
||||
local textColor = searchBarText and 0x262626 or 0xBBBBBB
|
||||
obj.search = GUI.object(sizes.xSearchBar, y, sizes.searchBarWidth, 1)
|
||||
buffer.square(sizes.xSearchBar, y, sizes.searchBarWidth, 1, 0xFFFFFF, textColor, " ")
|
||||
return GUI.input(sizes.xSearchBar + 1, y, sizes.searchBarWidth - 2, textColor, searchBarText or lang.search, {justDrawNotEvent = justDrawNotEvent})
|
||||
return GUI.input(sizes.xSearchBar + 1, y, sizes.searchBarWidth - 2, textColor, searchBarText or MineOSCore.localization.search, {justDrawNotEvent = justDrawNotEvent})
|
||||
end
|
||||
|
||||
local function drawTopBar()
|
||||
@ -185,8 +172,8 @@ local function drawTopBar()
|
||||
|
||||
local cyka = {
|
||||
{objName = "sortingMethod", text = sortingMethods[config.currentSortingMethod], active = false},
|
||||
{objName = "showFormat", text = lang.showFileFormatShort, active = config.showFileFormat},
|
||||
{objName = "showHidden", text = lang.showHiddenFilesShort, active = config.showHiddenFiles},
|
||||
{objName = "showFormat", text = MineOSCore.localization.showFileFormatShort, active = config.showFileFormat},
|
||||
{objName = "showHidden", text = MineOSCore.localization.showHiddenFilesShort, active = config.showHiddenFiles},
|
||||
}
|
||||
for i = 1, #cyka do
|
||||
obj[cyka[i].objName] = GUI.adaptiveButton(x, y, 1, 0, 0xFFFFFF, 0x262626, 0x262626, 0xFFFFFF, cyka[i].text)
|
||||
@ -217,7 +204,7 @@ local function drawLeftBar()
|
||||
local x, y = sizes.xFinder + 1, sizes.yMain
|
||||
--Фаворитсы
|
||||
if #config.favourites > 0 then
|
||||
buffer.text(x, y, colors.leftBarHeader, lang.favourites); y = y + 1
|
||||
buffer.text(x, y, colors.leftBarHeader, MineOSCore.localization.favourites); y = y + 1
|
||||
for i = 1, #config.favourites do
|
||||
drawAndHiglightPath(y, config.favourites[i])
|
||||
y = y + 1
|
||||
@ -226,7 +213,7 @@ local function drawLeftBar()
|
||||
end
|
||||
--Сеть
|
||||
if (function() local count = 0; for key in pairs(network) do count = count + 1 end; return count end)() > 0 then
|
||||
buffer.text(x, y, colors.leftBarHeader, lang.network); y = y + 1
|
||||
buffer.text(x, y, colors.leftBarHeader, MineOSCore.localization.network); y = y + 1
|
||||
for address in pairs(network) do
|
||||
buffer.text(sizes.xFinder + 2, y, colors.leftBarList, unicode.sub(address, 1, sizes.leftBarWidth - 4))
|
||||
obj.network[address] = GUI.object(sizes.xFinder + 2, y, sizes.leftBarWidth, 1)
|
||||
@ -235,7 +222,7 @@ local function drawLeftBar()
|
||||
y = y + 1
|
||||
end
|
||||
--Диски
|
||||
buffer.text(x, y, colors.leftBarHeader, lang.disks); y = y + 1
|
||||
buffer.text(x, y, colors.leftBarHeader, MineOSCore.localization.disks); y = y + 1
|
||||
for i = 1, #disks do
|
||||
drawAndHiglightPath(y, disks[i])
|
||||
y = y + 1
|
||||
@ -256,8 +243,8 @@ local function drawNetwork()
|
||||
local text = ecs.stringLimit("end", currentNetworkAddress, sizes.mainWidth - 4)
|
||||
buffer.text(math.floor(sizes.xMain + sizes.mainWidth / 2 - unicode.len(text) / 2), y, 0xAAAAAA, text); y = y + 2
|
||||
x = math.floor(sizes.xMain + sizes.mainWidth / 2 - buttonWidth / 2)
|
||||
obj.networkFile = GUI.button(x, y, buttonWidth, 1, 0xdddddd, 0x262626, 0x262626, 0xEEEEEE, lang.sendFile); y = y + 2
|
||||
obj.networkMessage = GUI.button(x, y, buttonWidth, 1, 0xdddddd, 0x262626, 0x262626, 0xEEEEEE, lang.sendMessage); y = y + 2
|
||||
obj.networkFile = GUI.button(x, y, buttonWidth, 1, 0xdddddd, 0x262626, 0x262626, 0xEEEEEE, MineOSCore.localization.sendFile); y = y + 2
|
||||
obj.networkMessage = GUI.button(x, y, buttonWidth, 1, 0xdddddd, 0x262626, 0x262626, 0xEEEEEE, MineOSCore.localization.sendMessage); y = y + 2
|
||||
end
|
||||
|
||||
local function drawFiles()
|
||||
@ -300,8 +287,8 @@ end
|
||||
local function drawAll(force)
|
||||
drawTopBar()
|
||||
drawLeftBar()
|
||||
drawBottomBar()
|
||||
drawMain()
|
||||
drawBottomBar()
|
||||
buffer.draw(force)
|
||||
end
|
||||
|
||||
@ -331,7 +318,7 @@ local function sendMessageOrFileWindow(text1, text2)
|
||||
{"EmptyLine"},
|
||||
{"Input", 0xFFFFFF, ecs.colors.orange, text2},
|
||||
{"EmptyLine"},
|
||||
{"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, lang.cancel}}
|
||||
{"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
end
|
||||
|
||||
@ -358,7 +345,7 @@ local function sendFile(path, address)
|
||||
|
||||
file:close()
|
||||
component.modem.send(address, port, "FILESENDEND")
|
||||
GUI.error(lang.fileSuccessfullySent)
|
||||
GUI.error(MineOSCore.localization.fileSuccessfullySent)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -368,8 +355,6 @@ local args = {...}
|
||||
-- buffer.clear(0xFF6666)
|
||||
|
||||
oldPixelsOfFullScreen = buffer.copy(1, 1, buffer.screen.width, buffer.screen.height)
|
||||
MineOSCore.setLocalization(lang)
|
||||
MineOSCore.loadIcons()
|
||||
calculateSizes()
|
||||
loadConfig()
|
||||
createDisks()
|
||||
@ -408,8 +393,8 @@ while true do
|
||||
if searchBarText == "" then searchBarText = nil end
|
||||
sizes.yFileList = sizes.yFileListStartPoint
|
||||
getListAndDrawAll()
|
||||
elseif obj.close:isClicked(eventData[3], eventData[4]) then
|
||||
obj.close:press(0.2)
|
||||
elseif obj.windowActionButtons.close:isClicked(eventData[3], eventData[4]) then
|
||||
obj.windowActionButtons.close:press(0.2)
|
||||
return
|
||||
elseif obj.showFormat:isClicked(eventData[3], eventData[4]) then
|
||||
config.showFileFormat = not config.showFileFormat
|
||||
@ -423,11 +408,11 @@ while true do
|
||||
obj.sortingMethod:press(0.2)
|
||||
local data = ecs.universalWindow("auto", "auto", 36, 0x262626, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", ecs.colors.orange, lang.sortingMethod},
|
||||
{"CenterText", ecs.colors.orange, MineOSCore.localization.sortingMethod},
|
||||
{"EmptyLine"},
|
||||
{"Selector", 0xFFFFFF, ecs.colors.orange, lang.sortByTypeShort, lang.sortByNameShort, lang.sortByDateShort},
|
||||
{"Selector", 0xFFFFFF, ecs.colors.orange, MineOSCore.localization.sortByTypeShort, MineOSCore.localization.sortByNameShort, MineOSCore.localization.sortByDateShort},
|
||||
{"EmptyLine"},
|
||||
{"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, lang.cancel}}
|
||||
{"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
if data[2] == "OK" then
|
||||
config.currentSortingMethod = sortingMethods[data[1]]
|
||||
@ -444,14 +429,14 @@ while true do
|
||||
if clickedAtEmptyArea then
|
||||
if obj.networkMessage and obj.networkMessage:isClicked(eventData[3], eventData[4]) then
|
||||
obj.networkMessage:press(0.2)
|
||||
local data = sendMessageOrFileWindow(lang.sendMessage, lang.messageText)
|
||||
local data = sendMessageOrFileWindow(MineOSCore.localization.sendMessage, MineOSCore.localization.messageText)
|
||||
if data[2] == "OK" then
|
||||
component.modem.send(currentNetworkAddress, port, "hereIsMessage", data[1])
|
||||
end
|
||||
clickedAtEmptyArea = false
|
||||
elseif obj.networkFile and obj.networkFile:isClicked(eventData[3], eventData[4]) then
|
||||
obj.networkFile:press(0.2)
|
||||
local data = sendMessageOrFileWindow(lang.sendFile, lang.pathToFile)
|
||||
local data = sendMessageOrFileWindow(MineOSCore.localization.sendFile, MineOSCore.localization.pathToFile)
|
||||
if data[2] == "OK" then
|
||||
if fs.exists(data[1]) then
|
||||
sendFile(data[1], currentNetworkAddress)
|
||||
@ -507,12 +492,12 @@ while true do
|
||||
if eventData[5] == 1 then
|
||||
if sizes.yFileList < sizes.yFileListStartPoint then
|
||||
sizes.yFileList = sizes.yFileList + scrollSpeed
|
||||
drawMain(); buffer.draw()
|
||||
drawMain(); drawBottomBar(); buffer.draw()
|
||||
end
|
||||
else
|
||||
if sizes.fromIcon < #fileList - sizes.xCountOfIcons then
|
||||
sizes.yFileList = sizes.yFileList - scrollSpeed
|
||||
drawMain(); buffer.draw()
|
||||
drawMain(); drawBottomBar(); buffer.draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -525,14 +510,14 @@ while true do
|
||||
sendPersonalInfo()
|
||||
drawAll()
|
||||
elseif message1 == "hereIsMessage" then
|
||||
GUI.error(message2, {title = {color = 0xFFDB40, text = lang.gotMessageFrom .. truncatedRemoteAddress}})
|
||||
GUI.error(message2, {title = {color = 0xFFDB40, text = MineOSCore.localization.gotMessageFrom .. truncatedRemoteAddress}})
|
||||
elseif message1 == "FILESTARTED" then
|
||||
_G.finderFileReceiver = io.open("MineOS/System/Finder/tempFile.lua", "wb")
|
||||
elseif message1 == "FILESEND" then
|
||||
_G.finderFileReceiver:write(message2)
|
||||
elseif message1 == "FILESENDEND" then
|
||||
_G.finderFileReceiver:close()
|
||||
local data = sendMessageOrFileWindow(lang.gotFileFrom .. truncatedRemoteAddress, lang.pathToSave)
|
||||
local data = sendMessageOrFileWindow(MineOSCore.localization.gotFileFrom .. truncatedRemoteAddress, MineOSCore.localization.pathToSave)
|
||||
if data[2] == "OK" and data[1] ~= "" then fs.rename("MineOS/System/Finder/tempFile.lua", data[1]); getListAndDrawAll() end
|
||||
end
|
||||
end
|
||||
|
||||
@ -81,6 +81,7 @@
|
||||
|
||||
viewTab = "View",
|
||||
|
||||
errorWhileRunningProgram = "An error occurred when program execution: ",
|
||||
fileDoesntExists = "File doesn't exists",
|
||||
fileSuccessfullySent = "File has been successfully sent",
|
||||
sendFile = "Send file",
|
||||
|
||||
@ -81,6 +81,7 @@
|
||||
|
||||
viewTab = "Вид",
|
||||
|
||||
errorWhileRunningProgram = "Ошибка при выполнении программы: ",
|
||||
fileDoesntExists = "Файл не существует",
|
||||
fileSuccessfullySent = "Файл успешно отправлен",
|
||||
sendFile = "Отправить файл",
|
||||
|
||||
180
MineOS/OS.lua
180
MineOS/OS.lua
@ -18,14 +18,16 @@ local copyright = [[
|
||||
-- Вычищаем копирайт из оперативки, ибо мы не можем тратить СТОЛЬКО памяти.
|
||||
-- Сколько тут, раз, два, три... 295 ASCII-символов!
|
||||
-- А это, между прочим, 59 раз по слову "Пидор". Но один раз - не пидорас, поэтому очищаем.
|
||||
-- Я передумал, не очищаем, пригодится еще. Вот же ж неоптимизированная параша!
|
||||
-- copyright = nil
|
||||
|
||||
---------------------------------------------- Библиотеки ------------------------------------------------------------------------
|
||||
|
||||
-- Адаптивная загрузка необходимых библиотек и компонентов
|
||||
local libraries = {
|
||||
MineOSCore = "MineOSCore",
|
||||
buffer = "doubleBuffering",
|
||||
MineOSCore = "MineOSCore",
|
||||
GUI = "GUI",
|
||||
image = "image",
|
||||
ecs = "ECSAPI",
|
||||
component = "component",
|
||||
@ -34,19 +36,9 @@ local libraries = {
|
||||
files = "files",
|
||||
context = "context",
|
||||
SHA2 = "SHA2",
|
||||
GUI = "GUI"
|
||||
}
|
||||
|
||||
local components = {
|
||||
gpu = "gpu",
|
||||
}
|
||||
|
||||
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end
|
||||
for comp in pairs(components) do if not _G[comp] then _G[comp] = _G.component[components[comp]] end end
|
||||
libraries, components = nil, nil
|
||||
|
||||
-- Загрузка языкового пакета
|
||||
local lang = files.loadTableFromFile("MineOS/System/OS/Languages/" .. _G.OSSettings.language .. ".lang")
|
||||
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil
|
||||
|
||||
---------------------------------------------- Переменные ------------------------------------------------------------------------
|
||||
|
||||
@ -59,6 +51,8 @@ local showFileFormat = false
|
||||
local sortingMethod = "type"
|
||||
local wallpaper
|
||||
local currentCountOfIconsInDock
|
||||
local controlDown = false
|
||||
local fileList
|
||||
|
||||
local obj = {}
|
||||
|
||||
@ -112,11 +106,14 @@ local function drawWallpaper()
|
||||
end
|
||||
end
|
||||
|
||||
local function getFileList()
|
||||
fileList = ecs.getFileList(workPath)
|
||||
fileList = ecs.sortFiles(workPath, fileList, sortingMethod, showHiddenFiles)
|
||||
end
|
||||
|
||||
--ОТРИСОВКА ИКОНОК НА РАБОЧЕМ СТОЛЕ ПО ТЕКУЩЕЙ ПАПКЕ
|
||||
local function drawDesktop()
|
||||
obj.DesktopCounters = {}
|
||||
local fileList = ecs.getFileList(workPath)
|
||||
fileList = ecs.sortFiles(workPath, fileList, sortingMethod, showHiddenFiles)
|
||||
|
||||
--Ебашим раб стол
|
||||
sizes.countOfDesktops = math.ceil(#fileList / sizes.totalCountOfIcons)
|
||||
@ -182,9 +179,7 @@ end
|
||||
|
||||
--РИСОВАТЬ ВЕСЬ ТОПБАР
|
||||
local function drawTopBar()
|
||||
--Рисуем элементы и создаем объекты
|
||||
obj.TopBarButtons = GUI.menu(1, 1, buffer.screen.width, _G.OSSettings.interfaceColor or colors.interface, {textColor = 0x000000, text = "MineOS"}, {textColor = 0x444444, text = lang.viewTab}, {textColor = 0x444444, text = lang.settings})
|
||||
--Рисуем время
|
||||
obj.TopBarButtons = GUI.menu(1, 1, buffer.screen.width, _G.OSSettings.interfaceColor or colors.interface, {textColor = 0x000000, text = "MineOS"}, {textColor = 0x444444, text = MineOSCore.localization.viewTab}, {textColor = 0x444444, text = MineOSCore.localization.settings})
|
||||
drawTime()
|
||||
end
|
||||
|
||||
@ -196,6 +191,11 @@ local function drawAll(force)
|
||||
buffer.draw(force)
|
||||
end
|
||||
|
||||
local function getFileListAndDrawAll(force)
|
||||
getFileList()
|
||||
drawAll(force)
|
||||
end
|
||||
|
||||
---------------------------------------------- Система защиты пекарни ------------------------------------------------------------------------
|
||||
|
||||
local function drawBiometry(backgroundColor, textColor, text)
|
||||
@ -210,20 +210,20 @@ local function drawBiometry(backgroundColor, textColor, text)
|
||||
end
|
||||
|
||||
local function waitForBiometry(username)
|
||||
drawBiometry(0xDDDDDD, 0x000000, username and lang.putFingerToVerify or lang.putFingerToRegister)
|
||||
drawBiometry(0xDDDDDD, 0x000000, username and MineOSCore.localization.putFingerToVerify or MineOSCore.localization.putFingerToRegister)
|
||||
while true do
|
||||
local e = {event.pull("touch")}
|
||||
local success = false
|
||||
local touchedHash = SHA2.hash(e[6])
|
||||
if username then
|
||||
if username == touchedHash then
|
||||
drawBiometry(0xCCFFBF, 0x000000, lang.welcomeBack .. e[6])
|
||||
drawBiometry(0xCCFFBF, 0x000000, MineOSCore.localization.welcomeBack .. e[6])
|
||||
success = true
|
||||
else
|
||||
drawBiometry(0x770000, 0xFFFFFF, lang.accessDenied)
|
||||
drawBiometry(0x770000, 0xFFFFFF, MineOSCore.localization.accessDenied)
|
||||
end
|
||||
else
|
||||
drawBiometry(0xCCFFBF, 0x000000, lang.fingerprintCreated)
|
||||
drawBiometry(0xCCFFBF, 0x000000, MineOSCore.localization.fingerprintCreated)
|
||||
success = true
|
||||
end
|
||||
os.sleep(0.2)
|
||||
@ -247,9 +247,9 @@ end
|
||||
local function checkPassword()
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, lang.inputPassword},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.inputPassword},
|
||||
{"EmptyLine"},
|
||||
{"Input", 0x262626, 0x880000, lang.inputPassword, "*"},
|
||||
{"Input", 0x262626, 0x880000, MineOSCore.localization.inputPassword, "*"},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xbbbbbb, 0xffffff, "OK"}}
|
||||
)
|
||||
@ -257,10 +257,10 @@ local function checkPassword()
|
||||
if hash == _G.OSSettings.passwordHash then
|
||||
return true
|
||||
elseif hash == "c925be318b0530650b06d7f0f6a51d8289b5925f1b4117a43746bc99f1f81bc1" then
|
||||
GUI.error(lang.mineOSCreatorUsedMasterPassword)
|
||||
GUI.error(MineOSCore.localization.mineOSCreatorUsedMasterPassword)
|
||||
return true
|
||||
else
|
||||
GUI.error(lang.incorrectPassword)
|
||||
GUI.error(MineOSCore.localization.incorrectPassword)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -269,10 +269,10 @@ local function setPassword()
|
||||
while true do
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, lang.passwordProtection},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.passwordProtection},
|
||||
{"EmptyLine"},
|
||||
{"Input", 0x262626, 0x880000, lang.inputPassword},
|
||||
{"Input", 0x262626, 0x880000, lang.confirmInputPassword},
|
||||
{"Input", 0x262626, 0x880000, MineOSCore.localization.inputPassword},
|
||||
{"Input", 0x262626, 0x880000, MineOSCore.localization.confirmInputPassword},
|
||||
{"EmptyLine"}, {"Button", {0xAAAAAA, 0xffffff, "OK"}}
|
||||
)
|
||||
|
||||
@ -282,7 +282,7 @@ local function setPassword()
|
||||
ecs.saveOSSettings()
|
||||
return
|
||||
else
|
||||
GUI.error(lang.passwordsAreDifferent)
|
||||
GUI.error(MineOSCore.localization.passwordsAreDifferent)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -300,19 +300,19 @@ end
|
||||
local function setProtectionMethod()
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, lang.protectYourComputer},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.protectYourComputer},
|
||||
{"EmptyLine"},
|
||||
{"Selector", 0x262626, 0x880000, lang.biometricProtection, lang.passwordProtection, lang.withoutProtection},
|
||||
{"Selector", 0x262626, 0x880000, MineOSCore.localization.biometricProtection, MineOSCore.localization.passwordProtection, MineOSCore.localization.withoutProtection},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, lang.cancel}}
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
|
||||
if data[2] == "OK" then
|
||||
if data[1] == lang.passwordProtection then
|
||||
if data[1] == MineOSCore.localization.passwordProtection then
|
||||
setPassword()
|
||||
elseif data[1] == lang.biometricProtection then
|
||||
elseif data[1] == MineOSCore.localization.biometricProtection then
|
||||
setBiometry()
|
||||
elseif data[1] == lang.withoutProtection then
|
||||
elseif data[1] == MineOSCore.localization.withoutProtection then
|
||||
setWithoutProtection()
|
||||
end
|
||||
end
|
||||
@ -406,12 +406,10 @@ end
|
||||
|
||||
---------------------------------------------- Сама ОС ------------------------------------------------------------------------
|
||||
|
||||
ecs.loadOSSettings()
|
||||
MineOSCore.setLocalization(lang)
|
||||
MineOSCore.loadIcons()
|
||||
buffer.start()
|
||||
changeResolution()
|
||||
changeWallpaper()
|
||||
drawAll(true)
|
||||
getFileListAndDrawAll()
|
||||
login()
|
||||
windows10()
|
||||
|
||||
@ -419,14 +417,14 @@ windows10()
|
||||
|
||||
while true do
|
||||
local eventData = { event.pull() }
|
||||
local clickedAtEmptyArea = true
|
||||
-- Рисовалочка
|
||||
if eventData[1] == "touch" or eventData[1] == "drag" then if controlDown then buffer.set(eventData[3], eventData[4], 0xFF8888, 0x000000, " "); buffer.draw(); clickedAtEmptyArea = false end end
|
||||
|
||||
if eventData[1] == "touch" then
|
||||
|
||||
local clickedAtEmptyArea = true
|
||||
|
||||
for _, icon in pairs(obj.DesktopIcons) do
|
||||
if icon:isClicked(eventData[3], eventData[4]) then
|
||||
if MineOSCore.iconClick(icon, eventData, colors.selection, colors.iconsSelectionTransparency, 0xFFFFFF, 0.2, showFileFormat, {method = drawAll, arguments = {}}, {method = drawAll, arguments = {true}}, {method = function() MineOSCore.safeLaunch("Finder.lua", "open", icon.path) end, arguments = {icon.path}}) then return end
|
||||
if MineOSCore.iconClick(icon, eventData, colors.selection, colors.iconsSelectionTransparency, 0xFFFFFF, 0.2, showFileFormat, {method = getFileListAndDrawAll, arguments = {}}, {method = getFileListAndDrawAll, arguments = {true}}, {method = function() MineOSCore.safeLaunch("Finder.lua", "open", icon.path) end, arguments = {icon.path}}) then return end
|
||||
clickedAtEmptyArea = false
|
||||
break
|
||||
end
|
||||
@ -446,9 +444,9 @@ while true do
|
||||
drawAll(true)
|
||||
else
|
||||
local content = ecs.readShortcut(pathOfDockShortcuts .. icon.path)
|
||||
action = context.menu(eventData[3], eventData[4], {lang.contextMenuRemoveFromDock, not (currentCountOfIconsInDock > 1)})
|
||||
action = context.menu(eventData[3], eventData[4], {MineOSCore.localization.contextMenuRemoveFromDock, not (currentCountOfIconsInDock > 1)})
|
||||
|
||||
if action == lang.contextMenuRemoveFromDock then
|
||||
if action == MineOSCore.localization.contextMenuRemoveFromDock then
|
||||
fs.remove(pathOfDockShortcuts .. icon.path)
|
||||
drawAll()
|
||||
else
|
||||
@ -478,25 +476,25 @@ while true do
|
||||
buffer.draw()
|
||||
|
||||
if button.text == "MineOS" then
|
||||
local action = context.menu(button.x, button.y + 1, {lang.aboutSystem}, {lang.updates}, "-", {lang.logout, _G.OSSettings.protectionMethod == "withoutProtection"}, {lang.reboot}, {lang.shutdown}, "-", {lang.returnToShell})
|
||||
local action = context.menu(button.x, button.y + 1, {MineOSCore.localization.aboutSystem}, {MineOSCore.localization.updates}, "-", {MineOSCore.localization.logout, _G.OSSettings.protectionMethod == "withoutProtection"}, {MineOSCore.localization.reboot}, {MineOSCore.localization.shutdown}, "-", {MineOSCore.localization.returnToShell})
|
||||
|
||||
if action == lang.returnToShell then
|
||||
if action == MineOSCore.localization.returnToShell then
|
||||
ecs.prepareToExit()
|
||||
return 0
|
||||
elseif action == lang.logout then
|
||||
elseif action == MineOSCore.localization.logout then
|
||||
drawAll()
|
||||
login()
|
||||
elseif action == lang.shutdown then
|
||||
elseif action == MineOSCore.localization.shutdown then
|
||||
ecs.TV(0)
|
||||
shell.execute("shutdown")
|
||||
elseif action == lang.reboot then
|
||||
elseif action == MineOSCore.localization.reboot then
|
||||
ecs.TV(0)
|
||||
shell.execute("reboot")
|
||||
elseif action == lang.updates then
|
||||
elseif action == MineOSCore.localization.updates then
|
||||
ecs.prepareToExit()
|
||||
shell.execute("pastebin run 0nm5b1ju")
|
||||
return 0
|
||||
elseif action == lang.aboutSystem then
|
||||
elseif action == MineOSCore.localization.aboutSystem then
|
||||
ecs.prepareToExit()
|
||||
print(copyright)
|
||||
print("А теперь жмякай любую кнопку и продолжай работу с ОС.")
|
||||
@ -504,58 +502,58 @@ while true do
|
||||
drawAll(true)
|
||||
end
|
||||
|
||||
elseif button.text == lang.viewTab then
|
||||
elseif button.text == MineOSCore.localization.viewTab then
|
||||
local action = context.menu(button.x, button.y + 1,
|
||||
{lang.showFileFormat, showFileFormat},
|
||||
{lang.hideFileFormat, not showFileFormat},
|
||||
{MineOSCore.localization.showFileFormat, showFileFormat},
|
||||
{MineOSCore.localization.hideFileFormat, not showFileFormat},
|
||||
"-",
|
||||
{lang.showHiddenFiles, showHiddenFiles},
|
||||
{lang.hideHiddenFiles, not showHiddenFiles},
|
||||
{MineOSCore.localization.showHiddenFiles, showHiddenFiles},
|
||||
{MineOSCore.localization.hideHiddenFiles, not showHiddenFiles},
|
||||
"-",
|
||||
{lang.sortByName},
|
||||
{lang.sortByDate},
|
||||
{lang.sortByType},
|
||||
{MineOSCore.localization.sortByName},
|
||||
{MineOSCore.localization.sortByDate},
|
||||
{MineOSCore.localization.sortByType},
|
||||
"-",
|
||||
{lang.contextMenuRemoveWallpaper, not wallpaper}
|
||||
{MineOSCore.localization.contextMenuRemoveWallpaper, not wallpaper}
|
||||
)
|
||||
|
||||
if action == lang.showHiddenFiles then
|
||||
if action == MineOSCore.localization.showHiddenFiles then
|
||||
showHiddenFiles = true
|
||||
drawAll()
|
||||
elseif action == lang.hideHiddenFiles then
|
||||
elseif action == MineOSCore.localization.hideHiddenFiles then
|
||||
showHiddenFiles = false
|
||||
drawAll()
|
||||
elseif action == lang.showFileFormat then
|
||||
elseif action == MineOSCore.localization.showFileFormat then
|
||||
showFileFormat = true
|
||||
drawAll()
|
||||
elseif action == lang.hideFileFormat then
|
||||
elseif action == MineOSCore.localization.hideFileFormat then
|
||||
showFileFormat = false
|
||||
drawAll()
|
||||
elseif action == lang.sortByName then
|
||||
elseif action == MineOSCore.localization.sortByName then
|
||||
sortingMethod = "name"
|
||||
drawAll()
|
||||
elseif action == lang.sortByDate then
|
||||
elseif action == MineOSCore.localization.sortByDate then
|
||||
sortingMethod = "date"
|
||||
drawAll()
|
||||
elseif action == lang.sortByType then
|
||||
elseif action == MineOSCore.localization.sortByType then
|
||||
sortingMethod = "type"
|
||||
drawAll()
|
||||
elseif action == lang.contextMenuRemoveWallpaper then
|
||||
elseif action == MineOSCore.localization.contextMenuRemoveWallpaper then
|
||||
wallpaper = nil
|
||||
fs.remove(pathToWallpaper)
|
||||
drawAll(true)
|
||||
end
|
||||
elseif button.text == lang.settings then
|
||||
elseif button.text == MineOSCore.localization.settings then
|
||||
local action = context.menu(button.x, button.y + 1,
|
||||
{lang.screenResolution},
|
||||
{MineOSCore.localization.screenResolution},
|
||||
"-",
|
||||
{lang.changePassword, _G.OSSettings.protectionMethod ~= "password"},
|
||||
{lang.setProtectionMethod},
|
||||
{MineOSCore.localization.changePassword, _G.OSSettings.protectionMethod ~= "password"},
|
||||
{MineOSCore.localization.setProtectionMethod},
|
||||
"-",
|
||||
{lang.colorScheme}
|
||||
{MineOSCore.localization.colorScheme}
|
||||
)
|
||||
|
||||
if action == lang.screenResolution then
|
||||
if action == MineOSCore.localization.screenResolution then
|
||||
local possibleResolutions = {texts = {}, scales = {}}
|
||||
local xSize, ySize = ecs.getScaledResolution(1)
|
||||
local currentScale, decreaseStep = 1, 0.1
|
||||
@ -569,11 +567,11 @@ while true do
|
||||
|
||||
local data = ecs.universalWindow("auto", "auto", 36, 0xeeeeee, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, lang.screenResolution},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.screenResolution},
|
||||
{"EmptyLine"},
|
||||
{"Selector", 0x262626, 0x880000, table.unpack(possibleResolutions.texts)},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, lang.cancel}}
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
|
||||
if data[2] == "OK" then
|
||||
@ -582,20 +580,20 @@ while true do
|
||||
ecs.saveOSSettings()
|
||||
drawAll()
|
||||
end
|
||||
elseif action == lang.changePassword then
|
||||
elseif action == MineOSCore.localization.changePassword then
|
||||
changePassword()
|
||||
elseif action == lang.setProtectionMethod then
|
||||
elseif action == MineOSCore.localization.setProtectionMethod then
|
||||
setProtectionMethod()
|
||||
elseif action == lang.colorScheme then
|
||||
elseif action == MineOSCore.localization.colorScheme then
|
||||
local data = ecs.universalWindow("auto", "auto", 36, 0xeeeeee, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, lang.colorScheme},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.colorScheme},
|
||||
{"EmptyLine"},
|
||||
{"Color", lang.backgroundColor, _G.OSSettings.backgroundColor or colors.background},
|
||||
{"Color", lang.interfaceColor, _G.OSSettings.interfaceColor or colors.interface},
|
||||
{"Color", lang.selectionColor, _G.OSSettings.selectionColor or colors.selection},
|
||||
{"Color", MineOSCore.localization.backgroundColor, _G.OSSettings.backgroundColor or colors.background},
|
||||
{"Color", MineOSCore.localization.interfaceColor, _G.OSSettings.interfaceColor or colors.interface},
|
||||
{"Color", MineOSCore.localization.selectionColor, _G.OSSettings.selectionColor or colors.selection},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, lang.cancel}}
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
|
||||
if data[4] == "OK" then
|
||||
@ -614,7 +612,7 @@ while true do
|
||||
end
|
||||
|
||||
if clickedAtEmptyArea and eventData[5] == 1 then
|
||||
MineOSCore.emptyZoneClick(eventData, workPath, {method = drawAll, arguments = {}}, {method = drawAll, arguments = {true}})
|
||||
MineOSCore.emptyZoneClick(eventData, workPath, {method = getFileListAndDrawAll, arguments = {}}, {method = getFileListAndDrawAll, arguments = {true}})
|
||||
end
|
||||
elseif eventData[1] == "OSWallpaperChanged" then
|
||||
changeWallpaper()
|
||||
@ -631,5 +629,15 @@ while true do
|
||||
drawAll()
|
||||
end
|
||||
end
|
||||
elseif eventData[1] == "key_down" then
|
||||
-- CTRL
|
||||
if eventData[4] == 29 then
|
||||
controlDown = true
|
||||
end
|
||||
elseif eventData[1] == "key_up" then
|
||||
if eventData[4] == 29 then
|
||||
controlDown = false
|
||||
drawAll()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
37
lib/GUI.lua
37
lib/GUI.lua
@ -178,6 +178,14 @@ function GUI.menu(x, y, width, menuColor, ...)
|
||||
return menuObjects
|
||||
end
|
||||
|
||||
function GUI.windowActionButtons(x, y, fatSymbol)
|
||||
local symbol = fatSymbol and "⬤" or "●"
|
||||
local windowActionButtons, background = {}
|
||||
background = buffer.get(x, y); windowActionButtons.close = GUI.button(x, y, 1, 1, background, 0xFF4940, background, 0x992400, symbol); x = x + 2
|
||||
background = buffer.get(x, y); windowActionButtons.minimize = GUI.button(x, y, 1, 1, background, 0xFFB640, background, 0x996D00, symbol); x = x + 2
|
||||
background = buffer.get(x, y); windowActionButtons.maximize = GUI.button(x, y, 1, 1, background, 0x00B640, background, 0x006D40, symbol); x = x + 2
|
||||
return windowActionButtons
|
||||
end
|
||||
|
||||
------------------------------------------------- Окна -------------------------------------------------------------------
|
||||
|
||||
@ -382,34 +390,13 @@ end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- buffer.clear(0xFFAAAA)
|
||||
-- buffer.draw(true)
|
||||
|
||||
-- GUI.error("Ублюдок, мать твою, а ну иди сюда, говно собачье, а ну решил ко мне лезть, ты... засранец вонючий, мать твою. А?! ну иди сюда, попробуй меня трахнуть, я тебя сам трахну ублюдок, анонист чертов, будь ты проклят, иди идиот, трахать тебя за свою семью, говно собачье, жлоб вонючий, дерьмо, сука, падла, иди сюда мерзавец, негодяй, гад, иди сюда ты говно, жопа!", {title = {color = 0xFF7777, text = "Ошибка авторизации"}})
|
||||
|
||||
-- local event = require("event")
|
||||
-- local myButton = GUI.adaptiveButton(2, 2, 2, 1, 0xFFFFFF, 0x000000, 0xFF8888, 0xFFFFFF, "Кнопачка")
|
||||
-- buffer.draw()
|
||||
-- while true do
|
||||
-- local e = {event.pull("touch")}
|
||||
-- if myButton:isClicked(e[3], e[4]) then
|
||||
-- myButton:press(0.2)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- local myButtons = GUI.buttons(2, 2, GUI.directions.horizontal, 2, {GUI.buttonTypes.adaptive, 2, 0, 0xCCCCCC, 0x262626, 0xFF8888, 0xFFFFFF, "Кнопачка1"}, {GUI.buttonTypes.default, 30, 1, 0xCCCCCC, 0x262626, 0xFF8888, 0xFFFFFF, "Кнопачка2"}, {GUI.buttonTypes.adaptive, 2, 0, 0xCCCCCC, 0x262626, 0xFF8888, 0xFFFFFF, "Кнопачка3"})
|
||||
-- buffer.draw()
|
||||
-- while true do
|
||||
-- local e = {event.pull("touch")}
|
||||
-- for _, button in pairs(myButtons) do
|
||||
-- if button:isClicked(e[3], e[4]) then
|
||||
-- button:press(0.2)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
return GUI
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -16,48 +16,62 @@ local libraries = {
|
||||
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end
|
||||
libraries = nil
|
||||
|
||||
-- Загрузка языкового пакета
|
||||
-- local lang = files.loadTableFromFile("MineOS/System/OS/Languages/" .. _G.OSSettings.language .. ".lang")
|
||||
local lang = {}
|
||||
local MineOSCore = {}
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
MineOSCore.iconsPath = "MineOS/System/OS/Icons/"
|
||||
MineOSCore.iconWidth = 12
|
||||
MineOSCore.iconHeight = 6
|
||||
|
||||
MineOSCore.paths = {
|
||||
localizationFile = "MineOS/System/OS/Languages/" .. _G.OSSettings.language .. ".lang",
|
||||
system = "MineOS/System/",
|
||||
icons = "MineOS/System/OS/Icons/",
|
||||
applications = "MineOS/Applications/",
|
||||
pictures = "MineOS/Pictures/",
|
||||
}
|
||||
|
||||
MineOSCore.sortingMethods = {
|
||||
type = 0,
|
||||
name = 1,
|
||||
date = 2,
|
||||
}
|
||||
|
||||
MineOSCore.colors = {
|
||||
background = 0x262626.
|
||||
}
|
||||
|
||||
MineOSCore.localization = {}
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--Присвоение языкового пакета
|
||||
function MineOSCore.setLocalization(langArray)
|
||||
lang = langArray
|
||||
function MineOSCore.loadIcon(name, path)
|
||||
if not MineOSCore.icons[name] then MineOSCore.icons[name] = image.load(path) end
|
||||
return MineOSCore.icons[name]
|
||||
end
|
||||
|
||||
--Вся необходимая информация для иконок
|
||||
function MineOSCore.loadIcons()
|
||||
if MineOSCore.icons then return end
|
||||
function MineOSCore.loadStandartIcons()
|
||||
MineOSCore.icons = {}
|
||||
MineOSCore.icons.folder = image.load(MineOSCore.iconsPath .. "Folder.pic")
|
||||
MineOSCore.icons.script = image.load(MineOSCore.iconsPath .. "Script.pic")
|
||||
MineOSCore.icons.text = image.load(MineOSCore.iconsPath .. "Text.pic")
|
||||
MineOSCore.icons.config = image.load(MineOSCore.iconsPath .. "Config.pic")
|
||||
MineOSCore.icons.lua = image.load(MineOSCore.iconsPath .. "Lua.pic")
|
||||
MineOSCore.icons.image = image.load(MineOSCore.iconsPath .. "Image.pic")
|
||||
MineOSCore.icons.pastebin = image.load(MineOSCore.iconsPath .. "Pastebin.pic")
|
||||
MineOSCore.icons.fileNotExists = image.load(MineOSCore.iconsPath .. "FileNotExists.pic")
|
||||
MineOSCore.icons.archive = image.load(MineOSCore.iconsPath .. "Archive.pic")
|
||||
MineOSCore.icons.model3D = image.load(MineOSCore.iconsPath .. "3DModel.pic")
|
||||
MineOSCore.loadIcon("folder", MineOSCore.paths.icons .. "Folder.pic")
|
||||
MineOSCore.loadIcon("script", MineOSCore.paths.icons .. "Script.pic")
|
||||
MineOSCore.loadIcon("text", MineOSCore.paths.icons .. "Text.pic")
|
||||
MineOSCore.loadIcon("config", MineOSCore.paths.icons .. "Config.pic")
|
||||
MineOSCore.loadIcon("lua", MineOSCore.paths.icons .. "Lua.pic")
|
||||
MineOSCore.loadIcon("image", MineOSCore.paths.icons .. "Image.pic")
|
||||
MineOSCore.loadIcon("pastebin", MineOSCore.paths.icons .. "Pastebin.pic")
|
||||
MineOSCore.loadIcon("fileNotExists", MineOSCore.paths.icons .. "FileNotExists.pic")
|
||||
MineOSCore.loadIcon("archive", MineOSCore.paths.icons .. "Archive.pic")
|
||||
MineOSCore.loadIcon("model3D", MineOSCore.paths.icons .. "3DModel.pic")
|
||||
end
|
||||
|
||||
function MineOSCore.init()
|
||||
MineOSCore.localization = files.loadTableFromFile(MineOSCore.paths.localizationFile)
|
||||
MineOSCore.loadStandartIcons()
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--Отрисовка одной иконки
|
||||
function MineOSCore.drawIcon(x, y, path, showFileFormat, nameColor)
|
||||
local fileFormat, icon = ecs.getFileFormat(path)
|
||||
@ -67,9 +81,7 @@ function MineOSCore.drawIcon(x, y, path, showFileFormat, nameColor)
|
||||
-- icon = "cyka"
|
||||
-- MineOSCore.icons[icon] = image.load(path .. "/Resources/Icon.pic")
|
||||
icon = path .. "/Resources/Icon.pic"
|
||||
if not MineOSCore.icons[icon] then
|
||||
MineOSCore.icons[icon] = image.load(icon)
|
||||
end
|
||||
MineOSCore.loadIcon(icon, icon)
|
||||
else
|
||||
icon = "folder"
|
||||
end
|
||||
@ -112,7 +124,9 @@ function MineOSCore.drawIcon(x, y, path, showFileFormat, nameColor)
|
||||
end
|
||||
|
||||
function MineOSCore.safeLaunch(command, ...)
|
||||
local oldResolutionWidth, oldResolutionHeight = component.gpu.getResolution()
|
||||
local success, reason = pcall(loadfile(command), ...)
|
||||
component.gpu.setResolution(oldResolutionWidth, oldResolutionHeight)
|
||||
--Ебал я автора мода в задницу, кусок ебанутого говна
|
||||
--Какого хуя я должен вставлять кучу костылей в свой прекрасный код только потому, что эта ублюдочная
|
||||
--скотина захотела выдавать table из pcall? Что, блядь? Где это видано, сука?
|
||||
@ -120,14 +134,13 @@ function MineOSCore.safeLaunch(command, ...)
|
||||
--Что за ебливая сучья логика?
|
||||
if not success and type(reason) ~= "table" then
|
||||
reason = ecs.parseErrorMessage(reason, false)
|
||||
GUI.error(reason, {title = {color = 0xFFDB40, text = "Ошибка при выполнении программы"}})
|
||||
GUI.error(reason, {title = {color = 0xFFDB40, text = MineOSCore.localization.errorWhileRunningProgram}})
|
||||
end
|
||||
buffer.start()
|
||||
end
|
||||
|
||||
-- Запуск приложения
|
||||
function MineOSCore.launchIcon(path, translate)
|
||||
--Запоминаем, какое разрешение было
|
||||
local oldWidth, oldHeight = component.gpu.getResolution()
|
||||
--Получаем файл формат заранее
|
||||
local fileFormat = ecs.getFileFormat(path)
|
||||
local isDirectory = fs.isDirectory(path)
|
||||
@ -153,7 +166,7 @@ function MineOSCore.launchIcon(path, translate)
|
||||
MineOSCore.safeLaunch("MineOS/Applications/3DPrint.app/3DPrint.lua open " .. path)
|
||||
|
||||
--Если это текст или конфиг или языковой
|
||||
elseif fileFormat == ".txt" or fileFormat == ".cfg" or fileFormat == ".lang" then
|
||||
elseif fileFormat == ".txt" or fileFormat == ".cfg" or fileFormat == ".MineOSCore.localization" then
|
||||
ecs.prepareToExit()
|
||||
MineOSCore.safeLaunch("bin/edit.lua", path)
|
||||
|
||||
@ -163,16 +176,13 @@ function MineOSCore.launchIcon(path, translate)
|
||||
if fs.exists(shortcutLink) then
|
||||
MineOSCore.launchIcon(shortcutLink)
|
||||
else
|
||||
GUI.error(lang.shortcutIsCorrupted)
|
||||
GUI.error(MineOSCore.localization.shortcutIsCorrupted)
|
||||
end
|
||||
|
||||
--Если это архив
|
||||
elseif fileFormat == ".zip" then
|
||||
zip.unarchive(path, (fs.path(path) or ""))
|
||||
end
|
||||
--Ставим старое разрешение
|
||||
component.gpu.setResolution(oldWidth, oldHeight)
|
||||
buffer.start()
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -244,124 +254,124 @@ function MineOSCore.iconRightClick(icon, oldPixelsOfIcon, eventData, fileFormat,
|
||||
if fs.isDirectory(icon.path) then
|
||||
if fileFormat == ".app" then
|
||||
action = context.menu(eventData[3], eventData[4],
|
||||
{lang.contextMenuShowPackageContent},
|
||||
{MineOSCore.localization.contextMenuShowPackageContent},
|
||||
"-",
|
||||
{lang.contextMenuCopy},
|
||||
{lang.contextMenuPaste, not _G.clipboard},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuPaste, not _G.clipboard},
|
||||
"-",
|
||||
{lang.contextMenuRename},
|
||||
{lang.contextMenuCreateShortcut},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut},
|
||||
"-",
|
||||
{lang.contextMenuUploadToPastebin, true},
|
||||
{MineOSCore.localization.contextMenuUploadToPastebin, true},
|
||||
"-",
|
||||
{lang.contextMenuAddToDock, not somethingCanBeAddedToDock},
|
||||
{lang.contextMenuDelete}
|
||||
{MineOSCore.localization.contextMenuAddToDock, not somethingCanBeAddedToDock},
|
||||
{MineOSCore.localization.contextMenuDelete}
|
||||
)
|
||||
else
|
||||
action = context.menu(eventData[3], eventData[4],
|
||||
{lang.contextMenuCopy},
|
||||
{lang.contextMenuRename},
|
||||
{lang.contextMenuCreateShortcut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut},
|
||||
"-",
|
||||
{lang.contextMenuArchive},
|
||||
{MineOSCore.localization.contextMenuArchive},
|
||||
"-",
|
||||
{lang.contextMenuDelete}
|
||||
{MineOSCore.localization.contextMenuDelete}
|
||||
)
|
||||
end
|
||||
else
|
||||
if fileFormat == ".pic" then
|
||||
action = context.menu(eventData[3], eventData[4],
|
||||
{lang.contextMenuEdit},
|
||||
{lang.contextMenuEditInPhotoshop},
|
||||
{lang.contextMenuSetAsWallpaper},
|
||||
{MineOSCore.localization.contextMenuEdit},
|
||||
{MineOSCore.localization.contextMenuEditInPhotoshop},
|
||||
{MineOSCore.localization.contextMenuSetAsWallpaper},
|
||||
"-",
|
||||
{lang.contextMenuCopy, false},
|
||||
{lang.contextMenuRename},
|
||||
{lang.contextMenuCreateShortcut},
|
||||
{MineOSCore.localization.contextMenuCopy, false},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut},
|
||||
"-",
|
||||
{lang.contextMenuUploadToPastebin, true},
|
||||
{MineOSCore.localization.contextMenuUploadToPastebin, true},
|
||||
"-",
|
||||
{lang.contextMenuAddToDock, not somethingCanBeAddedToDock},
|
||||
{lang.contextMenuDelete, false}
|
||||
{MineOSCore.localization.contextMenuAddToDock, not somethingCanBeAddedToDock},
|
||||
{MineOSCore.localization.contextMenuDelete, false}
|
||||
)
|
||||
else
|
||||
action = context.menu(eventData[3], eventData[4],
|
||||
{lang.contextMenuEdit},
|
||||
-- {lang.contextMenuCreateApplication},
|
||||
{MineOSCore.localization.contextMenuEdit},
|
||||
-- {MineOSCore.localization.contextMenuCreateApplication},
|
||||
"-",
|
||||
{lang.contextMenuCopy},
|
||||
{lang.contextMenuRename},
|
||||
{lang.contextMenuCreateShortcut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut},
|
||||
"-",
|
||||
{lang.contextMenuUploadToPastebin, true},
|
||||
{MineOSCore.localization.contextMenuUploadToPastebin, true},
|
||||
"-",
|
||||
{lang.contextMenuAddToDock, not somethingCanBeAddedToDock},
|
||||
{lang.contextMenuDelete}
|
||||
{MineOSCore.localization.contextMenuAddToDock, not somethingCanBeAddedToDock},
|
||||
{MineOSCore.localization.contextMenuDelete}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if action == lang.contextMenuEdit then
|
||||
if action == MineOSCore.localization.contextMenuEdit then
|
||||
ecs.prepareToExit()
|
||||
MineOSCore.safeLaunch("bin/edit.lua", icon.path)
|
||||
executeMethod(fullRefreshMethod)
|
||||
elseif action == lang.contextMenuEditInPhotoshop then
|
||||
elseif action == MineOSCore.localization.contextMenuEditInPhotoshop then
|
||||
MineOSCore.safeLaunch("MineOS/Applications/Photoshop.app/Photoshop.lua", "open", icon.path)
|
||||
executeMethod(fullRefreshMethod)
|
||||
-- buffer.paste(1, 1, oldPixelsOfFullScreen)
|
||||
-- drawAll(true)
|
||||
elseif action == lang.contextMenuAddToFavourites then
|
||||
elseif action == MineOSCore.localization.contextMenuAddToFavourites then
|
||||
-- addToFavourites(fs.name(path), path)
|
||||
computer.pushSignal("finderFavouriteAdded", icon.path)
|
||||
executeMethod(drawAllMethod)
|
||||
elseif action == lang.contextMenuShowPackageContent then
|
||||
elseif action == MineOSCore.localization.contextMenuShowPackageContent then
|
||||
executeMethod(changeCurrentPathMethod)
|
||||
executeMethod(drawAllMethod)
|
||||
-- changePath(path)
|
||||
-- drawAll()
|
||||
elseif action == lang.contextMenuCopy then
|
||||
elseif action == MineOSCore.localization.contextMenuCopy then
|
||||
_G.clipboard = icon.path
|
||||
executeMethod(drawAllMethod)
|
||||
elseif action == lang.contextMenuPaste then
|
||||
elseif action == MineOSCore.localization.contextMenuPaste then
|
||||
ecs.copy(_G.clipboard, fs.path(icon.path) or "")
|
||||
executeMethod(drawAllMethod)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
-- drawAll()
|
||||
elseif action == lang.contextMenuDelete then
|
||||
elseif action == MineOSCore.localization.contextMenuDelete then
|
||||
fs.remove(icon.path)
|
||||
executeMethod(drawAllMethod)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
-- drawAll()
|
||||
elseif action == lang.contextMenuRename then
|
||||
elseif action == MineOSCore.localization.contextMenuRename then
|
||||
ecs.rename(icon.path)
|
||||
executeMethod(drawAllMethod)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
-- drawAll()
|
||||
elseif action == lang.contextMenuCreateShortcut then
|
||||
elseif action == MineOSCore.localization.contextMenuCreateShortcut then
|
||||
ecs.createShortCut(fs.path(icon.path).."/"..ecs.hideFileFormat(fs.name(icon.path))..".lnk", icon.path)
|
||||
executeMethod(drawAllMethod)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
-- drawAll()
|
||||
elseif action == lang.contextMenuArchive then
|
||||
elseif action == MineOSCore.localization.contextMenuArchive then
|
||||
-- ecs.info("auto", "auto", "", "Архивация файлов...")
|
||||
archive.pack(ecs.hideFileFormat(fs.name(icon.path))..".pkg", icon.path)
|
||||
executeMethod(drawAllMethod)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
-- drawAll()
|
||||
elseif action == lang.contextMenuUploadToPastebin then
|
||||
elseif action == MineOSCore.localization.contextMenuUploadToPastebin then
|
||||
MineOSCore.safeLaunch("MineOS/Applications/Pastebin.app/Pastebin.lua", "upload", icon.path)
|
||||
executeMethod(fullRefreshMethod)
|
||||
-- shell.execute("MineOS/Applications/Pastebin.app/Pastebin.lua upload " .. path)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
-- drawAll(true)
|
||||
elseif action == lang.contextMenuSetAsWallpaper then
|
||||
elseif action == MineOSCore.localization.contextMenuSetAsWallpaper then
|
||||
--ecs.error(path)
|
||||
ecs.createShortCut("MineOS/System/OS/Wallpaper.lnk", icon.path)
|
||||
computer.pushSignal("OSWallpaperChanged")
|
||||
return true
|
||||
-- buffer.paste(1, 1, oldPixelsOfFullScreen)
|
||||
-- buffer.draw()
|
||||
elseif action == lang.contextMenuCreateApplication then
|
||||
elseif action == MineOSCore.localization.contextMenuCreateApplication then
|
||||
ecs.newApplicationFromLuaFile(icon.path, fs.path(icon.path) or "")
|
||||
executeMethod(drawAllMethod)
|
||||
-- getFileList(workPathHistory[currentWorkPathHistoryElement])
|
||||
@ -387,31 +397,25 @@ function MineOSCore.iconClick(icon, eventData, selectionColor, selectionTranspar
|
||||
end
|
||||
|
||||
function MineOSCore.emptyZoneClick(eventData, workPath, drawAllMethod, fullRefreshMethod)
|
||||
local action = context.menu(eventData[3], eventData[4], {lang.contextMenuNewFile}, {lang.contextMenuNewFolder}, {lang.contextMenuNewApplication}, "-", {lang.contextMenuPaste, (_G.clipboard == nil), "^V"})
|
||||
if action == lang.contextMenuNewFile then
|
||||
local action = context.menu(eventData[3], eventData[4], {MineOSCore.localization.contextMenuNewFile}, {MineOSCore.localization.contextMenuNewFolder}, {MineOSCore.localization.contextMenuNewApplication}, "-", {MineOSCore.localization.contextMenuPaste, (_G.clipboard == nil), "^V"})
|
||||
if action == MineOSCore.localization.contextMenuNewFile then
|
||||
ecs.newFile(workPath)
|
||||
executeMethod(fullRefreshMethod)
|
||||
elseif action == lang.contextMenuNewFolder then
|
||||
elseif action == MineOSCore.localization.contextMenuNewFolder then
|
||||
ecs.newFolder(workPath)
|
||||
executeMethod(drawAllMethod)
|
||||
elseif action == lang.contextMenuPaste then
|
||||
elseif action == MineOSCore.localization.contextMenuPaste then
|
||||
ecs.copy(_G.clipboard, workPath)
|
||||
executeMethod(drawAllMethod)
|
||||
elseif action == lang.contextMenuNewApplication then
|
||||
elseif action == MineOSCore.localization.contextMenuNewApplication then
|
||||
ecs.newApplication(workPath)
|
||||
executeMethod(drawAllMethod)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- MineOSCore.loadIcons()
|
||||
-- buffer.start()
|
||||
|
||||
-- buffer.clear(0x262626)
|
||||
-- MineOSCore.drawIconField(2, 2, 5, 5, 1, 25, 2, 1, "lib/", "type", true, 0xFFFFFF)
|
||||
-- buffer.draw(true)
|
||||
MineOSCore.init()
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user