mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-06 11:12:40 +01:00
Хуйня пизда вагина
This commit is contained in:
parent
f8a58899d2
commit
2d5c33fa6d
@ -5,7 +5,7 @@
|
||||
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/About/",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=3.58,
|
||||
version=3.59,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Pictures/MoonTouch.pic",
|
||||
@ -198,7 +198,7 @@
|
||||
path="/lib/MineOSCore.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
|
||||
type="Library",
|
||||
version=1.61,
|
||||
version=1.62,
|
||||
},
|
||||
{
|
||||
path="/lib/advancedLua.lua",
|
||||
@ -231,7 +231,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/color.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.01,
|
||||
version=1.02,
|
||||
},
|
||||
{
|
||||
path="/lib/ImageFormatModules/OCIF.lua",
|
||||
@ -245,7 +245,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/image.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.25,
|
||||
version=1.26,
|
||||
},
|
||||
{
|
||||
path="/lib/serialization.lua",
|
||||
@ -643,7 +643,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/FlappyBird/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.11,
|
||||
version=1.12,
|
||||
resources={
|
||||
{
|
||||
path="/Flappy.pic",
|
||||
|
||||
@ -271,7 +271,7 @@ while true do
|
||||
end
|
||||
|
||||
if not somethingHappend then
|
||||
if yBird + bird.height - 1 < buffer.screen.height then
|
||||
if yBird + image.getHeight(bird) - 1 < buffer.screen.height then
|
||||
yBird = yBird + config.birdFlyDownSpeed
|
||||
else
|
||||
scores[currentUser] = math.max(scores[currentUser] or 0, currentScore)
|
||||
|
||||
@ -56,8 +56,8 @@
|
||||
sortByType = "Sort by type",
|
||||
sortByName = "Sort by name",
|
||||
sortByDate = "Sort by date",
|
||||
showFileFormat = "Show file format",
|
||||
hideFileFormat = "Hide file format",
|
||||
showExtension = "Show file extension",
|
||||
hideExtension = "Hide file extension",
|
||||
showHiddenFiles = "Show hidden files",
|
||||
hideHiddenFiles = "Don't show hidden files",
|
||||
showApplicationIcons = "Show application icons",
|
||||
|
||||
@ -56,8 +56,8 @@
|
||||
sortByType = "Сортировать по типу",
|
||||
sortByName = "Сортировать по имени",
|
||||
sortByDate = "Сортировать по дате",
|
||||
showFileFormat = "Показывать формат файлов",
|
||||
hideFileFormat = "Скрывать формат файлов",
|
||||
showExtension = "Показывать расширение файлов",
|
||||
hideExtension = "Скрывать расширение файлов",
|
||||
showHiddenFiles = "Показывать скрытые файлы",
|
||||
hideHiddenFiles = "Не показывать скрытые файлы",
|
||||
showApplicationIcons = "Показывать иконки приложений",
|
||||
|
||||
@ -20,7 +20,7 @@ copyright = nil
|
||||
|
||||
---------------------------------------------- Адаптивная загрузка библиотек ------------------------------------------------------------------------
|
||||
|
||||
package.loaded.MineOSCore = nil
|
||||
-- package.loaded.MineOSCore = nil
|
||||
|
||||
local component = require("component")
|
||||
local unicode = require("unicode")
|
||||
@ -337,7 +337,7 @@ local function updateDock()
|
||||
|
||||
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)
|
||||
local iconObject = MineOSCore.createIcon(xPos, 1, _G.OSSettings.dockShortcuts[iconIndex].path, 0x262626, _G.OSSettings.showExtension)
|
||||
|
||||
iconObject.onRightClick = function(iconObject, eventData)
|
||||
local menu = GUI.contextMenu(eventData[3], eventData[4])
|
||||
@ -368,7 +368,7 @@ local function updateDock()
|
||||
xPos = xPos + MineOSCore.iconWidth + sizes.xSpaceBetweenIcons
|
||||
end
|
||||
|
||||
local iconObject = MineOSCore.createIconObject(xPos, 1, MineOSCore.paths.trash, 0x262626, _G.OSSettings.showFileFormat)
|
||||
local iconObject = MineOSCore.createIcon(xPos, 1, MineOSCore.paths.trash, 0x262626, _G.OSSettings.showExtension)
|
||||
iconObject.iconImage.image = MineOSCore.icons.trash
|
||||
iconObject.onRightClick = function(iconObject, eventData)
|
||||
local menu = GUI.contextMenu(eventData[3], eventData[4])
|
||||
@ -443,7 +443,7 @@ local function createWorkspace()
|
||||
sizes.xSpaceBetweenIcons,
|
||||
sizes.ySpaceBetweenIcons,
|
||||
0xFFFFFF,
|
||||
_G.OSSettings.showFileFormat == nil and true or _G.OSSettings.showFileFormat,
|
||||
_G.OSSettings.showExtension == nil and true or _G.OSSettings.showExtension,
|
||||
_G.OSSettings.showHiddenFiles == nil and true or _G.OSSettings.showHiddenFiles,
|
||||
(_G.OSSettings.sortingMethod or "type"),
|
||||
"/"
|
||||
@ -491,9 +491,9 @@ local function createWorkspace()
|
||||
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
|
||||
menu:addItem(workspace.iconField.showExtension and MineOSCore.localization.hideExtension or MineOSCore.localization.showExtension).onTouch = function()
|
||||
workspace.iconField.showExtension = not workspace.iconField.showExtension
|
||||
_G.OSSettings.showExtension = workspace.iconField.showExtension
|
||||
MineOSCore.saveOSSettings()
|
||||
workspace.updateFileList()
|
||||
end
|
||||
|
||||
@ -13,10 +13,11 @@ local fs = require("filesystem")
|
||||
local unicode = require("unicode")
|
||||
local keyboard = require("keyboard")
|
||||
|
||||
---------------------------------------------- Core constants ------------------------------------------------------------------------
|
||||
local gpu = component.gpu
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local MineOSCore = {}
|
||||
local gpu = component.gpu
|
||||
|
||||
MineOSCore.showApplicationIcons = true
|
||||
MineOSCore.iconWidth = 12
|
||||
@ -105,8 +106,7 @@ end
|
||||
|
||||
]]
|
||||
|
||||
---------------------------------------------- Current sсript processing methods ------------------------------------------------------------------------
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------
|
||||
function MineOSCore.getCurrentScriptDirectory()
|
||||
return fs.path(getCurrentScript())
|
||||
end
|
||||
@ -128,6 +128,8 @@ function MineOSCore.getCurrentApplicationLocalization()
|
||||
return MineOSCore.getLocalization(MineOSCore.getCurrentApplicationResourcesDirectory() .. "Localization/")
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function MineOSCore.getMethodExecutionTime(method)
|
||||
local oldOSClock = os.clock()
|
||||
method()
|
||||
@ -191,6 +193,8 @@ function MineOSCore.loadStandartIcons()
|
||||
MineOSCore.loadIcon("trash", MineOSCore.paths.icons .. "Trash.pic")
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function MineOSCore.init()
|
||||
fs.makeDirectory(MineOSCore.paths.trash)
|
||||
MineOSCore.loadOSSettings()
|
||||
@ -203,100 +207,110 @@ function MineOSCore.waitForPressingAnyKey()
|
||||
print(MineOSCore.localization.pressAnyKeyToContinue)
|
||||
while true do
|
||||
local eventType = event.pull()
|
||||
if eventType == "key_down" or eventType == "touch" then break end
|
||||
if eventType == "key_down" or eventType == "touch" then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function MineOSCore.analyzeIconFormat(iconObject)
|
||||
if iconObject.isDirectory then
|
||||
if iconObject.format == ".app" then
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function launchApp(icon)
|
||||
computer.pushSignal("MineOSCore", "applicationHelp", icon.path)
|
||||
end
|
||||
|
||||
local function launchDirectory(icon)
|
||||
computer.pushSignal("MineOSCore", "changeWorkpath", icon.path)
|
||||
end
|
||||
|
||||
local function launchEditor(icon)
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "/MineCode IDE.app/Main.lua", "open", icon.path)
|
||||
end
|
||||
|
||||
local function launchLua(icon)
|
||||
ecs.prepareToExit()
|
||||
if MineOSCore.safeLaunch(icon.path) then
|
||||
MineOSCore.waitForPressingAnyKey()
|
||||
end
|
||||
end
|
||||
|
||||
local function launchImage(icon)
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "Photoshop.app/Main.lua", "open", icon.path)
|
||||
end
|
||||
|
||||
local function launchPackage(icon)
|
||||
require("compressor").unpack(icon.path, fs.path(icon.path))
|
||||
end
|
||||
|
||||
local function launch3DPrint(icon)
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "3DPrint.app/Main.lua", "open", icon.path)
|
||||
end
|
||||
|
||||
local function launchCorrupted(icon)
|
||||
GUI.error("Application is corrupted")
|
||||
end
|
||||
|
||||
function MineOSCore.analyzeIconExtension(icon)
|
||||
if icon.isDirectory then
|
||||
if icon.extension == ".app" then
|
||||
if MineOSCore.showApplicationIcons then
|
||||
if fs.exists(iconObject.path .. "/Resources/Icon.pic") then
|
||||
iconObject.iconImage.image = image.load(iconObject.path .. "/Resources/Icon.pic")
|
||||
else
|
||||
iconObject.iconImage.image = MineOSCore.icons.fileNotExists
|
||||
end
|
||||
icon.iconImage.image = image.load(icon.path .. "/Resources/Icon.pic")
|
||||
else
|
||||
iconObject.iconImage.image = MineOSCore.icons.application
|
||||
icon.iconImage.image = MineOSCore.icons.application
|
||||
end
|
||||
|
||||
iconObject.launch = function()
|
||||
computer.pushSignal("MineOSCore", "applicationHelp", iconObject.path)
|
||||
end
|
||||
icon.launch = launchApp
|
||||
else
|
||||
iconObject.iconImage.image = MineOSCore.icons.folder
|
||||
iconObject.launch = function()
|
||||
computer.pushSignal("MineOSCore", "changeWorkpath", iconObject.path)
|
||||
end
|
||||
icon.iconImage.image = MineOSCore.icons.folder
|
||||
icon.launch = launchDirectory
|
||||
end
|
||||
else
|
||||
if iconObject.format == ".lnk" then
|
||||
iconObject.shortcutPath = MineOSCore.readShortcut(iconObject.path)
|
||||
iconObject.shortcutFormat = fs.extension(iconObject.shortcutPath)
|
||||
iconObject.shortcutIsDirectory = fs.isDirectory(iconObject.shortcutPath)
|
||||
iconObject.isShortcut = true
|
||||
if icon.extension == ".lnk" then
|
||||
icon.shortcutPath = MineOSCore.readShortcut(icon.path)
|
||||
icon.shortcutExtension = fs.extension(icon.shortcutPath)
|
||||
icon.shortcutIsDirectory = fs.isDirectory(icon.shortcutPath)
|
||||
icon.isShortcut = true
|
||||
|
||||
local shortcutIconObject = MineOSCore.analyzeIconFormat({
|
||||
path = iconObject.shortcutPath,
|
||||
format = iconObject.shortcutFormat,
|
||||
isDirectory = iconObject.shortcutIsDirectory,
|
||||
iconImage = iconObject.iconImage
|
||||
local shortcutIcon = MineOSCore.analyzeIconExtension({
|
||||
path = icon.shortcutPath,
|
||||
extension = icon.shortcutExtension,
|
||||
isDirectory = icon.shortcutIsDirectory,
|
||||
iconImage = icon.iconImage
|
||||
})
|
||||
|
||||
iconObject.iconImage.image = shortcutIconObject.iconImage.image
|
||||
iconObject.launch = shortcutIconObject.launch
|
||||
icon.path = shortcutIcon.path
|
||||
icon.iconImage.image = shortcutIcon.iconImage.image
|
||||
icon.launch = shortcutIcon.launch
|
||||
|
||||
shortcutIconObject = nil
|
||||
elseif iconObject.format == ".cfg" or iconObject.format == ".config" then
|
||||
iconObject.iconImage.image = MineOSCore.icons.config
|
||||
iconObject.launch = function()
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "/MineCode IDE.app/Main.lua", "open", iconObject.path)
|
||||
end
|
||||
elseif iconObject.format == ".txt" or iconObject.format == ".rtf" then
|
||||
iconObject.iconImage.image = MineOSCore.icons.text
|
||||
iconObject.launch = function()
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "/MineCode IDE.app/Main.lua", "open", iconObject.path)
|
||||
end
|
||||
elseif iconObject.format == ".lua" then
|
||||
iconObject.iconImage.image = MineOSCore.icons.lua
|
||||
iconObject.launch = function()
|
||||
ecs.prepareToExit()
|
||||
if MineOSCore.safeLaunch(iconObject.path) then
|
||||
MineOSCore.waitForPressingAnyKey()
|
||||
end
|
||||
end
|
||||
elseif iconObject.format == ".pic" or iconObject.format == ".png" then
|
||||
iconObject.iconImage.image = MineOSCore.icons.image
|
||||
iconObject.launch = function()
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "Photoshop.app/Main.lua", "open", iconObject.path)
|
||||
end
|
||||
elseif iconObject.format == ".pkg" then
|
||||
iconObject.iconImage.image = MineOSCore.icons.archive
|
||||
iconObject.launch = function()
|
||||
require("compressor").unpack(iconObject.path, fs.path(iconObject.path))
|
||||
end
|
||||
elseif iconObject.format == ".3dm" then
|
||||
iconObject.iconImage.image = MineOSCore.icons.model3D
|
||||
iconObject.launch = function()
|
||||
MineOSCore.safeLaunch(MineOSCore.paths.applications .. "3DPrint.app/Main.lua", "open", iconObject.path)
|
||||
end
|
||||
elseif not fs.exists(iconObject.path) then
|
||||
iconObject.iconImage.image = MineOSCore.icons.fileNotExists
|
||||
iconObject.launch = function()
|
||||
GUI.error("Application is corrupted")
|
||||
end
|
||||
shortcutIcon = nil
|
||||
elseif icon.extension == ".cfg" or icon.extension == ".config" then
|
||||
icon.iconImage.image = MineOSCore.icons.config
|
||||
icon.launch = launchEditor
|
||||
elseif icon.extension == ".txt" or icon.extension == ".rtf" then
|
||||
icon.iconImage.image = MineOSCore.icons.text
|
||||
icon.launch = launchEditor
|
||||
elseif icon.extension == ".lua" then
|
||||
icon.iconImage.image = MineOSCore.icons.lua
|
||||
icon.launch = launchLua
|
||||
elseif icon.extension == ".pic" or icon.extension == ".png" then
|
||||
icon.iconImage.image = MineOSCore.icons.image
|
||||
icon.launch = launchImage
|
||||
elseif icon.extension == ".pkg" then
|
||||
icon.iconImage.image = MineOSCore.icons.archive
|
||||
icon.launch = launchPackage
|
||||
elseif icon.extension == ".3dm" then
|
||||
icon.iconImage.image = MineOSCore.icons.model3D
|
||||
icon.launch = launch3DPrint
|
||||
elseif not fs.exists(icon.path) then
|
||||
icon.iconImage.image = MineOSCore.icons.fileNotExists
|
||||
icon.launch = launchCorrupted
|
||||
else
|
||||
iconObject.iconImage.image = MineOSCore.icons.script
|
||||
iconObject.launch = function()
|
||||
ecs.prepareToExit()
|
||||
if MineOSCore.safeLaunch(iconObject.path) then
|
||||
MineOSCore.waitForPressingAnyKey()
|
||||
end
|
||||
end
|
||||
icon.iconImage.image = MineOSCore.icons.script
|
||||
icon.launch = launchLua
|
||||
end
|
||||
end
|
||||
|
||||
return iconObject
|
||||
return icon
|
||||
end
|
||||
|
||||
function MineOSCore.getParametersForDrawingIcons(fieldWidth, fieldHeight, xSpaceBetweenIcons, ySpaceBetweenIcons)
|
||||
@ -305,59 +319,59 @@ function MineOSCore.getParametersForDrawingIcons(fieldWidth, fieldHeight, xSpace
|
||||
return xCountOfIcons, yCountOfIcons, totalCountOfIcons
|
||||
end
|
||||
|
||||
function MineOSCore.createIconObject(x, y, path, textColor, showFileFormat)
|
||||
local iconObject = GUI.container(x, y, MineOSCore.iconWidth, MineOSCore.iconHeight)
|
||||
function MineOSCore.createIcon(x, y, path, textColor, showExtension)
|
||||
local icon = GUI.container(x, y, MineOSCore.iconWidth, MineOSCore.iconHeight)
|
||||
|
||||
iconObject.path = path
|
||||
iconObject.size = fs.size(iconObject.path)
|
||||
iconObject.isDirectory = fs.isDirectory(iconObject.path)
|
||||
iconObject.format = fs.extension(iconObject.path)
|
||||
iconObject.showFormat = showFileFormat
|
||||
iconObject.isShortcut = false
|
||||
iconObject.isSelected = false
|
||||
icon.path = path
|
||||
icon.size = fs.size(icon.path)
|
||||
icon.isDirectory = fs.isDirectory(icon.path)
|
||||
icon.extension = fs.extension(icon.path)
|
||||
icon.showExtension = showExtension
|
||||
icon.isShortcut = false
|
||||
icon.isSelected = false
|
||||
|
||||
iconObject.iconImage = iconObject:addImage(3, 1, {8, 4})
|
||||
iconObject.textLabel = iconObject:addLabel(1, MineOSCore.iconHeight, MineOSCore.iconWidth, 1, textColor, fs.name(iconObject.path)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
icon.iconImage = icon:addImage(3, 1, {8, 4})
|
||||
icon.textLabel = icon:addLabel(1, MineOSCore.iconHeight, MineOSCore.iconWidth, 1, textColor, fs.name(icon.path)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
|
||||
local oldDraw = iconObject.draw
|
||||
iconObject.draw = function(iconObject)
|
||||
if iconObject.isSelected then buffer.square(iconObject.x, iconObject.y, iconObject.width, iconObject.height, 0xFFFFFF, 0x000000, " ", 50) end
|
||||
if iconObject.showFormat then
|
||||
iconObject.textLabel.text = string.limit(fs.name(iconObject.path), iconObject.textLabel.width, "center")
|
||||
local oldDraw = icon.draw
|
||||
icon.draw = function(icon)
|
||||
if icon.isSelected then buffer.square(icon.x, icon.y, icon.width, icon.height, 0xFFFFFF, 0x000000, " ", 50) end
|
||||
if icon.showExtension then
|
||||
icon.textLabel.text = string.limit(fs.name(icon.path), icon.textLabel.width, "center")
|
||||
else
|
||||
iconObject.textLabel.text = string.limit(fs.hideExtension(fs.name(iconObject.path)), iconObject.textLabel.width, "center")
|
||||
icon.textLabel.text = string.limit(fs.hideExtension(fs.name(icon.path)), icon.textLabel.width, "center")
|
||||
end
|
||||
oldDraw(iconObject)
|
||||
if iconObject.isShortcut then buffer.set(iconObject.iconImage.x + iconObject.iconImage.width - 1, iconObject.iconImage.y + iconObject.iconImage.height - 1, 0xFFFFFF, 0x000000, "<") end
|
||||
oldDraw(icon)
|
||||
if icon.isShortcut then buffer.set(icon.iconImage.x + icon.iconImage.width - 1, icon.iconImage.y + icon.iconImage.height - 1, 0xFFFFFF, 0x000000, "<") end
|
||||
end
|
||||
|
||||
-- Поддержка изменяемых извне функций правого и левого кликов
|
||||
iconObject.onLeftClick = MineOSCore.iconLeftClick
|
||||
iconObject.onRightClick = MineOSCore.iconRightClick
|
||||
icon.onLeftClick = MineOSCore.iconLeftClick
|
||||
icon.onRightClick = MineOSCore.iconRightClick
|
||||
|
||||
-- Обработка клика непосредственно на иконку
|
||||
iconObject.iconImage.onTouch = function(eventData)
|
||||
iconObject.isSelected = true
|
||||
local firstParent = iconObject:getFirstParent()
|
||||
icon.iconImage.onTouch = function(eventData)
|
||||
icon.isSelected = true
|
||||
local firstParent = icon:getFirstParent()
|
||||
firstParent:draw()
|
||||
buffer.draw()
|
||||
|
||||
if eventData[5] == 0 then
|
||||
os.sleep(MineOSCore.iconClickDelay)
|
||||
iconObject.onLeftClick(iconObject, eventData)
|
||||
icon.onLeftClick(icon, eventData)
|
||||
else
|
||||
iconObject.onRightClick(iconObject, eventData)
|
||||
icon.onRightClick(icon, eventData)
|
||||
end
|
||||
|
||||
iconObject.isSelected = false
|
||||
icon.isSelected = false
|
||||
firstParent:draw()
|
||||
buffer.draw()
|
||||
end
|
||||
|
||||
-- Онализ формата и прочего говна иконки для последующего получения изображения иконки и функции-лаунчера
|
||||
MineOSCore.analyzeIconFormat(iconObject)
|
||||
MineOSCore.analyzeIconExtension(icon)
|
||||
|
||||
return iconObject
|
||||
return icon
|
||||
end
|
||||
|
||||
local function updateIconFieldFileList(iconField)
|
||||
@ -369,8 +383,8 @@ local function updateIconFieldFileList(iconField)
|
||||
if not iconField.fileList[i] then break end
|
||||
|
||||
iconField:addChild(
|
||||
MineOSCore.createIconObject(
|
||||
xPos, yPos, iconField.workpath .. iconField.fileList[i], iconField.colors.iconText, iconField.showFileFormat
|
||||
MineOSCore.createIcon(
|
||||
xPos, yPos, iconField.workpath .. iconField.fileList[i], iconField.colors.iconText, iconField.showExtension
|
||||
),
|
||||
GUI.objectTypes.container
|
||||
)
|
||||
@ -385,7 +399,7 @@ local function updateIconFieldFileList(iconField)
|
||||
return iconField
|
||||
end
|
||||
|
||||
function MineOSCore.createIconField(x, y, width, height, xCountOfIcons, yCountOfIcons, totalCountOfIcons, xSpaceBetweenIcons, ySpaceBetweenIcons, iconTextColor, showFileFormat, showHiddenFiles, sortingMethod, workpathworkpath)
|
||||
function MineOSCore.createIconField(x, y, width, height, xCountOfIcons, yCountOfIcons, totalCountOfIcons, xSpaceBetweenIcons, ySpaceBetweenIcons, iconTextColor, showExtension, showHiddenFiles, sortingMethod, workpathworkpath)
|
||||
local iconField = GUI.container(x, y, width, height)
|
||||
|
||||
iconField.colors = {iconText = iconTextColor}
|
||||
@ -395,7 +409,7 @@ function MineOSCore.createIconField(x, y, width, height, xCountOfIcons, yCountOf
|
||||
iconField.iconCount.width, iconField.iconCount.height, iconField.iconCount.total = xCountOfIcons, yCountOfIcons, totalCountOfIcons
|
||||
|
||||
iconField.workpath = workpath
|
||||
iconField.showFileFormat = showFileFormat
|
||||
iconField.showExtension = showExtension
|
||||
iconField.showHiddenFiles = showHiddenFiles
|
||||
iconField.sortingMethod = sortingMethod
|
||||
iconField.fileList = {}
|
||||
@ -588,8 +602,8 @@ end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function MineOSCore.iconLeftClick(iconObject, eventData)
|
||||
iconObject.launch()
|
||||
function MineOSCore.iconLeftClick(icon, eventData)
|
||||
icon:launch()
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
@ -597,14 +611,14 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
local action
|
||||
-- Разные контекстные меню
|
||||
if icon.isDirectory then
|
||||
if icon.format == ".app" then
|
||||
if icon.extension == ".app" then
|
||||
action = GUI.contextMenu(eventData[3], eventData[4],
|
||||
{MineOSCore.localization.contextMenuShowPackageContent},
|
||||
"-",
|
||||
{MineOSCore.localization.contextMenuCut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.format == ".lnk"},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.extension == ".lnk"},
|
||||
"-",
|
||||
{MineOSCore.localization.contextMenuArchive},
|
||||
{MineOSCore.localization.contextMenuAddToDock},
|
||||
@ -617,7 +631,7 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
{MineOSCore.localization.contextMenuCut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.format == ".lnk"},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.extension == ".lnk"},
|
||||
"-",
|
||||
{MineOSCore.localization.contextMenuArchive},
|
||||
{MineOSCore.localization.contextMenuAddToDock},
|
||||
@ -640,14 +654,14 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
{MineOSCore.localization.contextMenuProperties},
|
||||
{MineOSCore.localization.contextMenuDelete}
|
||||
):show()
|
||||
elseif icon.format == ".pic" then
|
||||
elseif icon.extension == ".pic" then
|
||||
action = GUI.contextMenu(eventData[3], eventData[4],
|
||||
{MineOSCore.localization.contextMenuSetAsWallpaper},
|
||||
"-",
|
||||
{MineOSCore.localization.contextMenuCut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.format == ".lnk"},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.extension == ".lnk"},
|
||||
"-",
|
||||
-- {MineOSCore.localization.contextMenuArchive},
|
||||
{MineOSCore.localization.contextMenuAddToDock},
|
||||
@ -655,7 +669,7 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
{MineOSCore.localization.contextMenuProperties},
|
||||
{MineOSCore.localization.contextMenuDelete}
|
||||
):show()
|
||||
elseif icon.format == ".lua" then
|
||||
elseif icon.extension == ".lua" then
|
||||
action = GUI.contextMenu(eventData[3], eventData[4],
|
||||
{MineOSCore.localization.contextMenuEdit},
|
||||
{MineOSCore.localization.contextMenuFlashEEPROM, (not component.isAvailable("eeprom") or icon.size > 4096)},
|
||||
@ -663,7 +677,7 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
{MineOSCore.localization.contextMenuCut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.format == ".lnk"},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.extension == ".lnk"},
|
||||
-- "-",
|
||||
-- {MineOSCore.localization.contextMenuUploadToPastebin, true},
|
||||
"-",
|
||||
@ -680,7 +694,7 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
{MineOSCore.localization.contextMenuCut},
|
||||
{MineOSCore.localization.contextMenuCopy},
|
||||
{MineOSCore.localization.contextMenuRename},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.format == ".lnk"},
|
||||
{MineOSCore.localization.contextMenuCreateShortcut, icon.extension == ".lnk"},
|
||||
"-",
|
||||
-- {MineOSCore.localization.contextMenuArchive},
|
||||
{MineOSCore.localization.contextMenuAddToDock},
|
||||
@ -718,7 +732,7 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
local clearName = fs.hideExtension(fs.name(icon.path))
|
||||
local repeats = 1
|
||||
while fs.exists(newName) do
|
||||
newName, repeats = MineOSCore.paths.trash .. clearName .. string.rep("-copy", repeats) .. icon.format, repeats + 1
|
||||
newName, repeats = MineOSCore.paths.trash .. clearName .. string.rep("-copy", repeats) .. icon.extension, repeats + 1
|
||||
end
|
||||
fs.rename(icon.path, newName)
|
||||
end
|
||||
@ -778,22 +792,22 @@ local function addKeyAndValue(window, x, y, key, value)
|
||||
return window:addLabel(x, y, window.width, 1, 0x555555, value)
|
||||
end
|
||||
|
||||
function MineOSCore.showPropertiesWindow(x, y, width, iconObject)
|
||||
function MineOSCore.showPropertiesWindow(x, y, width, icon)
|
||||
local window = GUI.window(x, y, width, 1)
|
||||
local backgroundPanel = window:addPanel(1, 2, window.width, 1, 0xDDDDDD)
|
||||
window:addPanel(1, 1, window.width, 1, 0xEEEEEE)
|
||||
window:addLabel(1, 1, window.width, 1, 0x333333, MineOSCore.localization.contextMenuProperties):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
window:addButton(2, 1, 1, 1, nil, 0xFF4940, nil, 0x992400, "●").onTouch = function() window:close() end
|
||||
|
||||
window:addImage(3, 3, iconObject.iconImage.image)
|
||||
window:addImage(3, 3, icon.iconImage.image)
|
||||
|
||||
local y = 3
|
||||
addKeyAndValue(window, 13, y, MineOSCore.localization.type, iconObject.format and iconObject.format or (iconObject.isDirectory and MineOSCore.localization.folder or MineOSCore.localization.unknown)); y = y + 1
|
||||
local fileSizeLabel = addKeyAndValue(window, 13, y, MineOSCore.localization.size, iconObject.isDirectory and MineOSCore.localization.calculatingSize or string.format("%.2f", iconObject.size / 1024) .. " KB"); y = y + 1
|
||||
addKeyAndValue(window, 13, y, MineOSCore.localization.date, os.date("%d.%m.%y, %H:%M", fs.lastModified(iconObject.path))); y = y + 1
|
||||
addKeyAndValue(window, 13, y, MineOSCore.localization.type, icon.extension and icon.extension or (icon.isDirectory and MineOSCore.localization.folder or MineOSCore.localization.unknown)); y = y + 1
|
||||
local fileSizeLabel = addKeyAndValue(window, 13, y, MineOSCore.localization.size, icon.isDirectory and MineOSCore.localization.calculatingSize or string.format("%.2f", icon.size / 1024) .. " KB"); y = y + 1
|
||||
addKeyAndValue(window, 13, y, MineOSCore.localization.date, os.date("%d.%m.%y, %H:%M", fs.lastModified(icon.path))); y = y + 1
|
||||
addKeyAndValue(window, 13, y, MineOSCore.localization.path, " ")
|
||||
|
||||
local lines = string.wrap(iconObject.path, window.width - 19)
|
||||
local lines = string.wrap(icon.path, window.width - 19)
|
||||
local textBox = window:addTextBox(19, y, window.width - 19, #lines, nil, 0x555555, lines, 1)
|
||||
window.height = textBox.y + textBox.height
|
||||
backgroundPanel.height = window.height - 1
|
||||
@ -804,8 +818,8 @@ function MineOSCore.showPropertiesWindow(x, y, width, iconObject)
|
||||
window:draw()
|
||||
buffer.draw()
|
||||
|
||||
if iconObject.isDirectory then
|
||||
fileSizeLabel.text = string.format("%.2f", fs.directorySize(iconObject.path) / 1024) .. " KB"
|
||||
if icon.isDirectory then
|
||||
fileSizeLabel.text = string.format("%.2f", fs.directorySize(icon.path) / 1024) .. " KB"
|
||||
window:draw()
|
||||
buffer.draw()
|
||||
end
|
||||
|
||||
@ -8,8 +8,8 @@ local function isNan(x)
|
||||
return x ~= x
|
||||
end
|
||||
|
||||
function color.HEXToRGB(color)
|
||||
return bit32.rshift(color, 16), bit32.band(bit32.rshift(color, 8), 0xFF), bit32.band(color, 0xFF)
|
||||
function color.HEXToRGB(HEXColor)
|
||||
return bit32.rshift(HEXColor, 16), bit32.band(bit32.rshift(HEXColor, 8), 0xFF), bit32.band(HEXColor, 0xFF)
|
||||
end
|
||||
|
||||
function color.RGBToHEX(r, g, b)
|
||||
@ -62,8 +62,8 @@ function color.HSBToRGB(h, s, v)
|
||||
return math.floor(rr * const), math.floor(gg * const), math.floor(bb * const)
|
||||
end
|
||||
|
||||
function color.HEXToHSB(color)
|
||||
local rr, gg, bb = color.HEXToRGB(color)
|
||||
function color.HEXToHSB(HEXColor)
|
||||
local rr, gg, bb = color.HEXToRGB(HEXColor)
|
||||
local h, s, b = color.RGBToHSB( rr, gg, bb )
|
||||
|
||||
return h, s, b
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
local color = require("color")
|
||||
local unicode = require("unicode")
|
||||
local fs = require("filesystem")
|
||||
local gpu = require("component").gpu
|
||||
|
||||
-------------------------------------------------- Constants --------------------------------------------------
|
||||
@ -163,10 +164,10 @@ local function getFileExtension(path)
|
||||
return string.match(path, "^.+(%.[^%/]+)%/?$")
|
||||
end
|
||||
|
||||
local function loadOrSave(methodName, path, picture, encodingMethod)
|
||||
local function loadOrSave(methodName, path, ...)
|
||||
local fileExtension = getFileExtension(path)
|
||||
if image.formatModules[fileExtension] then
|
||||
return image.formatModules[fileExtension][methodName](path, picture, encodingMethod)
|
||||
return image.formatModules[fileExtension][methodName](path, ...)
|
||||
else
|
||||
error("Failed to open file \"" .. tostring(path) .. "\" as image: format module for extension \"" .. tostring(fileExtension) .. "\" is not loaded")
|
||||
end
|
||||
@ -177,7 +178,11 @@ function image.save(path, picture, encodingMethod)
|
||||
end
|
||||
|
||||
function image.load(path)
|
||||
return loadOrSave("load", path)
|
||||
if fs.exists(path) then
|
||||
return loadOrSave("load", path)
|
||||
else
|
||||
return image.fromString("0101FFE300x")
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------- Image serialization --------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user