This commit is contained in:
Igor Timofeev 2017-04-25 13:42:06 +03:00
parent 2a500eadc1
commit 3fbf24097c
8 changed files with 182 additions and 762 deletions

View File

@ -5,7 +5,7 @@
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/About/",
type="Script",
forceDownload=true,
version=3.55,
version=3.56,
},
{
path="/MineOS/Pictures/MoonTouch.pic",
@ -66,14 +66,14 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/Localization/Russian.lang",
type="Script",
forceDownload=true,
version=1.22,
version=1.23,
},
{
path="/MineOS/System/OS/Localization/English.lang",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/Localization/English.lang",
type="Script",
forceDownload=true,
version=1.22,
version=1.23,
},
----------------------------------------------------- Системные иконки --------------------------------------------------------------------------
@ -198,14 +198,14 @@
path="/lib/MineOSCore.lua",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
type="Library",
version=1.57,
version=1.58,
},
{
path="/lib/advancedLua.lua",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/advancedLua.lua",
type="Library",
preloadFile=true,
version=1.11,
version=1.12,
},
{
path="/lib/web.lua",

View File

@ -67,8 +67,8 @@ local cloudWidth = math.floor(mainZoneWidth * 0.7)
-------------------------------------------------------------------------------------------------------------------------------
local settingsPath = "MineOS/System/VK/Settings.cfg"
local VKLogoImagePath = "MineOS/Applications/VK.app/Resources/VKLogo.pic"
local settingsPath = "/MineOS/System/VK/Settings.cfg"
local VKLogoImagePath = "/MineOS/Applications/VK.app/Resources/VKLogo.pic"
-- local leftBarElements = {"Новости", "Друзья", "Сообщения", "Настройки", "Выход"}
local leftBarElements = { "Моя страница", "Друзья", "Сообщения", "Аудиозаписи", "Новости", "Настройки", "Выход" }
local currentLeftBarElement = 3

View File

@ -1,4 +1,11 @@
{
newName = "New name",
folderName = "Folder name",
fileName = "File name",
applicationName = "Application name",
fileAlreadyExists = "File already exists",
resolution = "Screen resolution",
pressAnyKeyToContinue = "Press any key to continue",
screensaver = "Screensaver",
screensaverDelay = "Delay",

View File

@ -1,4 +1,10 @@
{
newName = "Новое имя",
folderName = "Имя папки",
fileName = "Имя файла",
applicationName = "Имя приложения",
fileAlreadyExists = "Файл уже существует",
resolution = "Разрешение экрана",
pressAnyKeyToContinue = "Нажмите любую клавишу, чтобы продолжить",
screensaver = "Заставка",

View File

@ -1,685 +1 @@
---------------------------------------------- Копирайт, епта ------------------------------------------------------------------------
local copyright = [[
Тут можно было бы написать кучу текста, мол,
вы не имеете прав на использование этой хуйни в
коммерческих целях и прочую чушь, навеянную нам
западной культурой. Но я же не пидор какой-то, верно?
Просто помни, что эту ОСь накодил Тимофеев Игорь,
ссылка на ВК: vk.com/id7799889
]]
-- Вычищаем копирайт из оперативки, ибо мы не можем тратить СТОЛЬКО памяти.
-- Сколько тут, раз, два, три... 282 UTF-8 символа!
-- А это, между прочим, 56 раз по слову "Пидор". Но один раз - не пидорас, поэтому очищаем.
copyright = nil
---------------------------------------------- Адаптивная загрузка библиотек ------------------------------------------------------------------------
package.loaded.MineOSCore = nil
local component = require("component")
local unicode = require("unicode")
local fs = require("filesystem")
local event = require("event")
local image = require("image")
local buffer = require("doubleBuffering")
local GUI = require("GUI")
local MineOSCore = require("MineOSCore")
local ecs = require("ECSAPI")
---------------------------------------------- Базовые константы ------------------------------------------------------------------------
local colors = {
background = 0x1B1B1B,
topBarTransparency = 20,
selection = ecs.colors.lightBlue,
interface = 0xCCCCCC,
dockBaseTransparency = 70,
dockTransparencyAdder = 10,
iconsSelectionTransparency = 20,
desktopCounter = 0x999999,
desktopCounterActive = 0xFFFFFF,
desktopPainting = 0xEEEEEE,
}
local sizes = {
heightOfDock = 6,
xSpaceBetweenIcons = 2,
ySpaceBetweenIcons = 1,
}
local screensaversPath, screensaverTimer = MineOSCore.paths.system .. "OS/Screensavers/", 0
local currentWorkpathHistoryIndex, workpathHistory = 1, {MineOSCore.paths.desktop}
local workspace
local currentDesktop, countOfDesktops = 1
---------------------------------------------- Система защиты пекарни ------------------------------------------------------------------------
local function drawBiometry(backgroundColor, textColor, text)
local width, height = 70, 21
local fingerWidth, fingerHeight = 24, 14
local x, y = math.floor(buffer.screen.width / 2 - width / 2), math.floor(buffer.screen.height / 2 - height / 2)
buffer.square(x, y, width, height, backgroundColor, 0x000000, " ", nil)
buffer.image(math.floor(x + width / 2 - fingerWidth / 2), y + 2, image.fromString([[180E0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 000000 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 000000 000000 0000FF 0000FF 000000 000000 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 000000 000000 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF ]]))
buffer.text(math.floor(x + width / 2 - unicode.len(text) / 2), y + height - 3, textColor, text)
buffer.draw()
end
local function waitForBiometry(username)
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 = require("SHA2").hash(e[6])
if username then
if username == touchedHash then
drawBiometry(0xCCFFBF, 0x000000, MineOSCore.localization.welcomeBack .. e[6])
success = true
else
drawBiometry(0x770000, 0xFFFFFF, MineOSCore.localization.accessDenied)
end
else
drawBiometry(0xCCFFBF, 0x000000, MineOSCore.localization.fingerprintCreated)
success = true
end
os.sleep(0.2)
workspace:draw()
buffer.draw()
return success, e[6]
end
end
local function setBiometry()
while true do
local success, username = waitForBiometry()
if success then
_G.OSSettings.protectionMethod = "biometric"
_G.OSSettings.passwordHash = require("SHA2").hash(username)
MineOSCore.saveOSSettings()
break
end
end
end
local function checkPassword()
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.inputPassword)
local inputTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, "Password", true, "*")
local label = container.layout:addLabel(1, 1, 36, 1, 0xFF4940, MineOSCore.localization.incorrectPassword):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
label.isHidden = true
workspace:draw()
buffer.draw()
container.panel.onTouch = function()
local hash = require("SHA2").hash(inputTextBox.text or "")
if hash == _G.OSSettings.passwordHash then
workspace:deleteChildren(#workspace.children)
workspace:draw()
buffer.draw()
elseif hash == "c925be318b0530650b06d7f0f6a51d8289b5925f1b4117a43746bc99f1f81bc1" then
GUI.error(MineOSCore.localization.mineOSCreatorUsedMasterPassword)
workspace:deleteChildren(#workspace.children)
workspace:draw()
buffer.draw()
else
label.isHidden = false
workspace:draw()
buffer.draw()
end
end
end
local function setPassword()
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.passwordProtection)
local inputTextBox1 = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, MineOSCore.localization.inputPassword, true, "*")
local inputTextBox2 = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, MineOSCore.localization.confirmInputPassword, true, "*")
workspace:draw()
buffer.draw()
container.panel.onTouch = function()
if inputTextBox1.text == inputTextBox2.text then
workspace:deleteChildren(#workspace.children)
_G.OSSettings.protectionMethod = "password"
_G.OSSettings.passwordHash = require("SHA2").hash(inputTextBox1.text)
MineOSCore.saveOSSettings()
workspace:draw()
buffer.draw()
else
GUI.error(MineOSCore.localization.passwordsAreDifferent)
end
end
end
local function setWithoutProtection()
_G.OSSettings.passwordHash = nil
_G.OSSettings.protectionMethod = "withoutProtection"
MineOSCore.saveOSSettings()
end
local function setProtectionMethod()
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.protectYourComputer)
local comboBox = container.layout:addComboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE)
comboBox:addItem(MineOSCore.localization.biometricProtection)
comboBox:addItem(MineOSCore.localization.passwordProtection)
comboBox:addItem(MineOSCore.localization.withoutProtection)
workspace:draw()
buffer.draw()
container.panel.onTouch = function()
workspace:deleteChildren(#workspace.children)
workspace:draw()
buffer.draw()
if comboBox.currentItem == 1 then
setBiometry()
elseif comboBox.currentItem == 2 then
setPassword()
elseif comboBox.currentItem == 3 then
setWithoutProtection()
end
end
end
local function login()
event.interuptingEnabled = false
if not _G.OSSettings.protectionMethod then
setProtectionMethod()
elseif _G.OSSettings.protectionMethod == "password" then
checkPassword()
elseif _G.OSSettings.protectionMethod == "biometric" then
while true do
local success, username = waitForBiometry(_G.OSSettings.passwordHash)
if success then break end
end
end
event.interuptingEnabled = true
end
---------------------------------------------- Система нотификаций ------------------------------------------------------------------------
local function windows10()
if math.random(1, 100) > 25 or _G.OSSettings.showWindows10Upgrade == false then return end
local width = 44
local height = 12
local x = math.floor(buffer.screen.width / 2 - width / 2)
local y = 2
local function draw(background)
buffer.square(x, y, width, height, background, 0xFFFFFF, " ")
buffer.square(x, y + height - 2, width, 2, 0xFFFFFF, 0xFFFFFF, " ")
buffer.text(x + 2, y + 1, 0xFFFFFF, "Get Windows 10")
buffer.text(x + width - 3, y + 1, 0xFFFFFF, "X")
buffer.image(x + 2, y + 4, image.load("/MineOS/System/OS/Icons/Computer.pic"))
buffer.text(x + 12, y + 4, 0xFFFFFF, "Your MineOS is ready for your")
buffer.text(x + 12, y + 5, 0xFFFFFF, "free upgrade.")
buffer.text(x + 2, y + height - 2, 0x999999, "For a short time we're offering")
buffer.text(x + 2, y + height - 1, 0x999999, "a free upgrade to")
buffer.text(x + 20, y + height - 1, background, "Windows 10")
buffer.draw()
end
local function disableUpdates()
_G.OSSettings.showWindows10Upgrade = false
MineOSCore.saveOSSettings()
end
draw(0x33B6FF)
while true do
local eventData = {event.pull("touch")}
if ecs.clickedAtArea(eventData[3], eventData[4], x, y, x + width - 1, x + height - 1) then
draw(0x0092FF)
os.sleep(0.2)
workspace:draw()
buffer.draw()
disableUpdates()
return
end
end
end
---------------------------------------------- Основные функции ------------------------------------------------------------------------
local function changeWallpaper()
if _G.OSSettings.wallpaper and fs.exists(_G.OSSettings.wallpaper) then
workspace.wallpaper.image = image.load(_G.OSSettings.wallpaper)
workspace.wallpaper.isHidden = false
else
workspace.wallpaper.image = nil
workspace.wallpaper.isHidden = true
end
end
local function changeWorkpath(newWorkpathHistoryIndex)
currentDesktop = 1
currentWorkpathHistoryIndex = newWorkpathHistoryIndex
workspace.iconField.workpath = workpathHistory[currentWorkpathHistoryIndex]
workspace.background.onTouch = function(eventData)
if eventData[5] == 1 then
MineOSCore.emptyZoneClick(eventData, workspace, workspace.iconField.workpath)
end
end
workspace.wallpaper.onTouch = workspace.background.onTouch
end
local function updateDesktopCounters()
countOfDesktops = math.ceil(#workspace.iconField.fileList / workspace.iconField.iconCount.total)
workspace.desktopCounters.children = {}
local x = 1
if #workpathHistory > 1 then
workspace.desktopCounters:addButton(x, 1, 1, 1, nil, 0xEEEEEE, nil, 0x888888, "<").onTouch = function()
table.remove(workpathHistory, #workpathHistory)
changeWorkpath(#workpathHistory)
workspace.updateFileList()
end; x = x + 3
end
if workpathHistory[currentWorkpathHistoryIndex] ~= "/" then
workspace.desktopCounters:addButton(x, 1, 4, 1, nil, 0xEEEEEE, nil, 0x888888, "Root").onTouch = function()
table.insert(workpathHistory, "/")
changeWorkpath(#workpathHistory)
workspace.updateFileList()
end; x = x + 6
end
if workpathHistory[currentWorkpathHistoryIndex] ~= MineOSCore.paths.desktop then
workspace.desktopCounters:addButton(x, 1, 7, 1, nil, 0xEEEEEE, nil, 0x888888, "Desktop").onTouch = function()
table.insert(workpathHistory, MineOSCore.paths.desktop)
changeWorkpath(#workpathHistory)
workspace.updateFileList()
end; x = x + 9
end
if countOfDesktops > 1 then
for i = 1, countOfDesktops do
workspace.desktopCounters:addButton(x, 1, 1, 1, nil, i == currentDesktop and 0xEEEEEE or 0xBBBBBB, nil, 0x888888, "").onTouch = function()
if currentDesktop ~= i then
currentDesktop = i
workspace.updateFileList()
end
end; x = x + 3
end
end
workspace.desktopCounters.width = x - 3
workspace.desktopCounters.localPosition.x = math.floor(workspace.width / 2 - workspace.desktopCounters.width / 2)
workspace.desktopCounters.localPosition.y = workspace.height - sizes.heightOfDock - 2
end
local function updateDock()
local function moveDockShortcut(iconIndex, direction)
_G.OSSettings.dockShortcuts[iconIndex], _G.OSSettings.dockShortcuts[iconIndex + direction] = swap(_G.OSSettings.dockShortcuts[iconIndex], _G.OSSettings.dockShortcuts[iconIndex + direction])
MineOSCore.saveOSSettings()
updateDock()
workspace:draw()
buffer.draw()
end
workspace.dockContainer.width = (#_G.OSSettings.dockShortcuts + 1) * (MineOSCore.iconWidth + sizes.xSpaceBetweenIcons) - sizes.xSpaceBetweenIcons
workspace.dockContainer.localPosition.x = math.floor(workspace.width / 2 - workspace.dockContainer.width / 2)
workspace.dockContainer.localPosition.y = workspace.height - sizes.heightOfDock + 1
workspace.dockContainer:deleteChildren()
local xPos = 1
for iconIndex = 1, #_G.OSSettings.dockShortcuts do
local iconObject = MineOSCore.createIconObject(xPos, 1, _G.OSSettings.dockShortcuts[iconIndex].path, 0x262626, _G.OSSettings.showFileFormat)
iconObject.onRightClick = function(iconObject, eventData)
local menu = GUI.contextMenu(eventData[3], eventData[4])
menu:addItem(MineOSCore.localization.contextMenuShowContainingFolder).onTouch = function()
table.insert(workpathHistory, fs.path(iconObject.path))
changeWorkpath(#workpathHistory)
workspace.updateFileList()
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.contextMenuMoveRight, iconIndex >= #_G.OSSettings.dockShortcuts).onTouch = function()
moveDockShortcut(iconIndex, 1)
end
menu:addItem(MineOSCore.localization.contextMenuMoveLeft, iconIndex <= 1).onTouch = function()
moveDockShortcut(iconIndex, -1)
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.contextMenuRemoveFromDock, _G.OSSettings.dockShortcuts[iconIndex].canNotBeDeleted or #_G.OSSettings.dockShortcuts < 2).onTouch = function()
table.remove(_G.OSSettings.dockShortcuts, iconIndex)
MineOSCore.saveOSSettings()
updateDock()
workspace:draw()
buffer.draw()
end
menu:show()
end
workspace.dockContainer:addChild(iconObject, GUI.objectTypes.container)
xPos = xPos + MineOSCore.iconWidth + sizes.xSpaceBetweenIcons
end
local iconObject = MineOSCore.createIconObject(xPos, 1, MineOSCore.paths.trash, 0x262626, _G.OSSettings.showFileFormat)
iconObject.iconImage.image = MineOSCore.icons.trash
iconObject.onRightClick = function(iconObject, eventData)
local menu = GUI.contextMenu(eventData[3], eventData[4])
menu:addItem(MineOSCore.localization.emptyTrash).onTouch = function()
local data = ecs.universalWindow("auto", "auto", 36, 0xeeeeee, true,
{"EmptyLine"},
{"CenterText", 0x000000, MineOSCore.localization.areYouSure},
{"EmptyLine"},
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
)
if data[1] == "OK" then
for file in fs.list(MineOSCore.paths.trash) do
fs.remove(MineOSCore.paths.trash .. file)
end
workspace.updateFileList()
end
end
menu:show()
end
workspace.dockContainer:addChild(iconObject, GUI.objectTypes.container)
end
-- Отрисовка дока
local function createDock()
workspace.dockContainer = workspace:addContainer(1, 1, workspace.width, sizes.heightOfDock)
-- Отрисовка дока
local oldDraw = workspace.dockContainer.draw
workspace.dockContainer.draw = function(dockContainer)
local currentDockTransparency, currentDockWidth, xPos, yPos = colors.dockBaseTransparency, dockContainer.width, dockContainer.x, dockContainer.y + 2
local color = _G.OSSettings.interfaceColor or colors.interface
for i = 1, dockContainer.height do
buffer.text(xPos, yPos, color, "", currentDockTransparency)
buffer.square(xPos + 1, yPos, currentDockWidth - 2, 1, color, 0xFFFFFF, " ", currentDockTransparency)
buffer.text(xPos + currentDockWidth - 1, yPos, color, "", currentDockTransparency)
currentDockTransparency, currentDockWidth, xPos, yPos = currentDockTransparency - colors.dockTransparencyAdder, currentDockWidth + 2, xPos - 1, yPos + 1
end
oldDraw(dockContainer)
end
end
local function changeResolution()
currentDesktop = 1
buffer.setResolution(table.unpack(_G.OSSettings.resolution or {160, 50}))
workspace.width, workspace.height = buffer.screen.width, buffer.screen.height
workspace.iconField.iconCount.width, workspace.iconField.iconCount.height, workspace.iconField.iconCount.total = MineOSCore.getParametersForDrawingIcons(workspace.width, workspace.height - sizes.heightOfDock - 5, sizes.xSpaceBetweenIcons, sizes.ySpaceBetweenIcons)
workspace.iconField.localPosition.x = math.floor(workspace.width / 2 - (workspace.iconField.iconCount.width * (MineOSCore.iconWidth + sizes.xSpaceBetweenIcons) - sizes.xSpaceBetweenIcons) / 2)
workspace.iconField.localPosition.y = 3
workspace.menu.width = workspace.width
workspace.background.width, workspace.background.height = workspace.width, workspace.height
workspace.updateFileList(true)
end
local function createWorkspace()
workspace = GUI.fullScreenWindow()
workspace.background = workspace:addPanel(1, 1, workspace.width, workspace.height, _G.OSSettings.backgroundColor or colors.background)
workspace.wallpaper = workspace:addImage(1, 1, {workspace.width, workspace.height})
workspace.desktopCounters = workspace:addContainer(1, 1, 1, 1)
workspace.iconField = workspace:addChild(
MineOSCore.createIconField(
1, 1, 1, 1, 1, 1, 1,
sizes.xSpaceBetweenIcons,
sizes.ySpaceBetweenIcons,
0xFFFFFF,
_G.OSSettings.showFileFormat == nil and true or _G.OSSettings.showFileFormat,
_G.OSSettings.showHiddenFiles == nil and true or _G.OSSettings.showHiddenFiles,
(_G.OSSettings.sortingMethod or "type"),
"/"
),
GUI.objectTypes.container
)
createDock()
workspace.menu = workspace:addMenu(1, 1, workspace.width, _G.OSSettings.interfaceColor or colors.interface, 0x444444, 0x3366CC, 0xFFFFFF, colors.topBarTransparency)
local item1 = workspace.menu:addItem("MineOS", 0x000000)
item1.onTouch = function()
local menu = GUI.contextMenu(item1.x, item1.y + 1)
-- menu:addItem(MineOSCore.localization.aboutSystem).onTouch = function()
-- ecs.prepareToExit()
-- print(copyright)
-- ecs.waitForTouchOrClick()
-- buffer.draw(true)
-- end
menu:addItem(MineOSCore.localization.updates).onTouch = function()
MineOSCore.safeLaunch("/MineOS/Applications/AppMarket.app/Main.lua", "updateCheck")
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.logout, _G.OSSettings.protectionMethod == "withoutProtection").onTouch = function()
login()
end
menu:addItem(MineOSCore.localization.reboot).onTouch = function()
-- ecs.TV(0)
require("computer").shutdown(true)
dofile("/bin/reboot.lua")
end
menu:addItem(MineOSCore.localization.shutdown).onTouch = function()
-- ecs.TV(0)
require("computer").shutdown()
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.returnToShell).onTouch = function()
workspace:close()
ecs.prepareToExit()
os.exit()
end
menu:show()
end
local item2 = workspace.menu:addItem(MineOSCore.localization.viewTab)
item2.onTouch = function()
local menu = GUI.contextMenu(item2.x, item2.y + 1)
menu:addItem(workspace.iconField.showFileFormat and MineOSCore.localization.hideFileFormat or MineOSCore.localization.showFileFormat).onTouch = function()
workspace.iconField.showFileFormat = not workspace.iconField.showFileFormat
_G.OSSettings.showFileFormat = workspace.iconField.showFileFormat
MineOSCore.saveOSSettings()
workspace.updateFileList()
end
menu:addItem(workspace.iconField.showHiddenFiles and MineOSCore.localization.hideHiddenFiles or MineOSCore.localization.showHiddenFiles).onTouch = function()
workspace.iconField.showHiddenFiles = not workspace.iconField.showHiddenFiles
_G.OSSettings.showHiddenFiles = workspace.iconField.showHiddenFiles
MineOSCore.saveOSSettings()
workspace.updateFileList()
end
menu:addItem(MineOSCore.showApplicationIcons and MineOSCore.localization.hideApplicationIcons or MineOSCore.localization.showApplicationIcons).onTouch = function()
MineOSCore.showApplicationIcons = not MineOSCore.showApplicationIcons
workspace.updateFileList()
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.sortByName).onTouch = function()
_G.OSSettings.sortingMethod = "name"
MineOSCore.saveOSSettings()
workspace.iconField.sortingMethod = _G.OSSettings.sortingMethod
workspace.updateFileList()
end
menu:addItem(MineOSCore.localization.sortByDate).onTouch = function()
_G.OSSettings.sortingMethod = "date"
MineOSCore.saveOSSettings()
workspace.iconField.sortingMethod = _G.OSSettings.sortingMethod
workspace.updateFileList()
end
menu:addItem(MineOSCore.localization.sortByType).onTouch = function()
_G.OSSettings.sortingMethod = "type"
MineOSCore.saveOSSettings()
workspace.iconField.sortingMethod = _G.OSSettings.sortingMethod
workspace.updateFileList()
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.screensaver).onTouch = function()
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.screensaver)
local comboBox = container.layout:addComboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE)
comboBox:addItem(MineOSCore.localization.screensaverDisabled)
for file in fs.list(screensaversPath) do
comboBox:addItem(fs.hideExtension(file))
end
local slider = container.layout:addHorizontalSlider(1, 1, 36, 0xFFDB40, 0xEEEEEE, 0xFFDB80, 0xBBBBBB, 1, 100, _G.OSSettings.screensaverDelay or 20, false, MineOSCore.localization.screensaverDelay .. ": ", "")
workspace:draw()
buffer.draw()
container.panel.onTouch = function()
workspace:deleteChildren(#workspace.children)
if comboBox.currentItem == 1 then
_G.OSSettings.screensaver = nil
else
_G.OSSettings.screensaver, _G.OSSettings.screensaverDelay = comboBox.items[comboBox.currentItem].text, slider.value
end
MineOSCore.saveOSSettings()
workspace:draw()
buffer.draw()
end
end
menu:addItem(MineOSCore.localization.colorScheme).onTouch = function()
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.colorScheme)
local backgroundColorSelector = container.layout:addColorSelector(1, 1, 36, 3, workspace.background.colors.background, MineOSCore.localization.backgroundColor)
local interfaceColorSelector = container.layout:addColorSelector(1, 1, 36, 3, workspace.menu.colors.default.background, MineOSCore.localization.interfaceColor)
backgroundColorSelector.onTouch = function()
_G.OSSettings.backgroundColor, _G.OSSettings.interfaceColor = backgroundColorSelector.color, interfaceColorSelector.color
workspace.background.colors.background, workspace.menu.colors.default.background = _G.OSSettings.backgroundColor, _G.OSSettings.interfaceColor
MineOSCore.saveOSSettings()
workspace:draw()
buffer.draw()
end
interfaceColorSelector.onTouch = backgroundColorSelector.onTouch
workspace:draw()
buffer.draw()
container.panel.onTouch = function()
workspace:deleteChildren(#workspace.children)
workspace:draw()
buffer.draw()
end
end
menu:addItem(MineOSCore.localization.contextMenuRemoveWallpaper, workspace.wallpaper.isHidden).onTouch = function()
_G.OSSettings.wallpaper = nil
MineOSCore.saveOSSettings()
changeWallpaper()
end
menu:show()
end
local item3 = workspace.menu:addItem(MineOSCore.localization.settings)
item3.onTouch = function()
local menu = GUI.contextMenu(item3.x, item3.y + 1)
menu:addItem(MineOSCore.localization.screenResolution).onTouch = function()
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.screenResolution)
local widthTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, tostring(_G.OSSettings.resolution and _G.OSSettings.resolution[1] or 160), "Width", true)
widthTextBox.validator = function(text)
local number = tonumber(text)
if number then return number >= 1 and number <= 160 end
end
local heightTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, tostring(_G.OSSettings.resolution and _G.OSSettings.resolution[2] or 50), "Height", true)
heightTextBox.validator = function(text)
local number = tonumber(text)
if number then return number >= 1 and number <= 50 end
end
container.panel.onTouch = function()
workspace:deleteChildren(#workspace.children)
_G.OSSettings.resolution = {tonumber(widthTextBox.text), tonumber(heightTextBox.text)}
MineOSCore.saveOSSettings()
changeResolution()
end
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.setProtectionMethod).onTouch = function()
setProtectionMethod()
end
menu:show()
end
workspace.updateFileList = function(forceRedraw)
workspace.iconField.fromFile = (currentDesktop - 1) * workspace.iconField.iconCount.total + 1
workspace.iconField:updateFileList()
updateDock()
updateDesktopCounters()
workspace:draw()
buffer.draw(forceRedraw)
end
workspace.onAnyEvent = function(eventData)
if eventData[1] == "scroll" then
if eventData[5] == 1 then
if currentDesktop < countOfDesktops then
currentDesktop = currentDesktop + 1
workspace.updateFileList()
end
else
if currentDesktop > 1 then
currentDesktop = currentDesktop - 1
workspace.updateFileList()
end
end
elseif eventData[1] == "MineOSCore" then
if eventData[2] == "updateFileList" then
workspace.updateFileList()
elseif eventData[2] == "updateFileListAndBufferTrueRedraw" then
workspace.updateFileList(true)
elseif eventData[2] == "changeWorkpath" then
table.insert(workpathHistory, eventData[3])
changeWorkpath(#workpathHistory)
elseif eventData[2] == "updateWallpaper" then
changeWallpaper()
workspace:draw()
buffer.draw()
end
elseif not eventData[1] then
screensaverTimer = screensaverTimer + 0.5
if _G.OSSettings.screensaver and screensaverTimer > _G.OSSettings.screensaverDelay and fs.exists(screensaversPath .. _G.OSSettings.screensaver .. ".lua") then
MineOSCore.safeLaunch(screensaversPath .. _G.OSSettings.screensaver .. ".lua")
screensaverTimer = 0
workspace:draw()
buffer.draw(true)
end
else
screensaverTimer = 0
end
end
end
---------------------------------------------- Сама ОС ------------------------------------------------------------------------
createWorkspace()
changeWorkpath(1)
changeWallpaper()
changeResolution()
login()
windows10()
workspace:handleEvents(0.5)
OS.lua

View File

@ -2269,15 +2269,16 @@ end
-- window:addImage(1, 1, require("image").load("/MineOS/Pictures/Raspberry.pic"))
-- window:addPanel(1, 1, window.width, window.height, 0x000000, 40)
-- local layout = window:addLayout(1, 1, window.width, window.height, 1, 1)
-- layout:setCellPosition(layout:addLabel(1, 1, 30, 1, 0xEEEEEE, "Сохранить как"), 1, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
-- layout:setCellPosition(layout:addInputTextBox(1, 1, 30, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, "Путь", false), 1, 1)
-- local comboBox = layout:setCellPosition(layout:addComboBox(1, 1, 20, 3, 0xEEEEEE, 0x262626, 0x777777, 0xEEEEEE), 1, 1)
-- comboBox:addItem(".PNG")
-- comboBox:addItem(".PSD")
-- comboBox:addItem(".JPG")
-- -- layout:setCellDirection(1, 1, GUI.directions.horizontal)
-- local layout = window:addLayout(1, 1, window.width, window.height, 5, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 1"), 1, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 2"), 2, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 3"), 2, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 4"), 3, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 5"), 3, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 6"), 3, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 7"), 4, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 8"), 4, 1)
-- layout:setCellPosition(layout:addButton(1, 1, 26, 3, 0xEEEEEE, 0x000000, 0xAAAAAA, 0x000000, "Button 9"), 5, 1)
-- window:draw()
-- buffer.draw(true)

View File

@ -143,7 +143,23 @@ function MineOSCore.getAverageMethodExecutionTime(method, countOfTries)
return averageTime
end
---------------------------------------------- MineOS Icons related methods ------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------
function MineOSCore.createShortcut(where, forWhat)
fs.makeDirectory(fs.path(where))
local file = io.open(where, "w")
file:write("return \"" .. forWhat .. "\"")
file:close()
end
function MineOSCore.readShortcut(path)
local success, filename = pcall(loadfile(path))
if success then
return filename
else
error("Failed to read shortcut from path \"" .. fs.path(path) .. "\": file is corrupted")
end
end
function MineOSCore.saveOSSettings()
table.toFile(MineOSCore.paths.OSSettings, _G.OSSettings, true)
@ -216,7 +232,7 @@ function MineOSCore.analyzeIconFormat(iconObject)
end
else
if iconObject.format == ".lnk" then
iconObject.shortcutPath = ecs.readShortcut(iconObject.path)
iconObject.shortcutPath = MineOSCore.readShortcut(iconObject.path)
iconObject.shortcutFormat = fs.extension(iconObject.shortcutPath)
iconObject.shortcutIsDirectory = fs.isDirectory(iconObject.shortcutPath)
iconObject.isShortcut = true
@ -705,13 +721,13 @@ function MineOSCore.iconRightClick(icon, eventData)
while fs.exists(newName) do
newName, repeats = MineOSCore.paths.trash .. clearName .. string.rep("-copy", repeats) .. icon.format, repeats + 1
end
fs.rename(icon.path, newName)
end
computer.pushSignal("MineOSCore", "updateFileList")
elseif action == MineOSCore.localization.contextMenuRename then
ecs.rename(icon.path)
computer.pushSignal("MineOSCore", "updateFileList")
computer.pushSignal("MineOSCore", "rename", icon.path)
elseif action == MineOSCore.localization.contextMenuCreateShortcut then
ecs.createShortCut(fs.path(icon.path) .. "/" .. ecs.hideFileFormat(fs.name(icon.path)) .. ".lnk", icon.path)
MineOSCore.createShortcut(fs.path(icon.path) .. "/" .. fs.hideExtension(fs.name(icon.path)) .. ".lnk", icon.path)
computer.pushSignal("MineOSCore", "updateFileList")
elseif action == MineOSCore.localization.contextMenuArchive then
require("compressor").pack(fs.path(icon.path) .. fs.hideExtension(fs.name(icon.path)) .. ".pkg", icon.path)
@ -725,9 +741,6 @@ function MineOSCore.iconRightClick(icon, eventData)
component.eeprom.set(file:read("*a"))
file:close()
computer.beep(1500, 0.2)
elseif action == MineOSCore.localization.contextMenuCreateApplication then
ecs.newApplicationFromLuaFile(icon.path, fs.path(icon.path) or "")
computer.pushSignal("MineOSCore", "updateFileList")
elseif action == MineOSCore.localization.contextMenuAddToDock then
table.insert(_G.OSSettings.dockShortcuts, {path = icon.path})
MineOSCore.saveOSSettings()
@ -745,11 +758,9 @@ function MineOSCore.emptyZoneClick(eventData, workspace, workpath)
):show()
if action == MineOSCore.localization.contextMenuNewFile then
ecs.newFile(workpath)
computer.pushSignal("MineOSCore", "updateFileListAndBufferTrueRedraw")
computer.pushSignal("MineOSCore", "newFile")
elseif action == MineOSCore.localization.contextMenuNewFolder then
ecs.newFolder(workpath)
computer.pushSignal("MineOSCore", "updateFileList")
computer.pushSignal("MineOSCore", "newFolder")
elseif action == MineOSCore.localization.contextMenuPaste then
ecs.copy(_G.clipboard, workpath)
if _G.clipboardCut then
@ -759,8 +770,7 @@ function MineOSCore.emptyZoneClick(eventData, workspace, workpath)
end
computer.pushSignal("MineOSCore", "updateFileList")
elseif action == MineOSCore.localization.contextMenuNewApplication then
ecs.newApplication(workpath)
computer.pushSignal("MineOSCore", "updateFileList")
computer.pushSignal("MineOSCore", "newApplication")
end
end
@ -796,7 +806,7 @@ function MineOSCore.showPropertiesWindow(x, y, width, iconObject)
buffer.draw()
if iconObject.isDirectory then
fileSizeLabel.text = string.format("%.2f", MineOSCore.getFolderSize(iconObject.path) / 1024) .. " KB"
fileSizeLabel.text = string.format("%.2f", fs.directorySize(iconObject.path) / 1024) .. " KB"
window:draw()
buffer.draw()
end
@ -806,6 +816,84 @@ end
-----------------------------------------------------------------------------------------------------------------------------------
local function createUniversalContainer(parentWindow, path, text, title, placeholder)
local container = GUI.addUniversalContainer(parentWindow, title)
container.inputTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, text, placeholder, false)
container.label = container.layout:addLabel(1, 1, 36, 3, 0xFF4940, " "):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
parentWindow:draw()
buffer.draw()
return container
end
local function checkFileToExists(container, path)
if fs.exists(path) then
container.label.text = MineOSCore.localization.fileAlreadyExists
container.parent:draw()
buffer.draw()
else
container.parent:deleteChildren(#container.parent.children, #container.parent.children)
fs.makeDirectory(fs.path(path))
return true
end
end
function MineOSCore.newApplication(parentWindow, path)
local container = createUniversalContainer(parentWindow, path, nil, MineOSCore.localization.contextMenuNewApplication, MineOSCore.localization.applicationName)
container.inputTextBox.onInputFinished = function()
local finalPath = path .. container.inputTextBox.text .. ".app/"
if checkFileToExists(container, finalPath) then
fs.makeDirectory(finalPath .. "/Resources/")
fs.copy(MineOSCore.paths.icons .. "SampleIcon.pic", finalPath .. "/Resources/Icon.pic")
local file = io.open(finalPath .. "Main.lua", "w")
file:write("require('GUI').error('Hello world')")
file:close()
computer.pushSignal("MineOSCore", "updateFileList")
end
end
end
function MineOSCore.newFile(parentWindow, path)
local container = createUniversalContainer(parentWindow, path, nil, MineOSCore.localization.contextMenuNewFile, MineOSCore.localization.fileName)
container.inputTextBox.onInputFinished = function()
if checkFileToExists(container, path .. container.inputTextBox.text) then
local file = io.open(path .. container.inputTextBox.text, "w")
file:close()
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "/MineCode IDE.app/Main.lua", "open", path .. container.inputTextBox.text)
computer.pushSignal("MineOSCore", "updateFileList")
end
end
end
function MineOSCore.newFolder(parentWindow, path)
local container = createUniversalContainer(parentWindow, path, nil, MineOSCore.localization.contextMenuNewFolder, MineOSCore.localization.folderName)
container.inputTextBox.onInputFinished = function()
if checkFileToExists(container, path .. container.inputTextBox.text) then
fs.makeDirectory(path .. container.inputTextBox.text)
computer.pushSignal("MineOSCore", "updateFileList")
end
end
end
function MineOSCore.rename(parentWindow, path)
local container = createUniversalContainer(parentWindow, path, fs.name(path), MineOSCore.localization.contextMenuRename, MineOSCore.localization.newName)
container.inputTextBox.onInputFinished = function()
if checkFileToExists(container, fs.path(path) .. container.inputTextBox.text) then
fs.rename(path, fs.path(path) .. container.inputTextBox.text)
computer.pushSignal("MineOSCore", "updateFileList")
end
end
end
-----------------------------------------------------------------------------------------------------------------------------------
MineOSCore.init()
-----------------------------------------------------------------------------------------------------------------------------------

View File

@ -187,58 +187,60 @@ function filesystem.sortedList(path, sortingMethod, showHiddenFiles)
table.insert(fileList, file)
end
if sortingMethod == "type" then
local extension
for i = 1, #fileList do
extension = filesystem.extension(fileList[i]) or "Script"
if filesystem.isDirectory(path .. fileList[i]) and extension ~= ".app" then
extension = ".01_Folder"
end
fileList[i] = {fileList[i], extension}
end
table.sort(fileList, function(a, b) return a[2] < b[2] end)
local currentExtensionList, currentExtension = {}, fileList[1][2]
for i = 1, #fileList do
if currentExtension == fileList[i][2] then
table.insert(currentExtensionList, fileList[i][1])
else
table.sort(currentExtensionList, function(a, b) return a < b end)
for j = 1, #currentExtensionList do
table.insert(sortedFileList, currentExtensionList[j])
if #fileList > 0 then
if sortingMethod == "type" then
local extension
for i = 1, #fileList do
extension = filesystem.extension(fileList[i]) or "Script"
if filesystem.isDirectory(path .. fileList[i]) and extension ~= ".app" then
extension = ".01_Folder"
end
currentExtensionList, currentExtension = {fileList[i][1]}, fileList[i][2]
fileList[i] = {fileList[i], extension}
end
end
table.sort(currentExtensionList, function(a, b) return a < b end)
for j = 1, #currentExtensionList do
table.insert(sortedFileList, currentExtensionList[j])
end
elseif sortingMethod == "name" then
sortedFileList = fileList
table.sort(sortedFileList, function(a, b) return a < b end)
elseif sortingMethod == "date" then
for i = 1, #fileList do
fileList[i] = {fileList[i], filesystem.lastModified(path .. fileList[i])}
end
table.sort(fileList, function(a, b) return a[2] > b[2] end)
table.sort(fileList, function(a, b) return a[2] < b[2] end)
for i = 1, #fileList do
table.insert(sortedFileList, fileList[i][1])
end
else
error("Unknown sorting method: " .. tostring(sortingMethod))
end
local currentExtensionList, currentExtension = {}, fileList[1][2]
for i = 1, #fileList do
if currentExtension == fileList[i][2] then
table.insert(currentExtensionList, fileList[i][1])
else
table.sort(currentExtensionList, function(a, b) return a < b end)
for j = 1, #currentExtensionList do
table.insert(sortedFileList, currentExtensionList[j])
end
currentExtensionList, currentExtension = {fileList[i][1]}, fileList[i][2]
end
end
table.sort(currentExtensionList, function(a, b) return a < b end)
for j = 1, #currentExtensionList do
table.insert(sortedFileList, currentExtensionList[j])
end
elseif sortingMethod == "name" then
sortedFileList = fileList
table.sort(sortedFileList, function(a, b) return a < b end)
elseif sortingMethod == "date" then
for i = 1, #fileList do
fileList[i] = {fileList[i], filesystem.lastModified(path .. fileList[i])}
end
local i = 1
while i <= #sortedFileList do
if not showHiddenFiles and filesystem.isFileHidden(sortedFileList[i]) then
table.remove(sortedFileList, i)
table.sort(fileList, function(a, b) return a[2] > b[2] end)
for i = 1, #fileList do
table.insert(sortedFileList, fileList[i][1])
end
else
i = i + 1
error("Unknown sorting method: " .. tostring(sortingMethod))
end
local i = 1
while i <= #sortedFileList do
if not showHiddenFiles and filesystem.isFileHidden(sortedFileList[i]) then
table.remove(sortedFileList, i)
else
i = i + 1
end
end
end