From 3df6599347f91818b8bca1c4e4df1bb7922cbf32 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sun, 17 Sep 2017 23:41:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications.cfg | 4 +- MineOS/OS.lua | 6 --- lib/MineOSCore.lua | 93 ++++++++++++++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 40 deletions(-) diff --git a/Applications.cfg b/Applications.cfg index db97d8c4..94b2f7a0 100644 --- a/Applications.cfg +++ b/Applications.cfg @@ -5,7 +5,7 @@ about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/About/", type="Script", forceDownload=true, - version=3.80, + version=3.81, }, { path="/MineOS/Pictures/MoonTouch.pic", @@ -223,7 +223,7 @@ path="/lib/MineOSCore.lua", url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua", type="Library", - version=1.80, + version=1.81, }, { path="/lib/advancedLua.lua", diff --git a/MineOS/OS.lua b/MineOS/OS.lua index 77b9a7e0..52d10b1e 100755 --- a/MineOS/OS.lua +++ b/MineOS/OS.lua @@ -336,8 +336,6 @@ local function createOSWindow() icon.selected = false MineOSCore.OSDraw() - elseif eventData[1] == "double_touch" then - icon.onDoubleClick(icon, eventData) end end @@ -361,10 +359,6 @@ local function createOSWindow() end end - icon.onDoubleClick = function(icon, eventData) - MineOSCore.iconDoubleClick(icon, eventData) - end - icon.onRightClick = function(icon, eventData) local indexOf = icon:indexOf() diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index 2b32631f..1753b2e5 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -394,6 +394,27 @@ end ----------------------------------------------------------------------------------------------------------------------------------- +local function getCykaIconPosition(iconField) + local y = iconField.yOffset + for i = 1, #iconField.iconsContainer.children do + y = math.max(y, iconField.iconsContainer.children[i].localPosition.y) + end + + local x = iconField.xOffset + for i = 1, #iconField.iconsContainer.children do + if iconField.iconsContainer.children[i].localPosition.y == y then + x = math.max(x, iconField.iconsContainer.children[i].localPosition.x) + end + end + + x = x + MineOSCore.iconWidth + iconField.spaceBetweenIcons.horizontal + if x + MineOSCore.iconWidth + iconField.spaceBetweenIcons.horizontal > iconField.iconsContainer.width then + x, y = iconField.xOffset, y + MineOSCore.iconHeight + iconField.spaceBetweenIcons.vertical + end + + return x, y +end + local function iconFieldUpdateFileList(iconField) iconField.fileList = fs.sortedList(iconField.workpath, iconField.sortingMethod, MineOSCore.OSSettings.showHiddenFiles) iconField:update() @@ -403,49 +424,57 @@ local function iconFieldUpdateFileList(iconField) iconField:loadIconConfig() end - -- Заполнение дочернего контейнера - iconField.iconsContainer:deleteChildren() - local xPos, yPos, horizontalIconCounter = iconField.xOffset, iconField.yOffset, 1 + local configList, notConfigList = {}, {} for i = iconField.fromFile, iconField.fromFile + iconField.iconCount.total - 1 do if iconField.fileList[i] then if not iconField.filenameMatcher or string.unicodeFind(unicode.lower(iconField.fileList[i]), unicode.lower(iconField.filenameMatcher)) then - -- Выставление позиций иконок на основании конфига - local xIcon, yIcon, filename = xPos, yPos, fs.name(iconField.fileList[i]) - if iconField.iconConfig[filename] then - xIcon, yIcon = iconField.iconConfig[filename].x, iconField.iconConfig[filename].y + if iconField.iconConfigEnabled and iconField.iconConfig[iconField.fileList[i]] then + table.insert(configList, iconField.fileList[i]) else - xPos, horizontalIconCounter = xPos + MineOSCore.iconWidth + iconField.spaceBetweenIcons.horizontal, horizontalIconCounter + 1 - if horizontalIconCounter > iconField.iconCount.horizontal then - xPos, horizontalIconCounter = iconField.xOffset, 1 - yPos = yPos + MineOSCore.iconHeight + iconField.spaceBetweenIcons.vertical - end - - if iconField.iconConfigEnabled then - iconField.iconConfig[filename] = { - x = xIcon, - y = yIcon - } - end + table.insert(notConfigList, iconField.fileList[i]) end - - local icon = iconField.iconsContainer:addChild( - MineOSCore.icon( - xIcon, yIcon, - iconField.workpath .. iconField.fileList[i], - iconField.colors.text, - iconField.colors.selection - ) - ) - - icon.eventHandler = iconEventHandler - icon.launchers = iconField.launchers - icon:analyseExtension() end else break end end + -- Заполнение дочернего контейнера + iconField.iconsContainer:deleteChildren() + for i = 1, #configList do + local icon = iconField.iconsContainer:addChild(MineOSCore.icon( + iconField.iconConfig[configList[i]].x, + iconField.iconConfig[configList[i]].y, + iconField.workpath .. configList[i], + iconField.colors.text, + iconField.colors.selection + )) + + icon.eventHandler = iconEventHandler + icon.launchers = iconField.launchers + icon:analyseExtension() + end + + local x, y + if #configList > 0 then + x, y = getCykaIconPosition(iconField, configList) + else + x, y = iconField.xOffset, iconField.yOffset + end + for i = 1, #notConfigList do + local icon = iconField.iconsContainer:addChild(MineOSCore.icon(x, y, iconField.workpath .. notConfigList[i], iconField.colors.text, iconField.colors.selection)) + iconField.iconConfig[notConfigList[i]] = {x = x, y = y} + + icon.eventHandler = iconEventHandler + icon.launchers = iconField.launchers + icon:analyseExtension() + + x = x + MineOSCore.iconWidth + iconField.spaceBetweenIcons.horizontal + if x + MineOSCore.iconWidth + iconField.spaceBetweenIcons.horizontal - 1 > iconField.iconsContainer.width then + x, y = iconField.xOffset, y + MineOSCore.iconHeight + iconField.spaceBetweenIcons.vertical + end + end + if iconField.iconConfigEnabled then iconField:saveIconConfig() end