Новый графонистый файловый менеджер

This commit is contained in:
Igor Timofeev 2017-09-06 21:16:28 +03:00
parent 45e6722b59
commit 1638d91207
9 changed files with 2090 additions and 1511 deletions

View File

@ -5,7 +5,7 @@
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/About/",
type="Script",
forceDownload=true,
version=3.73,
version=3.74,
},
{
path="/MineOS/Pictures/MoonTouch.pic",
@ -60,14 +60,14 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/Localization/Russian.lang",
type="Script",
forceDownload=true,
version=1.29,
version=1.30,
},
{
path="/MineOS/System/Localization/English.lang",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/Localization/English.lang",
type="Script",
forceDownload=true,
version=1.29,
version=1.30,
},
----------------------------------------------------- Ассоциация говна --------------------------------------------------------------------------
{
@ -223,14 +223,14 @@
path="/lib/MineOSCore.lua",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
type="Library",
version=1.74,
version=1.75,
},
{
path="/lib/advancedLua.lua",
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/advancedLua.lua",
type="Library",
preloadFile=true,
version=1.19,
version=1.20,
},
{
path="/lib/web.lua",
@ -283,7 +283,7 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
type="Library",
preloadFile=true,
version=1.73,
version=1.74,
},
{
path="/lib/rayEngine.lua",
@ -462,7 +462,7 @@
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic",
createShortcut="dock",
forceDownload=true,
version=1.76,
version=1.77,
resources={
{
path="/Localization/Russian.lang",
@ -896,7 +896,7 @@
type="Application",
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Shooting/Icon.pic",
createShortcut="desktop",
version=1.0,
version=1.02,
},
{
path="/MineOS/Applications/HoloClock",

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,12 @@ local component = require("component")
local gpu = component.gpu
local event = require("event")
local ecs = require("ECSAPI")
local colorlib = require("colorlib")
local color = require("color")
---------------------------
local xOld, yOld = gpu.getResolution()
gpu.setResolution(160, 50)
local xSize, ySize = 160, 50
gpu.setResolution(xSize, ySize)
local players = {}
local xCenter, yCenter = math.floor(xSize/4 - 15), math.floor(ySize/2)
@ -147,7 +147,7 @@ end
local function AddPlayer(name)
if not players[name] then
players[name] = {0, colorlib.HSBtoHEX(math.random(0, 359), 100, math.random(50, 100))}
players[name] = {0, color.HSBToHEX(math.random(0, 359), 100, math.random(50, 100))}
end
end
@ -273,6 +273,9 @@ end
--------------------------
gpu.setBackground(0x262626)
gpu.fill(1, 1, xSize, ySize, " ")
while true do
local exit = Tir()
if exit == "exit" then break end

View File

@ -17,6 +17,7 @@
yes = "Yes",
no = "No",
cancel = "Cancel",
open = "Open",
applyToAll = "Apply to all",
toDirectory = "to directory",
copying = "Copying",

View File

@ -17,6 +17,7 @@
yes = "Да",
no = "Нет",
cancel = "Отмена",
open = "Открыть",
applyToAll = "Применить ко всем",
toDirectory = "в директории",
copying = "Копирование",

View File

@ -190,7 +190,7 @@ end
local function setProtectionMethod()
local container = MineOSCore.addUniversalContainer(MineOSCore.OSMainContainer, MineOSCore.localization.protectYourComputer)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE))
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x444444, 0x999999))
comboBox:addItem(MineOSCore.localization.biometricProtection)
comboBox:addItem(MineOSCore.localization.passwordProtection)
comboBox:addItem(MineOSCore.localization.withoutProtection)
@ -586,12 +586,17 @@ local function createOSWindow()
menu:addItem(MineOSCore.localization.wallpaper).onTouch = function()
local container = MineOSCore.addUniversalContainer(MineOSCore.OSMainContainer, MineOSCore.localization.wallpaper)
local inputField = container.layout:addChild(GUI.inputField(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x999999, 0xEEEEEE, 0x262626, MineOSCore.OSSettings.wallpaper, MineOSCore.localization.wallpaperPath, false))
local label = container.layout:addChild(GUI.label(1, 1, 36, 1, 0xFF4940, MineOSCore.localization.file .. " " .. MineOSCore.localization.notExists)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
label.hidden = fs.exists(inputField.text)
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x444444, 0x999999, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.wallpaperPath, GUI.filesystemModes.file, "/", MineOSCore.OSSettings.wallpaper))
filesystemChooser:addExtensionFilter(".pic")
filesystemChooser.onItemSelected = function(path)
MineOSCore.OSSettings.wallpaper = path
MineOSCore.saveOSSettings()
changeWallpaper()
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE))
MineOSCore.OSDraw()
end
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x444444, 0x999999))
comboBox.selectedItem = MineOSCore.OSSettings.wallpaperMode or 1
comboBox:addItem(MineOSCore.localization.wallpaperModeStretch)
comboBox:addItem(MineOSCore.localization.wallpaperModeCenter)
@ -606,15 +611,6 @@ local function createOSWindow()
MineOSCore.OSDraw()
end
inputField.onInputFinished = function()
MineOSCore.OSSettings.wallpaper = inputField.text
MineOSCore.saveOSSettings()
changeWallpaper()
label.hidden = fs.exists(inputField.text)
MineOSCore.OSDraw()
end
comboBox.onItemSelected = function()
MineOSCore.OSSettings.wallpaperMode = comboBox.selectedItem
MineOSCore.saveOSSettings()
@ -626,7 +622,7 @@ local function createOSWindow()
menu:addItem(MineOSCore.localization.screensaver).onTouch = function()
local container = MineOSCore.addUniversalContainer(MineOSCore.OSMainContainer, MineOSCore.localization.screensaver)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE))
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x444444, 0x999999))
local fileList = fs.sortedList(screensaversPath, "name", false)
for i = 1, #fileList do
comboBox:addItem(fs.hideExtension(fileList[i]))

View File

@ -46,7 +46,9 @@ GUI.dropDownMenuElementTypes = enum(
GUI.filesystemModes = enum(
"file",
"directory",
"both"
"both",
"open",
"save"
)
GUI.colors = {
@ -72,7 +74,7 @@ GUI.colors = {
},
windows = {
title = {
background = 0xEEEEEE,
background = 0xE1E1E1,
text = 0x3C3C3C
},
backgroundPanel = 0xFFFFFF,
@ -85,7 +87,23 @@ GUI.colors = {
background = 0xCCCCCC,
text = 0x3C3C3C
}
}
},
},
filesystemDialog = {
default = {
background = 0xE1E1E1,
file = 0x3C3C3C,
directory = 0x3C3C3C,
arrow = 0xAAAAAA
},
selected = {
background = 0x3C3C3C,
fileOrDirectory = 0xE1E1E1,
arrow = 0xBBBBBB
},
wrongExtension = 0xAAAAAA,
scrollBarBackground = 0xC3C3C3,
scrollBarForeground = 0x444444
}
}
@ -877,14 +895,16 @@ function GUI.error(...)
local x, y = math.floor(buffer.width / 2 - width / 2), offset + 1
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x1D1D1D))
mainContainer:addChild(GUI.image(x, y, sign))
mainContainer:addChild(GUI.textBox(x + image.getWidth(sign) + 2, y, textWidth, #lines, 0x1D1D1D, 0xEEEEEE, lines, 1, 0, 0)).eventHandler = nil
local buttonWidth = 12
local button = mainContainer:addChild(GUI.button(x + image.getWidth(sign) + textWidth - buttonWidth + 2, mainContainer.height - offset, buttonWidth, 1, 0x3366CC, 0xEEEEEE, 0xEEEEEE, 0x3366CC, "Ok"))
mainContainer:addChild(GUI.textBox(x + image.getWidth(sign) + 2, y, textWidth, #lines, 0x1D1D1D, 0xE1E1E1, lines, 1, 0, 0)).eventHandler = nil
local buttonWidth = 10
local button = mainContainer:addChild(GUI.roundedButton(x + image.getWidth(sign) + textWidth - buttonWidth + 2, mainContainer.height - offset, buttonWidth, 1, 0x3366CC, 0xE1E1E1, 0xE1E1E1, 0x3366CC, "OK"))
button.onTouch = function()
mainContainer:stopEventHandling()
buffer.paste(mainContainer.x, mainContainer.y, oldPixels)
buffer.draw()
end
mainContainer.eventHandler = function(mainContainer, object, eventData)
if eventData[1] == "key_down" and eventData[4] == 28 then
button:pressAndRelease()
@ -1881,7 +1901,7 @@ end
local function drawComboBox(object)
buffer.square(object.x, object.y, object.width, object.height, object.colors.default.background)
local x, y, limit, arrowSize = object.x + 1, math.floor(object.y + object.height / 2), object.width - 5, object.height
local x, y, limit, arrowSize = object.x + 1, math.floor(object.y + object.height / 2), object.width - 3, object.height
if object.dropDownMenu.itemsContainer.children[object.selectedItem] then
buffer.text(x, y, object.colors.default.text, string.limit(object.dropDownMenu.itemsContainer.children[object.selectedItem].text, limit, "right"))
end
@ -2660,6 +2680,7 @@ local function updateFileList(treeView, directoriesToShowContent, xOffset, path)
element.path = path .. file
element.xOffset = xOffset
element.isDirectory = fs.isDirectory(element.path)
element.extension = fs.extension(file, true) or ""
if
treeView.showMode == GUI.filesystemModes.both or
@ -2700,11 +2721,16 @@ local function updateFileList(treeView, directoriesToShowContent, xOffset, path)
end
local function treeViewUpdateFileList(treeView)
treeView.fileList = updateFileList(treeView, treeView.directoriesToShowContent, 1, treeView.workPath)
treeView.updateFileListLater = true
return treeView
end
local function treeViewDraw(treeView)
if treeView.updateFileListLater then
treeView.fileList = updateFileList(treeView, treeView.directoriesToShowContent, 1, treeView.workPath)
treeView.updateFileListLater = nil
end
local y = treeView.y
local showScrollBar = #treeView.fileList > treeView.height
local textLimit = treeView.width - (showScrollBar and 2 or 1)
@ -2714,19 +2740,25 @@ local function treeViewDraw(treeView)
end
for fileIndex = treeView.fromFile, #treeView.fileList do
local textColor, arrowColor = treeView.colors.default.text, treeView.colors.default.arrow
local textColor, arrowColor, text = treeView.colors.default.file, treeView.colors.default.arrow, treeView.fileList[fileIndex].isDirectory and "" or ""
if treeView.fileList[fileIndex].path == treeView.selectedItem then
textColor, arrowColor = treeView.colors.selected.text, treeView.colors.selected.arrow
buffer.square(treeView.x, y, treeView.width, 1, treeView.colors.selected.background, textColor, " ")
textColor, arrowColor = treeView.colors.selected.fileOrDirectory, treeView.colors.selected.arrow
buffer.square(treeView.x, y, treeView.width, 1, treeView.colors.selected.background, textColor, " ")
else
if treeView.fileList[fileIndex].isDirectory then
textColor = treeView.colors.default.directory
elseif treeView.extensionFilters and not treeView.extensionFilters[treeView.fileList[fileIndex].extension] then
textColor = treeView.colors.wrongExtension
end
end
if treeView.fileList[fileIndex].isDirectory then
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset, y, arrowColor, treeView.directoriesToShowContent[treeView.fileList[fileIndex].path] and "" or "")
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset + 2, y, textColor, unicode.sub("" .. fs.name(treeView.fileList[fileIndex].path), 1, textLimit - treeView.fileList[fileIndex].xOffset - 2))
else
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset, y, textColor, unicode.sub("" .. fs.name(treeView.fileList[fileIndex].path), 1, textLimit - treeView.fileList[fileIndex].xOffset))
end
buffer.text(treeView.x + treeView.fileList[fileIndex].xOffset + 2, y, textColor, unicode.sub(text .. fs.name(treeView.fileList[fileIndex].path), 1, textLimit - treeView.fileList[fileIndex].xOffset - 2))
y = y + 1
if y > treeView.y + treeView.height - 1 then
break
@ -2752,51 +2784,52 @@ local function treeViewDraw(treeView)
return treeView
end
local function treeViewEventHandler(mainContainer, object, eventData)
local function treeViewEventHandler(mainContainer, treeView, eventData)
if eventData[1] == "touch" then
local fileIndex = eventData[4] - object.y + object.fromFile
if object.fileList[fileIndex] then
local fileIndex = eventData[4] - treeView.y + treeView.fromFile
if treeView.fileList[fileIndex] then
if
object.fileList[fileIndex].isDirectory and
treeView.fileList[fileIndex].isDirectory and
(
object.selectionMode == GUI.filesystemModes.file or
object.selectedItem == object.fileList[fileIndex].path or
eventData[3] == object.x + object.fileList[fileIndex].xOffset
treeView.selectionMode == GUI.filesystemModes.file or
eventData[3] >= treeView.x + treeView.fileList[fileIndex].xOffset - 1 and eventData[3] <= treeView.x + treeView.fileList[fileIndex].xOffset + 1
)
then
if object.directoriesToShowContent[object.fileList[fileIndex].path] then
object.directoriesToShowContent[object.fileList[fileIndex].path] = nil
if treeView.directoriesToShowContent[treeView.fileList[fileIndex].path] then
treeView.directoriesToShowContent[treeView.fileList[fileIndex].path] = nil
else
object.directoriesToShowContent[object.fileList[fileIndex].path] = true
treeView.directoriesToShowContent[treeView.fileList[fileIndex].path] = true
end
object:updateFileList()
treeView:updateFileList()
mainContainer:draw()
buffer.draw()
else
if
object.selectionMode == GUI.filesystemModes.both or
object.selectionMode == GUI.filesystemModes.file and not object.fileList[fileIndex].isDirectory or
object.selectionMode == GUI.filesystemModes.directory and object.fileList[fileIndex].isDirectory
(
treeView.selectionMode == GUI.filesystemModes.both or
treeView.selectionMode == GUI.filesystemModes.directory and treeView.fileList[fileIndex].isDirectory or
treeView.selectionMode == GUI.filesystemModes.file and (not treeView.extensionFilters or treeView.extensionFilters[treeView.fileList[fileIndex].extension])
)
then
object.selectedItem = object.fileList[fileIndex].path
treeView.selectedItem = treeView.fileList[fileIndex].path
mainContainer:draw()
buffer.draw()
callMethod(object.onItemSelected, object.selectedItem, eventData)
callMethod(treeView.onItemSelected, treeView.selectedItem, eventData)
end
end
end
elseif eventData[1] == "scroll" then
if eventData[5] == 1 then
if object.fromFile > 1 then
object.fromFile = object.fromFile - 1
if treeView.fromFile > 1 then
treeView.fromFile = treeView.fromFile - 1
mainContainer:draw()
buffer.draw()
end
else
if object.fromFile < #object.fileList then
object.fromFile = object.fromFile + 1
if treeView.fromFile < #treeView.fileList then
treeView.fromFile = treeView.fromFile + 1
mainContainer:draw()
buffer.draw()
end
@ -2804,37 +2837,47 @@ local function treeViewEventHandler(mainContainer, object, eventData)
end
end
function GUI.treeView(x, y, width, height, backgroundColor, textColor, selectionColor, selectionTextColor, arrowColor, scrollBarBackground, scrollBarForeground, workPath, showMode, selectionMode)
local function treeViewAddExtensionFilter(treeView, extensionFilter)
treeView.extensionFilters = treeView.extensionFilters or {}
treeView.extensionFilters[unicode.lower(extensionFilter)] = true
end
function GUI.treeView(x, y, width, height, backgroundColor, directoryColor, fileColor, arrowColor, backgroundSelectionColor, textSelectedColor, arrowSelectionColor, wrongExtensionColor, scrollBarBackground, scrollBarForeground, workPath, showMode, selectionMode)
local treeView = GUI.container(x, y, width, height)
treeView.eventHandler = treeViewEventHandler
treeView.colors = {
default = {
background = backgroundColor,
text = textColor,
arrow = arrowColor
directory = directoryColor,
file = fileColor,
arrow = arrowColor,
},
selected = {
background = selectionColor,
text = selectionTextColor,
arrow = selectionTextColor
background = backgroundSelectionColor,
fileOrDirectory = textSelectedColor,
arrow = arrowSelectionColor,
},
scrollBar = {
background = scrollBarBackground,
foreground = scrollBarForeground
},
wrongExtension = wrongExtensionColor
}
treeView.directoriesToShowContent = {}
treeView.fileList = {}
treeView.workPath = workPath
treeView.updateFileList = treeViewUpdateFileList
treeView.draw = treeViewDraw
treeView.extensionFilters = nil
treeView.selectedItem = nil
treeView.fromFile = 1
treeView.showMode = showMode or GUI.filesystemModes.both
treeView.selectionMode = selectionMode or GUI.filesystemModes.file
treeView.updateFileList = treeViewUpdateFileList
treeView.draw = treeViewDraw
treeView.addExtensionFilter = treeViewAddExtensionFilter
treeView:updateFileList()
return treeView
@ -2842,23 +2885,218 @@ end
--------------------------------------------------------------------------------------------------------------------------------
local function filesystemDialogDraw(filesystemDialog)
if filesystemDialog.extensionComboBox.hidden then
filesystemDialog.inputField.width = filesystemDialog.cancelButton.localPosition.x - 4
else
filesystemDialog.inputField.width = filesystemDialog.extensionComboBox.localPosition.x - 3
end
if not (filesystemDialog.IOMode == GUI.filesystemModes.save) then
filesystemDialog.inputField.text = filesystemDialog.treeView.selectedItem
end
filesystemDialog.submitButton.disabled = not (filesystemDialog.treeView.selectedItem and filesystemDialog.inputField.text)
GUI.drawContainerContent(filesystemDialog)
GUI.windowShadow(filesystemDialog.x, filesystemDialog.y, filesystemDialog.width, filesystemDialog.height, GUI.colors.contextMenu.transparency.shadow, true)
return filesystemDialog
end
local function filesystemDialogSetMode(filesystemDialog, IOMode, filesystemMode)
filesystemDialog.IOMode = IOMode
filesystemDialog.filesystemMode = filesystemMode
if filesystemDialog.IOMode == GUI.filesystemModes.save then
filesystemDialog.treeView.showMode = GUI.filesystemModes.directory
filesystemDialog.treeView.selectionMode = GUI.filesystemModes.directory
filesystemDialog.inputField.eventHandler = inputFieldEventHandler
filesystemDialog.extensionComboBox.hidden = not (filesystemDialog.filesystemMode == GUI.filesystemModes.file)
else
if filesystemDialog.filesystemMode == GUI.filesystemModes.file then
filesystemDialog.treeView.showMode = GUI.filesystemModes.both
filesystemDialog.treeView.selectionMode = GUI.filesystemModes.file
else
filesystemDialog.treeView.showMode = GUI.filesystemModes.directory
filesystemDialog.treeView.selectionMode = GUI.filesystemModes.directory
end
filesystemDialog.inputField.eventHandler = nil
filesystemDialog.extensionComboBox.hidden = true
end
filesystemDialog.treeView:updateFileList()
end
local function filesystemDialogAddExtensionFilter(filesystemDialog, extension)
filesystemDialog.extensionComboBox:addItem(extension)
filesystemDialog.extensionComboBox.width = math.max(filesystemDialog.extensionComboBox.width, unicode.len(extension) + 3)
filesystemDialog.extensionComboBox.localPosition.x = filesystemDialog.cancelButton.localPosition.x - filesystemDialog.extensionComboBox.width - 2
filesystemDialog.treeView:addExtensionFilter(extension)
end
function GUI.filesystemDialog(x, y, width, height, submitButtonText, cancelButtonText, placeholderText, path)
local filesystemDialog = GUI.container(x, y, width, height)
filesystemDialog:addChild(GUI.panel(1, height - 2, width, 3, 0xD2D2D2))
filesystemDialog.cancelButton = filesystemDialog:addChild(GUI.adaptiveRoundedButton(1, height - 1, 2, 0, 0xE1E1E1, 0x3C3C3C, 0x3C3C3C, 0xE1E1E1, cancelButtonText))
filesystemDialog.submitButton = filesystemDialog:addChild(GUI.adaptiveRoundedButton(1, height - 1, 2, 0, 0x3C3C3C, 0xE1E1E1, 0xE1E1E1, 0x3C3C3C, submitButtonText))
filesystemDialog.submitButton.localPosition.x = filesystemDialog.width - filesystemDialog.submitButton.width - 1
filesystemDialog.cancelButton.localPosition.x = filesystemDialog.submitButton.localPosition.x - filesystemDialog.cancelButton.width - 2
filesystemDialog.extensionComboBox = filesystemDialog:addChild(GUI.comboBox(1, height - 1, 1, 1, 0xE1E1E1, 0x555555, 0xC3C3C3, 0x888888))
filesystemDialog.extensionComboBox.hidden = true
filesystemDialog.inputField = filesystemDialog:addChild(GUI.inputField(2, height - 1, 1, 1, 0xE1E1E1, 0x555555, 0x888888, 0xE1E1E1, 0x777777, nil, placeholderText))
filesystemDialog.treeView = filesystemDialog:addChild(GUI.treeView(
1, 1, width, height - 3,
GUI.colors.filesystemDialog.default.background,
GUI.colors.filesystemDialog.default.file,
GUI.colors.filesystemDialog.default.directory,
GUI.colors.filesystemDialog.default.arrow,
GUI.colors.filesystemDialog.selected.background,
GUI.colors.filesystemDialog.selected.fileOrDirectory,
GUI.colors.filesystemDialog.selected.arrow,
GUI.colors.filesystemDialog.wrongExtension,
GUI.colors.filesystemDialog.scrollBarBackground,
GUI.colors.filesystemDialog.scrollBarForeground,
path
))
filesystemDialog.draw = filesystemDialogDraw
filesystemDialog.setMode = filesystemDialogSetMode
filesystemDialog.addExtensionFilter = filesystemDialogAddExtensionFilter
filesystemDialog:setMode(GUI.filesystemModes.save, GUI.filesystemModes.file)
return filesystemDialog
end
function GUI.showFilesystemDialog(parentContainer, ...)
local container = parentContainer:addChild(GUI.container(1, 1, parentContainer.width, parentContainer.height))
container:addChild(GUI.object(1, 1, container.width, container.height))
local filesystemDialog = container:addChild(GUI.filesystemDialog(1, 1, math.floor(container.width * 0.35), math.floor(container.height * 0.8), ...))
filesystemDialog.localPosition.x = math.floor(container.width / 2 - filesystemDialog.width / 2)
filesystemDialog.cancelButton.onTouch = function()
local firstParent = filesystemDialog:getFirstParent()
filesystemDialog.parent:delete()
firstParent:draw()
buffer.draw()
end
filesystemDialog.submitButton.onTouch = function()
filesystemDialog.cancelButton.onTouch()
local path = filesystemDialog.treeView.selectedItem
if filesystemDialog.IOMode == GUI.filesystemModes.save then
path = path .. filesystemDialog.inputField.text
if filesystemDialog.filesystemMode == GUI.filesystemModes.file then
path = path .. filesystemDialog.extensionComboBox:getItem(filesystemDialog.extensionComboBox.selectedItem).text
else
path = path .. "/"
end
end
callMethod(filesystemDialog.onSubmit, path)
end
return filesystemDialog
end
--------------------------------------------------------------------------------------------------------------------------------
local function filesystemChooserDraw(object)
local tipWidth = object.height * 2 - 1
local y = math.floor(object.y + object.height / 2)
buffer.square(object.x, object.y, object.width - tipWidth, object.height, object.colors.background, object.colors.text, " ")
buffer.square(object.x + object.width - tipWidth, object.y, tipWidth, object.height, object.pressed and object.colors.tipText or object.colors.tipBackground, object.pressed and object.colors.tipBackground or object.colors.tipText, " ")
buffer.text(object.x + object.width - math.floor(tipWidth / 2) - 1, y, object.pressed and object.colors.tipBackground or object.colors.tipText, "")
buffer.text(object.x + 1, y, object.colors.text, string.limit(object.path or object.placeholderText, object.width - tipWidth - 2, "left"))
return filesystemChooser
end
local function filesystemChooserAddExtensionFilter(object, extension)
object.extensionFilters = object.extensionFilters or {}
object.extensionFilters[unicode.lower(extension)] = true
end
local function filesystemChooserEventHandler(mainContainer, object, eventData)
if eventData[1] == "touch" then
object.state = true
local filesystemDialog = GUI.showFilesystemDialog(mainContainer, object.submitButtonText, object.cancelButtonText, object.placeholderText, object.filesystemDialogPath)
for key in pairs(object.extensionFilters) do
filesystemDialog:addExtensionFilter(key)
end
filesystemDialog:setMode(GUI.filesystemModes.open, object.filesystemMode)
filesystemDialog.onSubmit = function(path)
object.path = path
mainContainer:draw()
buffer.draw()
callMethod(object.onItemSelected, object.path)
end
mainContainer:draw()
buffer.draw()
end
end
function GUI.filesystemChooser(x, y, width, height, backgroundColor, textColor, tipBackgroundColor, tipTextColor, submitButtonText, cancelButtonText, placeholderText, filesystemMode, filesystemDialogPath, path)
local object = GUI.object(x, y, width, height)
object.eventHandler = comboBoxEventHandler
object.colors = {
tipBackground = tipBackgroundColor,
tipText = tipTextColor,
text = textColor,
background = backgroundColor
}
object.submitButtonText = submitButtonText
object.cancelButtonText = cancelButtonText
object.placeholderText = placeholderText
object.pressed = false
object.path = path
object.filesystemDialogPath = filesystemDialogPath
object.draw = filesystemChooserDraw
object.eventHandler = filesystemChooserEventHandler
object.filesystemMode = filesystemMode
object.addExtensionFilter = filesystemChooserAddExtensionFilter
return object
end
--------------------------------------------------------------------------------------------------------------------------------
-- buffer.flush()
-- buffer.draw(true)
-- local mainContainer = GUI.fullScreenContainer()
-- mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x262626))
-- local treeView1 = mainContainer:addChild(GUI.treeView(2, 2, 30, 41, 0xCCCCCC, 0x2D2D2D, 0x3C3C3C, 0xEEEEEE, 0x666666, 0xC3C3C3, 0x393939, "/", GUI.filesystemModes.both, GUI.filesystemModes.both))
-- treeView1.onItemSelected = function(path)
-- GUI.error("Somethig was selected, the path is: \"" .. path .. "\"")
-- local dialog = GUI.showFilesystemDialog(mainContainer, "Save", "Cancel", "File name", "/")
-- dialog:setMode(GUI.filesystemModes.open, GUI.filesystemModes.file)
-- dialog:addExtensionFilter(".pic")
-- dialog:addExtensionFilter(".app")
-- dialog.onSubmit = function(path)
-- GUI.error(path)
-- end
-- local treeView2 = mainContainer:addChild(GUI.treeView(34, 2, 30, 41, 0xCCCCCC, 0x2D2D2D, 0x3C3C3C, 0xEEEEEE, 0x666666, 0xC3C3C3, 0x393939, "/", GUI.filesystemModes.file, GUI.filesystemModes.file))
-- treeView2.onItemSelected = function(path)
-- GUI.error("File was selected, the path is: \"" .. path .. "\"")
-- end
-- local chooser = mainContainer:addChild(GUI.filesystemChooser(2, 2, 30, 3, 0xE1E1E1, 0x888888, 0x3C3C3C, 0x888888, "Open", "Cancel", "File name", GUI.filesystemModes.file, "/", "/MineOS/Desktop/Test.pic"))
-- local treeView3 = mainContainer:addChild(GUI.treeView(66, 2, 30, 41, 0xCCCCCC, 0x2D2D2D, 0x3C3C3C, 0xEEEEEE, 0x666666, 0xC3C3C3, 0x393939, "/", GUI.filesystemModes.directory, GUI.filesystemModes.directory))
-- treeView3.onItemSelected = function(path)
-- GUI.error("Directory was selected, the path is: \"" .. path .. "\"")
-- end
-- chooser:addExtensionFilter(".pic")
-- mainContainer:draw()
-- buffer.draw(true)

View File

@ -19,7 +19,7 @@ MineOSCore.iconWidth = 12
MineOSCore.iconHeight = 6
MineOSCore.selectionIconPart = 0.4
MineOSCore.iconClickDelay = 0.2
MineOSCore.iconConfigFileName = "/.icons"
MineOSCore.iconConfigFileName = ".icons"
MineOSCore.paths = {}
MineOSCore.paths.OS = "/MineOS/"
@ -366,7 +366,7 @@ end
local function iconFieldLoadIconConfig(iconField)
if fs.exists(iconField.workpath .. MineOSCore.iconConfigFileName) then
iconField.iconConfig = table.fromFile(iconField.workpath .. MineOSCore.iconConfigFileName)
-- Чистим конфиг от файлов, которых более нет в иконфилде
local iconConfigItemExistsInFileList
for key in pairs(iconField.iconConfig) do

View File

@ -154,8 +154,9 @@ function filesystem.name(path)
return path:match("%/?([^%/]+)%/?$")
end
function filesystem.extension(path)
return path:match("[^%/]+(%.[^%/]+)%/?$")
function filesystem.extension(path, lower)
local extension = path:match("[^%/]+(%.[^%/]+)%/?$")
return (lower and extension) and (unicode.lower(extension)) or extension
end
function filesystem.hideExtension(path)