From f10060831dd15ec85c075adb927d5b87a1602329 Mon Sep 17 00:00:00 2001 From: InsideBSITheSecond <89040198+InsideBSITheSecond@users.noreply.github.com> Date: Mon, 16 Aug 2021 21:08:34 +0200 Subject: [PATCH 01/18] Fix crash caused by graph's axis values above 1000 just renamed the function "number" parameter to avoid indexing it --- Libraries/GUI.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 6ad1b409..82eb6ee8 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -1242,19 +1242,19 @@ end -------------------------------------------------------------------------------- -local function getAxisValue(number, postfix, roundValues) +local function getAxisValue(num, postfix, roundValues) if roundValues then - return math.floor(number) .. postfix + return math.floor(num) .. postfix else - local integer, fractional = math.modf(number) + local integer, fractional = math.modf(num) local firstPart, secondPart = "", "" if math.abs(integer) >= 1000 then return number.shorten(integer, 2) .. postfix else if math.abs(fractional) > 0 then - return string.format("%.2f", number) .. postfix + return string.format("%.2f", num) .. postfix else - return number .. postfix + return num .. postfix end end end From 2ec542b42252c42f13717e368465d15817d82e97 Mon Sep 17 00:00:00 2001 From: Bs0Dd Date: Mon, 23 Aug 2021 13:39:10 +0600 Subject: [PATCH 02/18] Added polygons rasterization and function for Picture Edit --- .../Localizations/English.lang | 4 +- .../Localizations/Russian.lang | 4 +- Applications/Picture Edit.app/Tools/1.lua | 34 ++++++++++++++++ Libraries/Screen.lua | 40 +++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/Applications/Picture Edit.app/Localizations/English.lang b/Applications/Picture Edit.app/Localizations/English.lang index 0056dfc0..c76bbae7 100644 --- a/Applications/Picture Edit.app/Localizations/English.lang +++ b/Applications/Picture Edit.app/Localizations/English.lang @@ -85,5 +85,7 @@ brightness = "Brightness: ", filterColor = "Filter color", transparency = "Transparency: ", - force = "Force" + force = "Force", + rasterizePolygon = "Rasterize polygon", + polygonEdges = "number of polygon edges:" } diff --git a/Applications/Picture Edit.app/Localizations/Russian.lang b/Applications/Picture Edit.app/Localizations/Russian.lang index 52a4f90a..c2d43776 100644 --- a/Applications/Picture Edit.app/Localizations/Russian.lang +++ b/Applications/Picture Edit.app/Localizations/Russian.lang @@ -85,5 +85,7 @@ brightness = "Яркость: ", filterColor = "Цвет фильтра", transparency = "Прозрачность: ", - force = "Сила: " + force = "Сила: ", + rasterizePolygon = "Растеризировать полигон", + polygonEdges = "Количество граней полигона:" } diff --git a/Applications/Picture Edit.app/Tools/1.lua b/Applications/Picture Edit.app/Tools/1.lua index dc16522d..984701bc 100644 --- a/Applications/Picture Edit.app/Tools/1.lua +++ b/Applications/Picture Edit.app/Tools/1.lua @@ -19,6 +19,7 @@ local fillButton = window.newButton1(locale.fill) local outlineButton = window.newButton1(locale.outline) local rasterizeLineButton = window.newButton1(locale.rasterizeLine) local rasterizeEllipseButton = window.newButton1(locale.rasterizeEllipse) +local rasterizePolygonButton = window.newButton1(locale.rasterizePolygon) local clearButton = window.newButton2(locale.clear) local cropButton = window.newButton2(locale.crop) @@ -101,6 +102,39 @@ tool.onSelection = function() workspace:draw() end + + window.currentToolLayout:addChild(rasterizePolygonButton).onTouch = function() + local container = GUI.addBackgroundContainer(workspace, true, true, locale.polygonEdges) + container.panel.eventHandler = nil + + local edgesSelector = container.layout:addChild(GUI.comboBox(1, 1, 30, 3, 0xEEEEEE, 0x2D2D2D, 0xCCCCCC, 0x888888)) + for i = 3, 10 do + edgesSelector:addItem(i) + end + + container.layout:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.ok)).onTouch = function() + screen.rasterizePolygon( + touchX - window.image.x + 1, + touchY - window.image.y + 1, + dragX - window.image.x + 1, + dragY - window.image.y + 1, + edgesSelector.selectedItem + 2, + function(x, y) + if x <= window.image.data[1] and y <= window.image.data[2] and x > 0 and y > 0 then + image.set(window.image.data, x, y, window.primaryColorSelector.color, 0x0, 0, " ") + end + end + ) + + container:remove() + end + + container.layout:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.cancel)).onTouch = function() + container:remove() + end + + workspace:draw() + end window.currentToolLayout:addChild(clearButton).onTouch = function() for j = selector.y, selector.y + selector.height - 1 do diff --git a/Libraries/Screen.lua b/Libraries/Screen.lua index 0b2b602a..ec0846f4 100755 --- a/Libraries/Screen.lua +++ b/Libraries/Screen.lua @@ -426,6 +426,38 @@ local function rasterizeEllipse(centerX, centerY, radiusX, radiusY, method) end end +local function rasterizePolygon(centerX, centerY, startX, startY, countOfEdges, method) + local degreeStep = 360 / countOfEdges + + local deltaX, deltaY = startX - centerX, startY - centerY + local radius = math.sqrt(deltaX ^ 2 + deltaY ^ 2) + local halfRadius = radius / 2 + local startDegree = math.deg(math.asin(deltaX / radius)) + + local function round(num) + if num >= 0 then + return math.floor(num + 0.5) + else + return math.ceil(num - 0.5) + end + end + + local function calculatePosition(degree) + local radDegree = math.rad(degree) + local deltaX2 = math.sin(radDegree) * radius + local deltaY2 = math.cos(radDegree) * radius + return round(centerX + deltaX2), round(centerY + (deltaY >= 0 and deltaY2 or -deltaY2)) + end + + local xOld, yOld, xNew, yNew = calculatePosition(startDegree) + + for degree = (startDegree + degreeStep - 1), (startDegree + 360), degreeStep do + xNew, yNew = calculatePosition(degree) + rasterizeLine(xOld, yOld, xNew, yNew, method) + xOld, yOld = xNew, yNew + end +end + local function drawLine(x1, y1, x2, y2, background, foreground, symbol) rasterizeLine(x1, y1, x2, y2, function(x, y) set(x, y, background, foreground, symbol) @@ -438,6 +470,12 @@ local function drawEllipse(centerX, centerY, radiusX, radiusY, background, foreg end) end +local function drawPolygon(centerX, centerY, radiusX, radiusY, background, foreground, countOfEdges, symbol) + rasterizePolygon(centerX, centerY, radiusX, radiusY, countOfEdges, function(x, y) + set(x, y, background, foreground, symbol) + end) +end + local function drawText(x, y, textColor, data, transparency) if y >= drawLimitY1 and y <= drawLimitY2 then local charIndex, screenIndex = 1, bufferWidth * (y - 1) + x @@ -776,6 +814,7 @@ return { paste = paste, rasterizeLine = rasterizeLine, rasterizeEllipse = rasterizeEllipse, + rasterizePolygon = rasterizePolygon, semiPixelRawSet = semiPixelRawSet, semiPixelSet = semiPixelSet, update = update, @@ -783,6 +822,7 @@ return { drawRectangle = drawRectangle, drawLine = drawLine, drawEllipse = drawEllipse, + drawPolygon = drawPolygon, drawText = drawText, drawImage = drawImage, drawFrame = drawFrame, From 4882829e2a4f46da9e5f5620ad8cc5c7baadcd6b Mon Sep 17 00:00:00 2001 From: Bs0Dd Date: Mon, 23 Aug 2021 13:45:24 +0600 Subject: [PATCH 03/18] Bruh --- Applications/Picture Edit.app/Localizations/English.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/Picture Edit.app/Localizations/English.lang b/Applications/Picture Edit.app/Localizations/English.lang index c76bbae7..ebe33c98 100644 --- a/Applications/Picture Edit.app/Localizations/English.lang +++ b/Applications/Picture Edit.app/Localizations/English.lang @@ -87,5 +87,5 @@ transparency = "Transparency: ", force = "Force", rasterizePolygon = "Rasterize polygon", - polygonEdges = "number of polygon edges:" + polygonEdges = "Number of polygon edges:" } From a1404171d1d38208a85524ce6de0227d3d909ee0 Mon Sep 17 00:00:00 2001 From: Bs0Dd Date: Wed, 25 Aug 2021 00:20:37 +0600 Subject: [PATCH 04/18] Viewer returned))) --- Applications/Viewer.app/Icon.pic | Bin 0 -> 190 bytes Applications/Viewer.app/Icons/arrowLeft.pic | Bin 0 -> 114 bytes Applications/Viewer.app/Icons/arrowRight.pic | Bin 0 -> 114 bytes Applications/Viewer.app/Icons/play.pic | Bin 0 -> 118 bytes .../Viewer.app/Icons/setWallpaper.pic | Bin 0 -> 124 bytes .../Viewer.app/Localizations/English.lang | 14 ++ .../Viewer.app/Localizations/Russian.lang | 14 ++ Applications/Viewer.app/Main.lua | 199 ++++++++++++++++++ 8 files changed, 227 insertions(+) create mode 100644 Applications/Viewer.app/Icon.pic create mode 100644 Applications/Viewer.app/Icons/arrowLeft.pic create mode 100644 Applications/Viewer.app/Icons/arrowRight.pic create mode 100644 Applications/Viewer.app/Icons/play.pic create mode 100644 Applications/Viewer.app/Icons/setWallpaper.pic create mode 100644 Applications/Viewer.app/Localizations/English.lang create mode 100644 Applications/Viewer.app/Localizations/Russian.lang create mode 100644 Applications/Viewer.app/Main.lua diff --git a/Applications/Viewer.app/Icon.pic b/Applications/Viewer.app/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..0534eba57c714aee4974b430bd6e753b211daed9 GIT binary patch literal 190 zcmXZWu?+$-429wMY$x^@x64ULRIEh70928v=%`rdB5rvvS@_=_7>%QeedBM?c09^!B>XLF9 m?TQT)GTJlI0?+9YwBM_Mc&Vs)+#<^4Lx8K*Uv$43&HDq$&=D5^ literal 0 HcmV?d00001 diff --git a/Applications/Viewer.app/Icons/arrowRight.pic b/Applications/Viewer.app/Icons/arrowRight.pic new file mode 100644 index 0000000000000000000000000000000000000000..ad5bf95c24cc354c702406beaca9669d2143311f GIT binary patch literal 114 zcmXwx%L%|R3`6BlK4WB;LZPRw)IdilSuOW0(kg+11-750b368wU0(QTH-IjJpe|~j nMyvA!MIP;1&=Ks1&w_?r0O8mSF|U!0aUNXgDXi$C5~5KbvKtW> literal 0 HcmV?d00001 diff --git a/Applications/Viewer.app/Icons/play.pic b/Applications/Viewer.app/Icons/play.pic new file mode 100644 index 0000000000000000000000000000000000000000..1f2d432a13fd1f5e47bf8e8253901f2a3c0413ca GIT binary patch literal 118 zcmW-Z-3fp&5QCG;^=FLkA_zXYl7b^h2kZ!4K-)rckbFnZ?buUxe(+Ww0G)&kq1AgP o7-Fl}0uE_{cL5<5fJ3Bp(LKbJO|+D?u1DG`$A1}9okqEae@jIX*#H0l literal 0 HcmV?d00001 diff --git a/Applications/Viewer.app/Icons/setWallpaper.pic b/Applications/Viewer.app/Icons/setWallpaper.pic new file mode 100644 index 0000000000000000000000000000000000000000..1e92c8d8a630321e11aee8efccfa8472605b46cd GIT binary patch literal 124 zcmXZT%?W@o3|3 Date: Wed, 25 Aug 2021 00:30:18 +0600 Subject: [PATCH 05/18] Now Viewer is a standard for images --- Libraries/Paths.lua | 1 + Libraries/System.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Paths.lua b/Libraries/Paths.lua index 94c20776..280632bc 100755 --- a/Libraries/Paths.lua +++ b/Libraries/Paths.lua @@ -23,6 +23,7 @@ paths.system.applicationPictureEdit = paths.system.applications .. "Picture Edit paths.system.applicationSettings = paths.system.applications .. "Settings.app/Main.lua" paths.system.applicationPrint3D = paths.system.applications .. "3D Print.app/Main.lua" paths.system.applicationConsole = paths.system.applications .. "Console.app/Main.lua" +paths.system.applicationViewer = paths.system.applications .. "Viewer.app/Main.lua" -------------------------------------------------------------------------------- diff --git a/Libraries/System.lua b/Libraries/System.lua index 6d0bbbb0..c60876d9 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -131,7 +131,7 @@ function system.getDefaultUserSettings() [".cfg"] = filesystem.path(paths.system.applicationMineCodeIDE), [".txt"] = filesystem.path(paths.system.applicationMineCodeIDE), [".lang"] = filesystem.path(paths.system.applicationMineCodeIDE), - [".pic"] = filesystem.path(paths.system.applicationPictureEdit), + [".pic"] = filesystem.path(paths.system.applicationViewer), [".3dm"] = paths.system.applications .. "3D Print.app/" }, } From d08ed5c0fd7e39ee9c7d43c07d94f964c4acf80d Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Wed, 25 Aug 2021 02:05:06 +0700 Subject: [PATCH 06/18] Cykf!!111 --- .../Extensions/.pic/Context menu.lua | 21 ++++++ .../Picture View.app/Extensions/.pic/Icon.pic | Bin 0 -> 208 bytes .../{Viewer.app => Picture View.app}/Icon.pic | Bin .../Icons/ArrowLeft.pic} | Bin .../Icons/ArrowRight.pic} | Bin .../Icons/Play.pic} | Bin .../Icons/SetWallpaper.pic} | Bin .../Localizations/English.lang | 0 .../Localizations/Russian.lang | 0 .../{Viewer.app => Picture View.app}/Main.lua | 62 ++++++++++++------ Installer/Files.cfg | 10 +++ 11 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 Applications/Picture View.app/Extensions/.pic/Context menu.lua create mode 100644 Applications/Picture View.app/Extensions/.pic/Icon.pic rename Applications/{Viewer.app => Picture View.app}/Icon.pic (100%) rename Applications/{Viewer.app/Icons/arrowLeft.pic => Picture View.app/Icons/ArrowLeft.pic} (100%) rename Applications/{Viewer.app/Icons/arrowRight.pic => Picture View.app/Icons/ArrowRight.pic} (100%) rename Applications/{Viewer.app/Icons/play.pic => Picture View.app/Icons/Play.pic} (100%) rename Applications/{Viewer.app/Icons/setWallpaper.pic => Picture View.app/Icons/SetWallpaper.pic} (100%) rename Applications/{Viewer.app => Picture View.app}/Localizations/English.lang (100%) rename Applications/{Viewer.app => Picture View.app}/Localizations/Russian.lang (100%) rename Applications/{Viewer.app => Picture View.app}/Main.lua (81%) diff --git a/Applications/Picture View.app/Extensions/.pic/Context menu.lua b/Applications/Picture View.app/Extensions/.pic/Context menu.lua new file mode 100644 index 00000000..d1ebe992 --- /dev/null +++ b/Applications/Picture View.app/Extensions/.pic/Context menu.lua @@ -0,0 +1,21 @@ + +local filesystem = require("Filesystem") +local GUI = require("GUI") +local paths = require("Paths") +local system = require("System") + +local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...) +local localization = system.getSystemLocalization() + +menu:addItem(localization.setAsWallpaper).onTouch = function() + local userSettings = system.getUserSettings() + + userSettings.interfaceWallpaperPath = icon.path + userSettings.interfaceWallpaperEnabled = true + system.updateWallpaper() + workspace:draw() + + system.saveUserSettings() +end + +system.addUploadToPastebinMenuItem(menu, icon.path) diff --git a/Applications/Picture View.app/Extensions/.pic/Icon.pic b/Applications/Picture View.app/Extensions/.pic/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..269a6401c3815e1a41c2faab4e5bb3899f056331 GIT binary patch literal 208 zcmXZWy$J$A5C!0UGqbyw+rVJ~HX#TmnwuJ#*^D)at(Yoe3xbgt2;!ZO#|DpYeuA0x ze7PuH*qG2GAq5PbG0p^&Qr_amRiNxzk^9NO2@oe@C>!FaR}ITuoqa`2MR^K;6Tm*g hkHnB4!gR%~{?x`n)R*uTapW@r>P6&Pd&u{#h(9Zi7V!W8 literal 0 HcmV?d00001 diff --git a/Applications/Viewer.app/Icon.pic b/Applications/Picture View.app/Icon.pic similarity index 100% rename from Applications/Viewer.app/Icon.pic rename to Applications/Picture View.app/Icon.pic diff --git a/Applications/Viewer.app/Icons/arrowLeft.pic b/Applications/Picture View.app/Icons/ArrowLeft.pic similarity index 100% rename from Applications/Viewer.app/Icons/arrowLeft.pic rename to Applications/Picture View.app/Icons/ArrowLeft.pic diff --git a/Applications/Viewer.app/Icons/arrowRight.pic b/Applications/Picture View.app/Icons/ArrowRight.pic similarity index 100% rename from Applications/Viewer.app/Icons/arrowRight.pic rename to Applications/Picture View.app/Icons/ArrowRight.pic diff --git a/Applications/Viewer.app/Icons/play.pic b/Applications/Picture View.app/Icons/Play.pic similarity index 100% rename from Applications/Viewer.app/Icons/play.pic rename to Applications/Picture View.app/Icons/Play.pic diff --git a/Applications/Viewer.app/Icons/setWallpaper.pic b/Applications/Picture View.app/Icons/SetWallpaper.pic similarity index 100% rename from Applications/Viewer.app/Icons/setWallpaper.pic rename to Applications/Picture View.app/Icons/SetWallpaper.pic diff --git a/Applications/Viewer.app/Localizations/English.lang b/Applications/Picture View.app/Localizations/English.lang similarity index 100% rename from Applications/Viewer.app/Localizations/English.lang rename to Applications/Picture View.app/Localizations/English.lang diff --git a/Applications/Viewer.app/Localizations/Russian.lang b/Applications/Picture View.app/Localizations/Russian.lang similarity index 100% rename from Applications/Viewer.app/Localizations/Russian.lang rename to Applications/Picture View.app/Localizations/Russian.lang diff --git a/Applications/Viewer.app/Main.lua b/Applications/Picture View.app/Main.lua similarity index 81% rename from Applications/Viewer.app/Main.lua rename to Applications/Picture View.app/Main.lua index 9ae68659..6c266dec 100644 --- a/Applications/Viewer.app/Main.lua +++ b/Applications/Picture View.app/Main.lua @@ -11,14 +11,14 @@ local currentNum = 1 local workspace, window, menu = system.addWindow(GUI.titledWindow(1, 1, 70, 30, 'Viewer', true)) -local locale = system.getCurrentScriptLocalization() +local localization = system.getCurrentScriptLocalization() local iconsPath = fs.path(system.getCurrentScript())..'Icons/' -local arrowLeftPic = image.load(iconsPath .. "arrowLeft.pic") -local arrowRightPic = image.load(iconsPath .. "arrowRight.pic") -local playPic = image.load(iconsPath .. "play.pic") -local setWallpaperPic = image.load(iconsPath.."setWallpaper.pic") +local arrowLeftPic = image.load(iconsPath .. "ArrowLeft.pic") +local arrowRightPic = image.load(iconsPath .. "ArrowRight.pic") +local playPic = image.load(iconsPath .. "Play.pic") +local setWallpaperPic = image.load(iconsPath.."SetWallpaper.pic") local layout = window:addChild(GUI.layout(1, 2, window.width, window.height, 1, 1)) @@ -36,11 +36,20 @@ local function scanDir() end local function loadImg() - if imageObj then imageObj:remove() end + if imageObj then + imageObj:remove() + end + local newImg, ifErr = image.load(dirFiles[currentNum]) - if not newImg then GUI.alert(ifErr) window:remove() return end + + if not newImg then + GUI.alert(ifErr) + window:remove() + return + end + imageObj = layout:addChild(GUI.image(1, 1, newImg)) - window.titleLabel.text = 'Viewer - '..text.limit(dirFiles[currentNum], 30, "center") + window.titleLabel.text = 'Viewer - ' .. text.limit(dirFiles[currentNum], 30, "center") workspace:draw() end @@ -55,18 +64,18 @@ end local play = panelLay:addChild(GUI.image(2, 1, playPic)) play.eventHandler = function(_, _, typ) if typ == 'touch' then - local container = GUI.addBackgroundContainer(workspace, true, true, locale.slideShow) + local container = GUI.addBackgroundContainer(workspace, true, true, localization.slideShow) container.panel.eventHandler = nil container.layout:setSpacing(1, 1, 2) - local delay = container.layout:addChild(GUI.slider(1, 1, 50, 0x66DB80, 0x0, 0xFFFFFF, 0xFFFFFF, 3, 30, 0, true, locale.delay, locale.seconds)) + local delay = container.layout:addChild(GUI.slider(1, 1, 50, 0x66DB80, 0x0, 0xFFFFFF, 0xFFFFFF, 3, 30, 0, true, localization.delay, localization.seconds)) delay.roundValues = true - local onFull = container.layout:addChild(GUI.switchAndLabel(1, 1, 27, 8, 0x66DB80, 0x1D1D1D, 0xEEEEEE, 0xFFFFFF, locale.fullScreen..":", false)) + local onFull = container.layout:addChild(GUI.switchAndLabel(1, 1, 27, 8, 0x66DB80, 0x1D1D1D, 0xEEEEEE, 0xFFFFFF, localization.fullScreen..":", false)) local buttonsLay = container.layout:addChild(GUI.layout(1, 1, 30, 7, 1, 1)) - buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.start)).onTouch = function() + buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.start)).onTouch = function() local slDelay = delay.value if onFull.switch.state then local w, h = screen.getResolution() @@ -90,7 +99,9 @@ play.eventHandler = function(_, _, typ) else panel.hidden = true panelLay.hidden = true + local strTim = system.getTime() + layout.eventHandler = function(_, _, typ) if typ == 'touch' or typ == 'key_down' then layout.eventHandler = nil @@ -107,30 +118,36 @@ play.eventHandler = function(_, _, typ) container:remove() end - buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.cancel)).onTouch = function() + buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.cancel)).onTouch = function() container:remove() end end end + panelLay:setPosition(2, 1, play) +-- Arrow right local arrowRight = panelLay:addChild(GUI.image(1, 1, arrowRightPic)) + arrowRight.eventHandler = function(_, _, typ) if typ == 'touch' then currentNum = currentNum == #dirFiles and 1 or currentNum+1 loadImg() end end + panelLay:setPosition(3, 1, arrowRight) +-- Set wallpaper local setWallpaper = panelLay:addChild(GUI.image(1, 1, setWallpaperPic)) + setWallpaper.eventHandler = function(_, _, typ) if typ == 'touch' then - local container = GUI.addBackgroundContainer(workspace, true, true, locale.setWallpaper) + local container = GUI.addBackgroundContainer(workspace, true, true, localization.setWallpaper) container.panel.eventHandler = nil local buttLay = container.layout:addChild(GUI.layout(1, 1, 24, 6, 2, 1)) - buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.yes)).onTouch = function() + buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.yes)).onTouch = function() local sets = system.getUserSettings() sets.interfaceWallpaperPath = dirFiles[currentNum] system.saveUserSettings() @@ -139,24 +156,24 @@ setWallpaper.eventHandler = function(_, _, typ) container:remove() end - local cancel = buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.no)) + local cancel = buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.no)) cancel.onTouch = function() container:remove() end buttLay:setPosition(2, 1, cancel) end end + panelLay:setPosition(4, 1, setWallpaper) -local hsPanel = menu:addItem(locale.hidePanel) +local hsPanel = menu:addItem(localization.hidePanel) hsPanel.onTouch = function() - hsPanel.text = panel.hidden and locale.hidePanel or locale.showPanel + hsPanel.text = panel.hidden and localization.hidePanel or localization.showPanel panel.hidden = not panel.hidden panelLay.hidden = not panelLay.hidden end -local flScreen = menu:addItem(locale.fullScreen) -flScreen.onTouch = function() +menu:addItem(localization.fullScreen).onTouch = function() local w, h = screen.getResolution() local flScr = workspace:addChild(GUI.window(1, 1, w, h)) flScr:addChild(GUI.panel(1, 1, w, h, 0xFFFFFF)) @@ -179,14 +196,17 @@ end if (options.o or options.open) and args[1] then currentDir = fs.path(args[1]) + scanDir() + for i=1, #dirFiles do if dirFiles[i] == args[1] then currentNum = i loadImg() break end end else scanDir() + if #dirFiles == 0 then - layout:addChild(GUI.text(1, 1, 0x4B4B4B, locale.noPictures)) + layout:addChild(GUI.text(1, 1, 0x4B4B4B, localization.noPictures)) panel.hidden = true panelLay.hidden = true hsPanel.disabled = true diff --git a/Installer/Files.cfg b/Installer/Files.cfg index 4425d39a..1a2da751 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -134,6 +134,16 @@ "Applications/Picture Edit.app/Localizations/English.lang", "Applications/Picture Edit.app/Localizations/Russian.lang", "Applications/Picture Edit.app/Extensions/.pic/Icon.pic", + -- Picture View + { path="Applications/Picture View.app/Main.lua" }, + "Applications/Picture View.app/Icon.pic", + "Applications/Picture View.app/Icons/ArrowLeft.pic", + "Applications/Picture View.app/Icons/ArrowRight.pic", + "Applications/Picture View.app/Icons/Play.pic", + "Applications/Picture View.app/Icons/SetWallpaper.pic", + "Applications/Picture View.app/Localizations/English.lang", + "Applications/Picture View.app/Localizations/Russian.lang", + "Applications/Picture View.app/Extensions/.pic/Icon.pic", -- Finder { path="Applications/Finder.app/Main.lua", id=175 }, "Applications/Finder.app/Icon.pic", From 25289c43d2c8cee33c66a82090e201d3dc4da757 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Wed, 25 Aug 2021 03:56:12 +0700 Subject: [PATCH 07/18] =?UTF-8?q?=D0=91=D0=BB=D1=8F=D0=B4=D1=8C,=20=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=B0=D0=BA=20=D0=B7=D0=B0=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D1=85=D0=B0=D0=BB=20=D1=8D=D1=82=D0=BE=D1=82=20=D0=BE=D0=BF?= =?UTF-8?q?=D0=B5=D0=BD=D1=81=D1=83=D1=80=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Localizations/English.lang | 2 - .../Localizations/Russian.lang | 2 - Applications/Picture View.app/Main.lua | 354 +++++++++--------- Libraries/GUI.lua | 7 +- Libraries/Paths.lua | 2 +- Libraries/System.lua | 2 +- 6 files changed, 190 insertions(+), 179 deletions(-) diff --git a/Applications/Picture View.app/Localizations/English.lang b/Applications/Picture View.app/Localizations/English.lang index 6ad9d411..da4b28ae 100644 --- a/Applications/Picture View.app/Localizations/English.lang +++ b/Applications/Picture View.app/Localizations/English.lang @@ -3,8 +3,6 @@ slideShow = "Slideshow", delay = "Delay: ", seconds = " seconds", - hidePanel = "Hide panel", - shpwPanel = "Show panel", fullScreen = "Full screen", setWallpaper = "Do you want to set this picture as wallpaper?", yes = "Yes", diff --git a/Applications/Picture View.app/Localizations/Russian.lang b/Applications/Picture View.app/Localizations/Russian.lang index 39d72c40..c57b3872 100644 --- a/Applications/Picture View.app/Localizations/Russian.lang +++ b/Applications/Picture View.app/Localizations/Russian.lang @@ -3,8 +3,6 @@ slideShow = "Слайдшоу", delay = "Задержка: ", seconds = " секунд(ы)", - hidePanel = "Скрыть панель", - showPanel = "Показать панель", fullScreen = "На полный экран", setWallpaper = "Вы хотите установить это изображение в качестве обоев?", yes = "Да", diff --git a/Applications/Picture View.app/Main.lua b/Applications/Picture View.app/Main.lua index 6c266dec..8e647f2c 100644 --- a/Applications/Picture View.app/Main.lua +++ b/Applications/Picture View.app/Main.lua @@ -4,216 +4,228 @@ local fs = require("Filesystem") local image = require("Image") local text = require("Text") local screen = require("Screen") - -local args, options = system.parseArguments(...) -local currentDir, dirFiles = '/Pictures/' -local currentNum = 1 - -local workspace, window, menu = system.addWindow(GUI.titledWindow(1, 1, 70, 30, 'Viewer', true)) +local paths = require("Paths") local localization = system.getCurrentScriptLocalization() -local iconsPath = fs.path(system.getCurrentScript())..'Icons/' +local args, options = system.parseArguments(...) +local iconsPath = fs.path(system.getCurrentScript()) .. "Icons/" +local currentDir, files = ((options.o or options.open) and args[1] and fs.exists(args[1])) and fs.path(args[1]) or paths.system.pictures +local fileIndex = 1 +local loadedImage -local arrowLeftPic = image.load(iconsPath .. "ArrowLeft.pic") -local arrowRightPic = image.load(iconsPath .. "ArrowRight.pic") -local playPic = image.load(iconsPath .. "Play.pic") -local setWallpaperPic = image.load(iconsPath.."SetWallpaper.pic") +-------------------------------------------------------------------------------- -local layout = window:addChild(GUI.layout(1, 2, window.width, window.height, 1, 1)) +local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 80, 25, 0x1E1E1E)) -local panel = window:addChild(GUI.panel(1, window.height-5, window.width, 6, 0x000000, 0.5)) -local panelLay = window:addChild(GUI.layout(1, window.height-5, window.width, 6, 4, 1)) -local imageObj +local imageObject = window:addChild(GUI.object(1, 1, 1, 1)) -local function scanDir() - dirFiles = {} - for lab, file in pairs(fs.list(currentDir)) do - if lab ~= 'n' and string.lower(fs.extension(file) or '') == ".pic" then - table.insert(dirFiles, currentDir .. file) - end - end +imageObject.draw = function() + if loadedImage then + screen.drawImage( + math.floor(window.x + window.width / 2 - loadedImage[1] / 2), + math.floor(window.y + window.height / 2 - loadedImage[2] / 2), + loadedImage + ) + end end -local function loadImg() - if imageObj then - imageObj:remove() - end +window.actionButtons:moveToFront() + +local title = window:addChild(GUI.text(1, 2, 0xFFFFFF, " ", 0.5)) +local panel = window:addChild(GUI.panel(1, 1, 1, 6, 0x000000, 0.5)) +local panelContainer = window:addChild(GUI.container(1, 1, 1, panel.height)) +local slideShowDelay, slideShowDeadline + +local function setUIHidden(state) + panel.hidden = state + panelContainer.hidden = state + window.actionButtons.hidden = state + title.hidden = state +end + +local function updateSlideshowDeadline() + slideShowDeadline = computer.uptime() + slideShowDelay +end + +local function updateTitlePosition() + title.localX = math.floor(window.width / 2 - unicode.len(title.text) / 2) +end + +local function loadImage() + local result, reason = image.load(files[fileIndex]) - local newImg, ifErr = image.load(dirFiles[currentNum]) - - if not newImg then - GUI.alert(ifErr) + if result then + title.text = fs.name(files[fileIndex]) + updateTitlePosition() + + loadedImage = result + else + GUI.alert(reason) window:remove() - return end - imageObj = layout:addChild(GUI.image(1, 1, newImg)) - window.titleLabel.text = 'Viewer - ' .. text.limit(dirFiles[currentNum], 30, "center") workspace:draw() end -local arrowLeft = panelLay:addChild(GUI.image(1, 1, arrowLeftPic)) -arrowLeft.eventHandler = function(_, _, typ) - if typ == 'touch' then - currentNum = currentNum == 1 and #dirFiles or currentNum-1 - loadImg() +local function loadIncremented(value) + fileIndex = fileIndex + value + + if fileIndex > #files then + fileIndex = 1 + elseif fileIndex < 1 then + fileIndex = #files end + + loadImage() end -local play = panelLay:addChild(GUI.image(2, 1, playPic)) -play.eventHandler = function(_, _, typ) - if typ == 'touch' then - local container = GUI.addBackgroundContainer(workspace, true, true, localization.slideShow) - container.panel.eventHandler = nil - container.layout:setSpacing(1, 1, 2) - - local delay = container.layout:addChild(GUI.slider(1, 1, 50, 0x66DB80, 0x0, 0xFFFFFF, 0xFFFFFF, 3, 30, 0, true, localization.delay, localization.seconds)) - delay.roundValues = true - - local onFull = container.layout:addChild(GUI.switchAndLabel(1, 1, 27, 8, 0x66DB80, 0x1D1D1D, 0xEEEEEE, 0xFFFFFF, localization.fullScreen..":", false)) - - local buttonsLay = container.layout:addChild(GUI.layout(1, 1, 30, 7, 1, 1)) - - buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.start)).onTouch = function() - local slDelay = delay.value - if onFull.switch.state then - local w, h = screen.getResolution() - local flScr = workspace:addChild(GUI.window(1, 1, w, h)) - flScr:addChild(GUI.panel(1, 1, w, h, 0xFFFFFF)) - local flLay = flScr:addChild(GUI.layout(1, 1, w, h, 1, 1)) - local img = flLay:addChild(GUI.image(1, 1, imageObj.image)) - +local function addButton(imageName, onTouch) + -- Spacing + if #panelContainer.children > 0 then + panelContainer.width = panelContainer.width + 5 + end + + local i = GUI.image(panelContainer.width, 2, image.load(iconsPath .. imageName .. ".pic")) + + panelContainer:addChild(i).eventHandler = function(_, _, e) + if e == "touch" then + onTouch() + end + end + + panelContainer.width = panelContainer.width + i.width +end + +addButton("ArrowLeft", function() + loadIncremented(-1) +end) + +addButton("Play", function() + local container = GUI.addBackgroundContainer(workspace, true, true, localization.slideShow) + container.panel.eventHandler = nil + container.layout:setSpacing(1, 1, 2) - flScr.eventHandler = function(_, _, typ) - if typ == 'touch' or typ == 'key_down' then flScr:remove() loadImg() - elseif strTim + slDelay <= system.getTime() then - img:remove() - currentNum = currentNum == #dirFiles and 1 or currentNum+1 - local newImg, ifErr = image.load(dirFiles[currentNum]) - if not newImg then GUI.alert(ifErr) flScr:remove() window:remove() return end - img = flLay:addChild(GUI.image(1, 1, newImg)) - strTim = system.getTime() - end - end - else - panel.hidden = true - panelLay.hidden = true - - local strTim = system.getTime() + local delay = container.layout:addChild(GUI.slider(1, 1, 50, 0x66DB80, 0x0, 0xFFFFFF, 0xFFFFFF, 3, 30, 0, true, localization.delay, localization.seconds)) + delay.roundValues = true + + local buttonsLay = container.layout:addChild(GUI.layout(1, 1, 30, 7, 1, 1)) + + buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.start)).onTouch = function() + setUIHidden(true) - layout.eventHandler = function(_, _, typ) - if typ == 'touch' or typ == 'key_down' then - layout.eventHandler = nil - panel.hidden = false - panelLay.hidden = false - elseif strTim + slDelay <= system.getTime() then - currentNum = currentNum == #dirFiles and 1 or currentNum+1 - loadImg() - strTim = system.getTime() - end - end - end - - container:remove() - end - - buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.cancel)).onTouch = function() - container:remove() + if not window.maximized then + window:maximize() end + + slideShowDelay = delay.value + updateSlideshowDeadline() + + container:remove() + end + + buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.cancel)).onTouch = function() + container:remove() end -end -panelLay:setPosition(2, 1, play) + workspace:draw() +end) -- Arrow right -local arrowRight = panelLay:addChild(GUI.image(1, 1, arrowRightPic)) - -arrowRight.eventHandler = function(_, _, typ) - if typ == 'touch' then - currentNum = currentNum == #dirFiles and 1 or currentNum+1 - loadImg() - end -end - -panelLay:setPosition(3, 1, arrowRight) +addButton("ArrowRight", function() + loadIncremented(1) +end) -- Set wallpaper -local setWallpaper = panelLay:addChild(GUI.image(1, 1, setWallpaperPic)) - -setWallpaper.eventHandler = function(_, _, typ) - if typ == 'touch' then - local container = GUI.addBackgroundContainer(workspace, true, true, localization.setWallpaper) - container.panel.eventHandler = nil - local buttLay = container.layout:addChild(GUI.layout(1, 1, 24, 6, 2, 1)) - - buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.yes)).onTouch = function() - local sets = system.getUserSettings() - sets.interfaceWallpaperPath = dirFiles[currentNum] - system.saveUserSettings() - system.updateWallpaper() - - container:remove() - end +addButton("SetWallpaper", function() + local container = GUI.addBackgroundContainer(workspace, true, true, localization.setWallpaper) + container.panel.eventHandler = nil - local cancel = buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.no)) - cancel.onTouch = function() - container:remove() - end - buttLay:setPosition(2, 1, cancel) - end -end - -panelLay:setPosition(4, 1, setWallpaper) - -local hsPanel = menu:addItem(localization.hidePanel) -hsPanel.onTouch = function() - hsPanel.text = panel.hidden and localization.hidePanel or localization.showPanel - panel.hidden = not panel.hidden - panelLay.hidden = not panelLay.hidden -end - -menu:addItem(localization.fullScreen).onTouch = function() - local w, h = screen.getResolution() - local flScr = workspace:addChild(GUI.window(1, 1, w, h)) - flScr:addChild(GUI.panel(1, 1, w, h, 0xFFFFFF)) - local flLay = flScr:addChild(GUI.layout(1, 1, w, h, 1, 1)) - flLay:addChild(GUI.image(1, 1, imageObj.image)) + local buttLay = container.layout:addChild(GUI.layout(1, 1, 24, 6, 2, 1)) - flScr.eventHandler = function(_, _, typ) - if typ == 'touch' or typ == 'key_down' then flScr:remove() end + buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.yes)).onTouch = function() + local sets = system.getUserSettings() + sets.interfaceWallpaperPath = files[fileIndex] + system.saveUserSettings() + system.updateWallpaper() + + container:remove() end -end + + local cancel = buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.no)) + + cancel.onTouch = function() + container:remove() + end + + buttLay:setPosition(2, 1, cancel) +end) window.onResize = function(newWidth, newHeight) window.backgroundPanel.width, window.backgroundPanel.height = newWidth, newHeight - layout.width, layout.height = newWidth, newHeight - window.titlePanel.width = newWidth - window.titleLabel.width = newWidth - panel.width, panel.localY = newWidth, newHeight-5 - panelLay.width, panelLay.localY = newWidth, newHeight-5 + imageObject.width, imageObject.height = newWidth, newHeight + panel.width, panel.localY = newWidth, newHeight - 5 + panelContainer.localX, panelContainer.localY = math.floor(newWidth / 2 - panelContainer.width / 2), panel.localY + + updateTitlePosition() end -if (options.o or options.open) and args[1] then - currentDir = fs.path(args[1]) - - scanDir() +local overrideWindowEventHandler = window.eventHandler +window.eventHandler = function(workspace, window, e1, ...) + if e1 == "double_touch" then + setUIHidden(not panel.hidden) + workspace:draw() + elseif e1 == "touch" or e1 == "key_down" then + if slideShowDeadline then + setUIHidden(false) + slideShowDelay, slideShowDeadline = nil, nil - for i=1, #dirFiles do - if dirFiles[i] == args[1] then currentNum = i loadImg() break end - end -else - scanDir() - - if #dirFiles == 0 then - layout:addChild(GUI.text(1, 1, 0x4B4B4B, localization.noPictures)) - panel.hidden = true - panelLay.hidden = true - hsPanel.disabled = true - flScreen.disabled = true + workspace:draw() + end else - loadImg() + if slideShowDelay and computer.uptime() > slideShowDeadline then + loadIncremented(1) + workspace:draw() + + updateSlideshowDeadline() + end end + + overrideWindowEventHandler(workspace, window, e1, ...) end +-------------------------------------------------------------------------------- + +window.onResize(window.width, window.height) + +files = fs.list(currentDir) + +if #files == 0 then + layout:addChild(GUI.text(1, 1, 0x4B4B4B, localization.noPictures)) + panel.hidden = true + panelContainer.hidden = true + hsPanel.disabled = true + flScreen.disabled = true +else + local i, extension = 1 + while i <= #files do + extension = fs.extension(files[i]) + + if extension and extension:lower() == ".pic" then + files[i] = currentDir .. files[i] + + if args and args[1] == files[i] then + fileIndex = i + end + + i = i + 1 + else + table.remove(files, i) + end + end + + loadImage() +end + + workspace:draw() diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 82eb6ee8..d38cd011 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -3524,20 +3524,23 @@ end local function textUpdate(object) object.width = unicode.len(object.text) + return object end local function textDraw(object) object:update() - screen.drawText(object.x, object.y, object.color, object.text) + screen.drawText(object.x, object.y, object.color, object.text, object.transparency) + return object end -function GUI.text(x, y, color, text) +function GUI.text(x, y, color, text, transparency) local object = GUI.object(x, y, 1, 1) object.text = text object.color = color + object.transparency = transparency object.update = textUpdate object.draw = textDraw object:update() diff --git a/Libraries/Paths.lua b/Libraries/Paths.lua index 280632bc..fe77ca04 100755 --- a/Libraries/Paths.lua +++ b/Libraries/Paths.lua @@ -23,7 +23,7 @@ paths.system.applicationPictureEdit = paths.system.applications .. "Picture Edit paths.system.applicationSettings = paths.system.applications .. "Settings.app/Main.lua" paths.system.applicationPrint3D = paths.system.applications .. "3D Print.app/Main.lua" paths.system.applicationConsole = paths.system.applications .. "Console.app/Main.lua" -paths.system.applicationViewer = paths.system.applications .. "Viewer.app/Main.lua" +paths.system.applicationPictureView = paths.system.applications .. "Picture View.app/Main.lua" -------------------------------------------------------------------------------- diff --git a/Libraries/System.lua b/Libraries/System.lua index c60876d9..ff4abed8 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -131,7 +131,7 @@ function system.getDefaultUserSettings() [".cfg"] = filesystem.path(paths.system.applicationMineCodeIDE), [".txt"] = filesystem.path(paths.system.applicationMineCodeIDE), [".lang"] = filesystem.path(paths.system.applicationMineCodeIDE), - [".pic"] = filesystem.path(paths.system.applicationViewer), + [".pic"] = filesystem.path(paths.system.applicationPictureView), [".3dm"] = paths.system.applications .. "3D Print.app/" }, } From 72409f76bfa0fcc13623ef314a9fc7ebe79de939 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Wed, 25 Aug 2021 04:04:09 +0700 Subject: [PATCH 08/18] =?UTF-8?q?=D0=91=D0=BB=D1=8F=D0=B4=D1=8C!=20=D0=9A?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BD=D0=BE=D0=B5=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8E=20=D0=BF=D0=BE=20=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=D1=83=20=D0=B2=D0=B0=D1=89=D0=B5=20=D0=B7=D0=B0=D0=B1=D1=8B?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=B5=D1=89=D0=B5=20=D0=BD=D0=B0=20=D1=8D=D1=82?= =?UTF-8?q?=D0=B0=D0=BF=D0=B5=20=D0=B3=D0=BE=D0=B2=D0=BD=D0=BE=D1=8D=D0=B4?= =?UTF-8?q?=D0=B8=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Installer/Files.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Installer/Files.cfg b/Installer/Files.cfg index 1a2da751..1717b749 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -134,6 +134,7 @@ "Applications/Picture Edit.app/Localizations/English.lang", "Applications/Picture Edit.app/Localizations/Russian.lang", "Applications/Picture Edit.app/Extensions/.pic/Icon.pic", + "Applications/Picture Edit.app/Extensions/.pic/Context menu.pic", -- Picture View { path="Applications/Picture View.app/Main.lua" }, "Applications/Picture View.app/Icon.pic", @@ -144,6 +145,7 @@ "Applications/Picture View.app/Localizations/English.lang", "Applications/Picture View.app/Localizations/Russian.lang", "Applications/Picture View.app/Extensions/.pic/Icon.pic", + "Applications/Picture View.app/Extensions/.pic/Context menu.pic", -- Finder { path="Applications/Finder.app/Main.lua", id=175 }, "Applications/Finder.app/Icon.pic", From 5d9db7b9f8aea572e7ed0c54360d1b4dc9c6571a Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Wed, 25 Aug 2021 13:54:18 +0700 Subject: [PATCH 09/18] =?UTF-8?q?=D0=A7=D0=B5=20=D1=8D=D1=82=20=D1=82?= =?UTF-8?q?=D1=83=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/Picture View.app/Main.lua | 77 ++++++++++++++------------ 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/Applications/Picture View.app/Main.lua b/Applications/Picture View.app/Main.lua index 8e647f2c..2d58d7ae 100644 --- a/Applications/Picture View.app/Main.lua +++ b/Applications/Picture View.app/Main.lua @@ -12,7 +12,7 @@ local args, options = system.parseArguments(...) local iconsPath = fs.path(system.getCurrentScript()) .. "Icons/" local currentDir, files = ((options.o or options.open) and args[1] and fs.exists(args[1])) and fs.path(args[1]) or paths.system.pictures local fileIndex = 1 -local loadedImage +local loadedImage, title -------------------------------------------------------------------------------- @@ -21,45 +21,56 @@ local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 80, 25, local imageObject = window:addChild(GUI.object(1, 1, 1, 1)) imageObject.draw = function() + local halfX, halfY = imageObject.x + imageObject.width / 2, imageObject.y + imageObject.height / 2 + if loadedImage then screen.drawImage( - math.floor(window.x + window.width / 2 - loadedImage[1] / 2), - math.floor(window.y + window.height / 2 - loadedImage[2] / 2), + math.floor(halfX - loadedImage[1] / 2), + math.floor(halfY - loadedImage[2] / 2), loadedImage ) - end + + if title then + screen.drawText(math.floor(halfX - unicode.len(title) / 2), imageObject.y + 1, 0xFFFFFF, title, 0.5) + end + elseif #files == 0 then + screen.drawText(math.floor(halfX - unicode.len(localization.noPictures) / 2), math.floor(halfY), 0x5A5A5A, localization.noPictures) + end end window.actionButtons:moveToFront() -local title = window:addChild(GUI.text(1, 2, 0xFFFFFF, " ", 0.5)) local panel = window:addChild(GUI.panel(1, 1, 1, 6, 0x000000, 0.5)) local panelContainer = window:addChild(GUI.container(1, 1, 1, panel.height)) local slideShowDelay, slideShowDeadline +local function updateTitle() + if panel.hidden then + title = nil + else + title = fs.name(files[fileIndex]) + end +end + local function setUIHidden(state) panel.hidden = state panelContainer.hidden = state window.actionButtons.hidden = state - title.hidden = state + + updateTitle() end local function updateSlideshowDeadline() slideShowDeadline = computer.uptime() + slideShowDelay end -local function updateTitlePosition() - title.localX = math.floor(window.width / 2 - unicode.len(title.text) / 2) -end - local function loadImage() local result, reason = image.load(files[fileIndex]) if result then - title.text = fs.name(files[fileIndex]) - updateTitlePosition() - loadedImage = result + + updateTitle() else GUI.alert(reason) window:remove() @@ -166,8 +177,6 @@ window.onResize = function(newWidth, newHeight) imageObject.width, imageObject.height = newWidth, newHeight panel.width, panel.localY = newWidth, newHeight - 5 panelContainer.localX, panelContainer.localY = math.floor(newWidth / 2 - panelContainer.width / 2), panel.localY - - updateTitlePosition() end local overrideWindowEventHandler = window.eventHandler @@ -200,32 +209,28 @@ window.onResize(window.width, window.height) files = fs.list(currentDir) +local i, extension = 1 +while i <= #files do + extension = fs.extension(files[i]) + + if extension and extension:lower() == ".pic" then + files[i] = currentDir .. files[i] + + if args and args[1] == files[i] then + fileIndex = i + end + + i = i + 1 + else + table.remove(files, i) + end +end + if #files == 0 then - layout:addChild(GUI.text(1, 1, 0x4B4B4B, localization.noPictures)) panel.hidden = true panelContainer.hidden = true - hsPanel.disabled = true - flScreen.disabled = true else - local i, extension = 1 - while i <= #files do - extension = fs.extension(files[i]) - - if extension and extension:lower() == ".pic" then - files[i] = currentDir .. files[i] - - if args and args[1] == files[i] then - fileIndex = i - end - - i = i + 1 - else - table.remove(files, i) - end - end - loadImage() end - workspace:draw() From f7f9e3c181b164bbb74609626458c50e51a78b77 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Wed, 25 Aug 2021 15:57:01 +0700 Subject: [PATCH 10/18] =?UTF-8?q?=D0=BA=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Installer/Files.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Installer/Files.cfg b/Installer/Files.cfg index 1717b749..c5c5ded6 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -134,7 +134,7 @@ "Applications/Picture Edit.app/Localizations/English.lang", "Applications/Picture Edit.app/Localizations/Russian.lang", "Applications/Picture Edit.app/Extensions/.pic/Icon.pic", - "Applications/Picture Edit.app/Extensions/.pic/Context menu.pic", + "Applications/Picture Edit.app/Extensions/.pic/Context menu.lua", -- Picture View { path="Applications/Picture View.app/Main.lua" }, "Applications/Picture View.app/Icon.pic", @@ -145,7 +145,7 @@ "Applications/Picture View.app/Localizations/English.lang", "Applications/Picture View.app/Localizations/Russian.lang", "Applications/Picture View.app/Extensions/.pic/Icon.pic", - "Applications/Picture View.app/Extensions/.pic/Context menu.pic", + "Applications/Picture View.app/Extensions/.pic/Context menu.lua", -- Finder { path="Applications/Finder.app/Main.lua", id=175 }, "Applications/Finder.app/Icon.pic", From b50fbd9703e3fb891a61ee4ce4dfad2c5c69a387 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Fri, 27 Aug 2021 20:09:55 +0700 Subject: [PATCH 11/18] New application in /Applications/ dir fix --- Libraries/System.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Libraries/System.lua b/Libraries/System.lua index ff4abed8..695bdc4f 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -1361,10 +1361,11 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...) if e1 == "touch" then if #container.input.text > 0 then local path = iconField.path .. container.input.text .. ".app/" + if checkFileToExists(container, path) then - system.copy({ paths.system.applicationSample }, iconField.path) - filesystem.rename(iconField.path .. filesystem.name(paths.system.applicationSample), path) - + system.copy({ paths.system.applicationSample }, paths.system.temporary) + filesystem.rename(paths.system.temporary .. filesystem.name(paths.system.applicationSample), path) + container:remove() iconFieldSaveIconPosition(iconField, container.input.text .. ".app/", e3, e4) computer.pushSignal("system", "updateFileList") From b550d7351af04b68df9c1e144c01d026f191fe1d Mon Sep 17 00:00:00 2001 From: Bs0Dd Date: Thu, 2 Sep 2021 22:16:33 +0600 Subject: [PATCH 12/18] Calendar, hah --- Applications/Calendar.app/Icon.pic | Bin 0 -> 175 bytes Applications/Calendar.app/Icons/ArrowLeft.pic | Bin 0 -> 75 bytes .../Calendar.app/Icons/ArrowLeftBlack.pic | Bin 0 -> 75 bytes .../Calendar.app/Icons/ArrowRight.pic | Bin 0 -> 75 bytes .../Calendar.app/Icons/ArrowRightBlack.pic | Bin 0 -> 75 bytes .../Calendar.app/Localizations/English.lang | 21 ++ .../Calendar.app/Localizations/Russian.lang | 21 ++ Applications/Calendar.app/Main.lua | 217 ++++++++++++++++++ Installer/Files.cfg | 9 + 9 files changed, 268 insertions(+) create mode 100644 Applications/Calendar.app/Icon.pic create mode 100644 Applications/Calendar.app/Icons/ArrowLeft.pic create mode 100644 Applications/Calendar.app/Icons/ArrowLeftBlack.pic create mode 100644 Applications/Calendar.app/Icons/ArrowRight.pic create mode 100644 Applications/Calendar.app/Icons/ArrowRightBlack.pic create mode 100644 Applications/Calendar.app/Localizations/English.lang create mode 100644 Applications/Calendar.app/Localizations/Russian.lang create mode 100644 Applications/Calendar.app/Main.lua diff --git a/Applications/Calendar.app/Icon.pic b/Applications/Calendar.app/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..020a44ae0766ad029809c1b6cf5320a864d76ce7 GIT binary patch literal 175 zcmXZWyA1+C3 literal 0 HcmV?d00001 diff --git a/Applications/Calendar.app/Icons/ArrowLeft.pic b/Applications/Calendar.app/Icons/ArrowLeft.pic new file mode 100644 index 0000000000000000000000000000000000000000..68fc39eac8ed76b38b87a6b78ec002655dd5139a GIT binary patch literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=9SqD2Opg}M0W%qa%mp1#QAPzIgMonwD7L5%$k+j7 OGCo?=0A?~WFaiLeY7k`r literal 0 HcmV?d00001 diff --git a/Applications/Calendar.app/Icons/ArrowLeftBlack.pic b/Applications/Calendar.app/Icons/ArrowLeftBlack.pic new file mode 100644 index 0000000000000000000000000000000000000000..965a36ca3657598c505d34fdc577f615fd795d95 GIT binary patch literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=PzGiOrbi3sfSHUy=7J8WD5C<9!N9--6kF5>WP}2l NjE@#IfSHU8i~wQ84t4+l literal 0 HcmV?d00001 diff --git a/Applications/Calendar.app/Icons/ArrowRight.pic b/Applications/Calendar.app/Icons/ArrowRight.pic new file mode 100644 index 0000000000000000000000000000000000000000..71673044e7e69df97e1565551e56ebbddebf3d7d GIT binary patch literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=9Sn>NjE@%10W+CF%#C0s69dzug$+;zObS2-0|OIK OdO;(Qv4eq`fe8S-We|S= literal 0 HcmV?d00001 diff --git a/Applications/Calendar.app/Icons/ArrowRightBlack.pic b/Applications/Calendar.app/Icons/ArrowRightBlack.pic new file mode 100644 index 0000000000000000000000000000000000000000..c1459dcbada62da6a437ab61c4aedde17bd8bfd1 GIT binary patch literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=PzFW@#zzb1fSJr7=0-4+iGk_S!Um`UCIujafq@Aq Oy`T}u2xVYqU;+SoL=KPu literal 0 HcmV?d00001 diff --git a/Applications/Calendar.app/Localizations/English.lang b/Applications/Calendar.app/Localizations/English.lang new file mode 100644 index 00000000..3f89aab8 --- /dev/null +++ b/Applications/Calendar.app/Localizations/English.lang @@ -0,0 +1,21 @@ +{ + weekLine = "Mo Tu We Th Fr Sa Su", + weekLineAlt = "Su Mo Tu We Th Fr Sa", + months = { + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + }, + startWeek = "Start week from ", + monday = "Monday", + sunday = "Sunday" +} diff --git a/Applications/Calendar.app/Localizations/Russian.lang b/Applications/Calendar.app/Localizations/Russian.lang new file mode 100644 index 00000000..5c9fa81e --- /dev/null +++ b/Applications/Calendar.app/Localizations/Russian.lang @@ -0,0 +1,21 @@ +{ + weekLine = "Пн Вт Ср Чт Пт Сб Вс", + weekLineAlt = "Вс Пн Вт Ср Чт Пт Сб", + months = { + "Январь", + "Февраль", + "Март", + "Апрель", + "Май", + "Июнь", + "Июль", + "Август", + "Сентябрь", + "Октябрь", + "Ноябрь", + "Декабрь", + }, + startWeek = "Начинать неделю с ", + monday = "Понедельника", + sunday = "Воскресенья" +} diff --git a/Applications/Calendar.app/Main.lua b/Applications/Calendar.app/Main.lua new file mode 100644 index 00000000..e7454eca --- /dev/null +++ b/Applications/Calendar.app/Main.lua @@ -0,0 +1,217 @@ +local GUI = require("GUI") +local system = require("System") +local bigLetters = require("BigLetters") +local screen = require("Screen") +local image = require("Image") +local fs = require("Filesystem") + + +local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 42, 24, 0xFFFFFF)) +window.actionButtons.localY = 1 + +local localization = system.getCurrentScriptLocalization() +local iconsPath = fs.path(system.getCurrentScript()) .. "Icons/" +local isWeekAlt = false + +local countOfDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} +local monthDateMove = {3, 2, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3} +local lastCountedYear = 0 +local comMonthMem +local curYearList + +local function isLeap(year) + if year % 4 == 0 or year % 400 == 0 then return true else return false end +end + +local function getNextDay(day) + return day < 7 and day + 1 or 1 +end + +local function calculateYear(year, fstDayPos) + local yearList = {} + local leap = isLeap(year) + + for month = 1, 12 do + yearList[month] = {} + + if month == 2 then + if leap then + yearList[month].countOfDays = 29 + yearList[month].fstDayPos = fstDayPos + fstDayPos = getNextDay(fstDayPos) + else + yearList[month].countOfDays = 28 + yearList[month].fstDayPos = fstDayPos + end + else + yearList[month].countOfDays = countOfDays[month] + yearList[month].fstDayPos = fstDayPos + for i = 1, monthDateMove[month] do + fstDayPos = getNextDay(fstDayPos) + end + end + end + + return yearList +end + +local function fstJanPos(year) + local day = 0 + + local difference = math.abs(year - 1010) + local leapCount + + if difference % 4 == 0 then + leapCount = difference / 4 + elseif difference % 4 == 1 or difference % 4 == 2 then + leapCount = math.floor(difference / 4) + elseif difference % 4 == 3 then + leapCount = math.floor(difference / 4) + 1 + end + + local offset = difference + leapCount + + if offset % 7 == 0 then + day = 1 + else + day = offset % 7 + 1 + end + + return day +end + +local function makeIconButton(x, y, parentObj, icon, onTouch) + local obj = GUI.image(x, y, image.load(iconsPath .. icon .. ".pic")) + parentObj:addChild(obj).eventHandler = function(_, _, event) + if event == "touch" then + onTouch() + end + end + return obj +end + +local currentStamp = os.date("*t", system.getTime()) +local currentYear, currentMonth, currentDay = currentStamp.year, currentStamp.month, currentStamp.day +local selectedYear, selectedMonth = currentYear, currentMonth + +local function renderYear(object) + local text = tostring(selectedYear) + local width = bigLetters.getTextSize(text) + bigLetters.drawText(math.floor(object.x + object.width / 2 - width / 2), object.y, 0x000000, text) +end + +local year = window:addChild(GUI.object(8, 3, 28, 5)) +year.draw = function(object) + renderYear(object) +end + + +local function renderMonth(xCoord, yCoord, width, monthPos) + local text = localization.months[monthPos] + local weekText = isWeekAlt and localization.weekLineAlt or localization.weekLine + local xStart = math.floor(xCoord + width / 2 - unicode.len(weekText) / 2) + screen.drawText(math.floor(xCoord + width / 2 - unicode.len(text) / 2), yCoord, 0xFF0000, text) + screen.drawText(xStart, yCoord + 2, 0x888888, weekText) + if not curYearList or selectedYear ~= lastCountedYear then + curYearList = calculateYear(selectedYear, fstJanPos(selectedYear)) + end + + local counter, line = curYearList[monthPos].fstDayPos - 1, 4 + if isWeekAlt then + counter = counter + 1 == 7 and 0 or counter + 1 + end + for i=1, curYearList[monthPos].countOfDays do + local numColor = (isWeekAlt and (counter == 0 or counter == 6) and 0xFF0000) or (not isWeekAlt and counter > 4 and 0xFF0000) or 0x262626 + if selectedYear == currentYear and monthPos == currentMonth and i == currentDay then + screen.drawText(xStart + (counter * 4) - 1, yCoord + line - 1, 0xC3C3C3, '⢀▄▄⡀') + screen.drawRectangle(xStart + (counter * 4) - 1, yCoord + line, 4, 1, 0xC3C3C3, 0x000000, ' ') + screen.drawText(xStart + (counter * 4) - 1, yCoord + line + 1, 0xC3C3C3, '⠈▀▀⠁') + end + screen.drawText(xStart + (counter * 4), yCoord + line, numColor, (i < 10 and ' ' or '')..tostring(i)) + counter = counter == 6 and 0 or counter + 1 + if counter == 0 then line = line + 2 end + end +end + +local month = window:addChild(GUI.object(9, 9, 26, 15)) +month.draw = function(object) + renderMonth(object.x, object.y, object.width, selectedMonth) +end + + +local function prevYear() + selectedYear = selectedYear == 0 and selectedYear or selectedYear - 1 + workspace:draw() +end + +local function nextYear() + selectedYear = selectedYear == 9999 and selectedYear or selectedYear + 1 + workspace:draw() +end + +local arrowLeftBlack = makeIconButton(3, 4, window, "ArrowLeftBlack", prevYear) + +local arrowRightBlack = makeIconButton(39, 4, window, "ArrowRightBlack", nextYear) + + +local function prevMonth() + selectedMonth = selectedMonth - 1 + if selectedMonth < 1 then if selectedYear - 1 ~= -1 then selectedMonth = 12 prevYear() else selectedMonth = 1 end + else workspace:draw() end +end + +local function nextMonth() + selectedMonth = selectedMonth + 1 + if selectedMonth > 12 then if selectedYear + 1 ~= 10000 then selectedMonth = 1 nextYear() else selectedMonth = 12 end + else workspace:draw() end +end + + +local arrowLeft = makeIconButton(3, 15, window, "ArrowLeft", prevMonth) + +local arrowRight = makeIconButton(39, 15, window, "ArrowRight", nextMonth) + + +local weekType = menu:addItem(localization.startWeek..localization.sunday) +weekType.onTouch = function() + isWeekAlt = not isWeekAlt + weekType.text = isWeekAlt and localization.startWeek..localization.monday or localization.startWeek..localization.sunday +end + + +window.actionButtons.maximize.onTouch = function() + if not window.maximized then + year.localX, year.localY = 130, 3 + arrowLeftBlack.localX, arrowLeftBlack.localY = 129, 9 + arrowRightBlack.localX, arrowRightBlack.localY = 157, 9 + month.localX, month.localY = 3, 2 + comMonthMem = selectedMonth + selectedMonth = 1 + local mx, my = 35, 2 + for i=2, 12 do + local newMonth = window:addChild(GUI.object(mx, my, 26, 15)) + newMonth.draw = function(object) + renderMonth(object.x, object.y, object.width, i) + end + mx = mx + 32 == 131 and 3 or mx + 32 + if mx == 3 then my = my + 16 end + end + else + year.localX, year.localY = 8, 3 + arrowLeftBlack.localX, arrowLeftBlack.localY = 3, 4 + arrowRightBlack.localX, arrowRightBlack.localY = 39, 4 + month.localX, month.localY = 9, 9 + selectedMonth = comMonthMem + window:removeChildren(9) + end + window:maximize() + arrowLeft.hidden = not arrowLeft.hidden + arrowRight.hidden = not arrowRight.hidden +end + + +window.onResize = function(newWidth, newHeight) + window.backgroundPanel.width, window.backgroundPanel.height = newWidth, newHeight +end + +workspace:draw() diff --git a/Installer/Files.cfg b/Installer/Files.cfg index c5c5ded6..b4380ac0 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -182,6 +182,15 @@ "Applications/Settings.app/Localizations/Italian.lang", "Applications/Settings.app/Localizations/Japanese.lang", "Applications/Settings.app/Localizations/Dutch.lang", + -- Calendar + { path="Applications/Calendar.app/Main.lua", shortcut = true }, + "Applications/Calendar.app/Icon.pic", + "Applications/Calendar.app/Icons/ArrowLeft.pic", + "Applications/Calendar.app/Icons/ArrowRight.pic", + "Applications/Calendar.app/Icons/ArrowLeftBlack.pic", + "Applications/Calendar.app/Icons/ArrowRightBlack.pic", + "Applications/Calendar.app/Localizations/English.lang", + "Applications/Calendar.app/Localizations/Russian.lang", -- 3D Print { path="Applications/3D Print.app/Main.lua", id=859, shortcut = true }, "Applications/3D Print.app/Icon.pic", From b138a825909086b5fa3ad604519d31147dee8513 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Fri, 3 Sep 2021 00:25:37 +0700 Subject: [PATCH 13/18] Spasibo! --- Applications/Calendar.app/Icon.pic | Bin 175 -> 186 bytes Applications/Calendar.app/Icons/ArrowLeft.pic | Bin 75 -> 75 bytes .../Calendar.app/Icons/ArrowRight.pic | Bin 75 -> 75 bytes Applications/Calendar.app/Main.lua | 98 ++++++++++++------ 4 files changed, 69 insertions(+), 29 deletions(-) diff --git a/Applications/Calendar.app/Icon.pic b/Applications/Calendar.app/Icon.pic index 020a44ae0766ad029809c1b6cf5320a864d76ce7..d50467ae9c30021574e2a1cd11b339e3e51a08a6 100644 GIT binary patch literal 186 zcmXwxyA1+C3`EDDJv*QXS^&hs#U~*_LUJvTl2H&eLMIzsBa5{%iTyP5?E8GZm@75V z`u+lFQ26@!BLSNyYQ%(cid7-7bHEa!ObO+djvTtfuw$$eQqCzKx!P$VG$ literal 175 zcmXZWyA1+C3 diff --git a/Applications/Calendar.app/Icons/ArrowLeft.pic b/Applications/Calendar.app/Icons/ArrowLeft.pic index 68fc39eac8ed76b38b87a6b78ec002655dd5139a..ce0cfdf41c1a40e227a29f5ca25a604777d1d8ae 100644 GIT binary patch literal 75 zcmeZw_H<)sVrKZy!1`!WACS7nz{J4#XwhOYlbM0((ZV@kCL@r!paUw(r~p;T^k`87 HRGJY0o`x68 literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=9SqD2Opg}M0W%qa%mp1#QAPzIgMonwD7L5%$k+j7 OGCo?=0A?~WFaiLeY7k`r diff --git a/Applications/Calendar.app/Icons/ArrowRight.pic b/Applications/Calendar.app/Icons/ArrowRight.pic index 71673044e7e69df97e1565551e56ebbddebf3d7d..20aaac1f87fe17439231265cf302358be2de5156 100644 GIT binary patch literal 75 zcmeZw_H<)sVrKZy!1`#>Vjy*mfsujn(ZV@kCNq$^pb^SsQUEiUK++qbOr}Q*8^BCP G1||TLVi)BA literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=9Sn>NjE@%10W+CF%#C0s69dzug$+;zObS2-0|OIK OdO;(Qv4eq`fe8S-We|S= diff --git a/Applications/Calendar.app/Main.lua b/Applications/Calendar.app/Main.lua index e7454eca..5527998a 100644 --- a/Applications/Calendar.app/Main.lua +++ b/Applications/Calendar.app/Main.lua @@ -3,15 +3,21 @@ local system = require("System") local bigLetters = require("BigLetters") local screen = require("Screen") local image = require("Image") +local paths = require("paths") local fs = require("Filesystem") +--------------------------------------------------------------------------------------- -local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 42, 24, 0xFFFFFF)) -window.actionButtons.localY = 1 +local currentScriptPath = fs.path(system.getCurrentScript()) +local localization = system.getLocalization(currentScriptPath .. "Localizations/") -local localization = system.getCurrentScriptLocalization() -local iconsPath = fs.path(system.getCurrentScript()) .. "Icons/" -local isWeekAlt = false +local arrowLeftIcon = image.load(currentScriptPath .. "Icons/ArrowLeft.pic") +local arrowRightIcon = image.load(currentScriptPath .. "Icons/ArrowRight.pic") + +local configPath = paths.user.applicationData .. "Calendar/Config.cfg" +local config = fs.exists(configPath) and fs.readTable(configPath) or { + isWeekAlt = false +} local countOfDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} local monthDateMove = {3, 2, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3} @@ -19,6 +25,11 @@ local lastCountedYear = 0 local comMonthMem local curYearList +--------------------------------------------------------------------------------------- + +local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 42, 24, 0xFFFFFF)) +window.actionButtons.localY = 1 + local function isLeap(year) if year % 4 == 0 or year % 400 == 0 then return true else return false end end @@ -80,13 +91,15 @@ local function fstJanPos(year) return day end -local function makeIconButton(x, y, parentObj, icon, onTouch) - local obj = GUI.image(x, y, image.load(iconsPath .. icon .. ".pic")) +local function makeIconButton(x, y, parentObj, right, onTouch) + local obj = GUI.image(x, y, right and arrowRightIcon or arrowLeftIcon) + parentObj:addChild(obj).eventHandler = function(_, _, event) if event == "touch" then onTouch() end end + return obj end @@ -108,25 +121,31 @@ end local function renderMonth(xCoord, yCoord, width, monthPos) local text = localization.months[monthPos] - local weekText = isWeekAlt and localization.weekLineAlt or localization.weekLine + local weekText = config.isWeekAlt and localization.weekLineAlt or localization.weekLine local xStart = math.floor(xCoord + width / 2 - unicode.len(weekText) / 2) + screen.drawText(math.floor(xCoord + width / 2 - unicode.len(text) / 2), yCoord, 0xFF0000, text) screen.drawText(xStart, yCoord + 2, 0x888888, weekText) + if not curYearList or selectedYear ~= lastCountedYear then curYearList = calculateYear(selectedYear, fstJanPos(selectedYear)) end local counter, line = curYearList[monthPos].fstDayPos - 1, 4 - if isWeekAlt then + + if config.isWeekAlt then counter = counter + 1 == 7 and 0 or counter + 1 end + for i=1, curYearList[monthPos].countOfDays do - local numColor = (isWeekAlt and (counter == 0 or counter == 6) and 0xFF0000) or (not isWeekAlt and counter > 4 and 0xFF0000) or 0x262626 + local numColor = (config.isWeekAlt and (counter == 0 or counter == 6) and 0xFF0000) or (not config.isWeekAlt and counter > 4 and 0xFF0000) or 0x262626 + if selectedYear == currentYear and monthPos == currentMonth and i == currentDay then - screen.drawText(xStart + (counter * 4) - 1, yCoord + line - 1, 0xC3C3C3, '⢀▄▄⡀') - screen.drawRectangle(xStart + (counter * 4) - 1, yCoord + line, 4, 1, 0xC3C3C3, 0x000000, ' ') - screen.drawText(xStart + (counter * 4) - 1, yCoord + line + 1, 0xC3C3C3, '⠈▀▀⠁') + screen.drawText(xStart + (counter * 4) - 1, yCoord + line - 1, 0xD2D2D2, '⢀▄▄⡀') + screen.drawRectangle(xStart + (counter * 4) - 1, yCoord + line, 4, 1, 0xD2D2D2, 0x000000, ' ') + screen.drawText(xStart + (counter * 4) - 1, yCoord + line + 1, 0xD2D2D2, '⠈▀▀⠁') end + screen.drawText(xStart + (counter * 4), yCoord + line, numColor, (i < 10 and ' ' or '')..tostring(i)) counter = counter == 6 and 0 or counter + 1 if counter == 0 then line = line + 2 end @@ -149,35 +168,49 @@ local function nextYear() workspace:draw() end -local arrowLeftBlack = makeIconButton(3, 4, window, "ArrowLeftBlack", prevYear) - -local arrowRightBlack = makeIconButton(39, 4, window, "ArrowRightBlack", nextYear) - +local arrowLeftBlack = makeIconButton(3, 4, window, false, prevYear) +local arrowRightBlack = makeIconButton(39, 4, window, true, nextYear) local function prevMonth() selectedMonth = selectedMonth - 1 - if selectedMonth < 1 then if selectedYear - 1 ~= -1 then selectedMonth = 12 prevYear() else selectedMonth = 1 end - else workspace:draw() end + + if selectedMonth < 1 then + if selectedYear - 1 ~= -1 then + selectedMonth = 12 + prevYear() + else + selectedMonth = 1 + end + else + workspace:draw() + end end local function nextMonth() selectedMonth = selectedMonth + 1 - if selectedMonth > 12 then if selectedYear + 1 ~= 10000 then selectedMonth = 1 nextYear() else selectedMonth = 12 end - else workspace:draw() end + + if selectedMonth > 12 then + if selectedYear + 1 ~= 10000 then + selectedMonth = 1 + nextYear() + else + selectedMonth = 12 + end + else + workspace:draw() + end end - -local arrowLeft = makeIconButton(3, 15, window, "ArrowLeft", prevMonth) - -local arrowRight = makeIconButton(39, 15, window, "ArrowRight", nextMonth) - +local arrowLeft = makeIconButton(3, 15, window, false, prevMonth) +local arrowRight = makeIconButton(39, 15, window, true, nextMonth) local weekType = menu:addItem(localization.startWeek..localization.sunday) weekType.onTouch = function() - isWeekAlt = not isWeekAlt - weekType.text = isWeekAlt and localization.startWeek..localization.monday or localization.startWeek..localization.sunday -end + config.isWeekAlt = not config.isWeekAlt + weekType.text = config.isWeekAlt and localization.startWeek..localization.monday or localization.startWeek..localization.sunday + fs.writeTable(configPath, config) +end window.actionButtons.maximize.onTouch = function() if not window.maximized then @@ -187,13 +220,18 @@ window.actionButtons.maximize.onTouch = function() month.localX, month.localY = 3, 2 comMonthMem = selectedMonth selectedMonth = 1 + local mx, my = 35, 2 + for i=2, 12 do local newMonth = window:addChild(GUI.object(mx, my, 26, 15)) + newMonth.draw = function(object) renderMonth(object.x, object.y, object.width, i) end + mx = mx + 32 == 131 and 3 or mx + 32 + if mx == 3 then my = my + 16 end end else @@ -204,7 +242,9 @@ window.actionButtons.maximize.onTouch = function() selectedMonth = comMonthMem window:removeChildren(9) end + window:maximize() + arrowLeft.hidden = not arrowLeft.hidden arrowRight.hidden = not arrowRight.hidden end From e6287bc31bea552329f2153957a7e1338e5db476 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Fri, 3 Sep 2021 00:26:10 +0700 Subject: [PATCH 14/18] Spasibo! --- Applications/Calendar.app/Icons/ArrowLeftBlack.pic | Bin 75 -> 0 bytes .../Calendar.app/Icons/ArrowRightBlack.pic | Bin 75 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Applications/Calendar.app/Icons/ArrowLeftBlack.pic delete mode 100644 Applications/Calendar.app/Icons/ArrowRightBlack.pic diff --git a/Applications/Calendar.app/Icons/ArrowLeftBlack.pic b/Applications/Calendar.app/Icons/ArrowLeftBlack.pic deleted file mode 100644 index 965a36ca3657598c505d34fdc577f615fd795d95..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=PzGiOrbi3sfSHUy=7J8WD5C<9!N9--6kF5>WP}2l NjE@#IfSHU8i~wQ84t4+l diff --git a/Applications/Calendar.app/Icons/ArrowRightBlack.pic b/Applications/Calendar.app/Icons/ArrowRightBlack.pic deleted file mode 100644 index c1459dcbada62da6a437ab61c4aedde17bd8bfd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 75 zcmeZw_H<)sVrKZy!1`#>Vg?3=PzFW@#zzb1fSJr7=0-4+iGk_S!Um`UCIujafq@Aq Oy`T}u2xVYqU;+SoL=KPu From f1c7f3efe8710b55459ec24f88c05a201f943516 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Fri, 3 Sep 2021 00:26:31 +0700 Subject: [PATCH 15/18] Spasibo! --- Installer/Files.cfg | 2 -- 1 file changed, 2 deletions(-) diff --git a/Installer/Files.cfg b/Installer/Files.cfg index b4380ac0..a8f06898 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -187,8 +187,6 @@ "Applications/Calendar.app/Icon.pic", "Applications/Calendar.app/Icons/ArrowLeft.pic", "Applications/Calendar.app/Icons/ArrowRight.pic", - "Applications/Calendar.app/Icons/ArrowLeftBlack.pic", - "Applications/Calendar.app/Icons/ArrowRightBlack.pic", "Applications/Calendar.app/Localizations/English.lang", "Applications/Calendar.app/Localizations/Russian.lang", -- 3D Print From ae18379ca8ab5fad80bf6e26ccd2ab5568ff59ea Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Sat, 4 Sep 2021 19:44:52 +0700 Subject: [PATCH 16/18] Added OCIF8 image format support & fixed HEX editor app --- Applications/App Market.app/Main.lua | 2 +- Applications/HEX.app/Main.lua | 72 +++++++++++++++----------- Applications/Picture Edit.app/Main.lua | 2 +- Installer/Files.cfg | 18 +++---- Libraries/Color.lua | 13 +++++ Libraries/GUI.lua | 16 +++++- Libraries/Image.lua | 53 +++++++++++-------- 7 files changed, 111 insertions(+), 65 deletions(-) diff --git a/Applications/App Market.app/Main.lua b/Applications/App Market.app/Main.lua index 19caa8a0..4e3ae519 100644 --- a/Applications/App Market.app/Main.lua +++ b/Applications/App Market.app/Main.lua @@ -241,7 +241,7 @@ local function checkImage(url, mneTolkoSprosit) if data:sub(1, 4) == "OCIF" then local encodingMethod = string.byte(data:sub(5, 5)) - if encodingMethod == 6 or encodingMethod == 7 then + if encodingMethod >= 6 or encodingMethod <= 8 then if string.byte(data:sub(6, 6)) == 8 and string.byte(data:sub(7, 7)) == 4 then if mneTolkoSprosit then handle:close() diff --git a/Applications/HEX.app/Main.lua b/Applications/HEX.app/Main.lua index f7a1810c..bb5ddd4d 100755 --- a/Applications/HEX.app/Main.lua +++ b/Applications/HEX.app/Main.lua @@ -1,13 +1,18 @@ local text = require("Text") -local number = require("Number") local filesystem = require("Filesystem") local GUI = require("GUI") local screen = require("Screen") local system = require("System") +local paths = require("Paths") ------------------------------------------------------------------------------------------------------------------ +local configPath = paths.user.applicationData .. "HEX Editor/Config.cfg" +local config = filesystem.exists(configPath) and filesystem.readTable(configPath) or { + recentPath = "/OS.lua" +} + local colors = { background = 0xF0F0F0, backgroundText = 0x555555, @@ -39,8 +44,13 @@ local scrollBar, titleTextBox local workspace, window = system.addWindow(GUI.filledWindow(1, 1, 98, 25, colors.background)) +window.maxWidth = window.width +window.showDesktopOnMaximize = true + window.backgroundPanel.localX, window.backgroundPanel.localY = 11, 5 -window.backgroundPanel.width, window.backgroundPanel.height = window.width - 10, window.height - 4 +window.backgroundPanel.width = window.width - 10 + +window.actionButtons.localY = 2 local function byteArrayToNumber(b) local n = 0 @@ -204,8 +214,8 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5) end end -local function newByteField(x, y, width, height, elementWidth, elementHeight, asChar) - local object = GUI.object(x, y, width, height) +local function newByteField(x, y, width, elementWidth, elementHeight, asChar) + local object = GUI.object(x, y, width, 1) object.elementWidth = elementWidth object.elementHeight = elementHeight @@ -221,20 +231,19 @@ end window:addChild(GUI.panel(1, 1, window.width, 3, 0x3C3C3C)):moveToBack() -local byteField = window:addChild(newByteField(13, 6, 64, 20, 4, 2, false)) -local charField = window:addChild(newByteField(byteField.localX + byteField.width + 3, 6, 16, 20, 1, 2, true)) -local separator = window:addChild(GUI.object(byteField.localX + byteField.width, 5, 1, 21)) +local byteField = window:addChild(newByteField(13, 6, 64, 4, 2, false)) +local charField = window:addChild(newByteField(byteField.localX + byteField.width + 3, 6, 16, 1, 2, true)) +local separator = window:addChild(GUI.object(byteField.localX + byteField.width, 5, 1, 1)) separator.draw = function(object) for i = object.y, object.y + object.height - 1 do screen.drawText(object.x, i, colors.separator, "│") end end - window:addChild(GUI.panel(11, 4, window.width - 10, 1, colors.panel)) -- Vertical -local verticalCounter = window:addChild(GUI.object(1, 4, 10, window.height - 3)) +local verticalCounter = window:addChild(GUI.object(1, 4, 10, 1)) verticalCounter.draw = function(object) screen.drawRectangle(object.x, object.y, object.width, object.height, colors.panel, colors.panelText, " ") @@ -277,12 +286,11 @@ window:addChild(GUI.object(13, 4, 62, 1)).draw = function(object) end end -scrollBar = window:addChild(GUI.scrollBar(window.width, 5, 1, window.height - 4, 0xC3C3C3, 0x393939, 0, 1, 1, 160, 1, true)) +scrollBar = window:addChild(GUI.scrollBar(window.width, 5, 1, 1, 0xC3C3C3, 0x393939, 0, 1, 1, 160, 1, true)) scrollBar.eventHandler = nil titleTextBox = window:addChild( - GUI.textBox( - 1, 1, math.floor(window.width * 0.35), 3, + GUI.textBox(1, 1, math.floor(window.width * 0.35), 3, colors.titleBackground, colors.titleText, { @@ -293,6 +301,7 @@ titleTextBox = window:addChild( 1, 1, 0 ) ) + titleTextBox.localX = math.floor(window.width / 2 - titleTextBox.width / 2) titleTextBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) titleTextBox.eventHandler = nil @@ -307,6 +316,7 @@ local function load(path) if file then bytes = {} + local byte while true do byte = file:readBytes(1) @@ -318,9 +328,11 @@ local function load(path) end file:close() + offset = 0 selection.from, selection.to = 1, 1 scrollBar.value, scrollBar.maximumValue = 0, #bytes + status() else GUI.alert("Failed to open file for reading: " .. tostring(reason)) @@ -329,18 +341,26 @@ end openFileButton.onTouch = function() local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Open", "Cancel", "File name", "/") + filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:show() + filesystemDialog.onSubmit = function(path) load(path) + + config.recentPath = path + filesystem.writeTable(configPath, config) + workspace:draw() end end saveFileButton.onTouch = function() local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Save", "Cancel", "File name", "/") + filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:show() + filesystemDialog.onSubmit = function(path) local file = filesystem.open(path, "wb") if file then @@ -354,31 +374,21 @@ saveFileButton.onTouch = function() end end -window.actionButtons.localY = 2 -window.actionButtons.maximize.onTouch = function() - window.height = window.parent.height - byteField.height = window.height - 6 +window.onResize = function(width, height) + byteField.height = height - 6 charField.height = byteField.height scrollBar.height = byteField.height - window.backgroundPanel.height = window.height - 4 + window.backgroundPanel.height = height - 4 verticalCounter.height = window.backgroundPanel.height + 1 separator.height = byteField.height + 2 - - window.localY = 1 - - workspace:draw() end ------------------------------------------------------------------------------------------------------------------ -load("/OS.lua") +window.onResize(window.width, window.height) + +local args, options = system.parseArguments(...) + +load(((options.o or options.open) and args[1] and filesystem.exists(args[1])) and args[1] or config.recentPath) + workspace:draw() - - - - - - - - - diff --git a/Applications/Picture Edit.app/Main.lua b/Applications/Picture Edit.app/Main.lua index 8c25b5f2..c1df5d78 100644 --- a/Applications/Picture Edit.app/Main.lua +++ b/Applications/Picture Edit.app/Main.lua @@ -315,7 +315,7 @@ end local function save(path) if filesystem.extension(path) == ".pic" then - local result, reason = image.save(path, window.image.data, 7) + local result, reason = image.save(path, window.image.data, 8) if result then setSavePath(path) diff --git a/Installer/Files.cfg b/Installer/Files.cfg index a8f06898..73e22de8 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -182,13 +182,6 @@ "Applications/Settings.app/Localizations/Italian.lang", "Applications/Settings.app/Localizations/Japanese.lang", "Applications/Settings.app/Localizations/Dutch.lang", - -- Calendar - { path="Applications/Calendar.app/Main.lua", shortcut = true }, - "Applications/Calendar.app/Icon.pic", - "Applications/Calendar.app/Icons/ArrowLeft.pic", - "Applications/Calendar.app/Icons/ArrowRight.pic", - "Applications/Calendar.app/Localizations/English.lang", - "Applications/Calendar.app/Localizations/Russian.lang", -- 3D Print { path="Applications/3D Print.app/Main.lua", id=859, shortcut = true }, "Applications/3D Print.app/Icon.pic", @@ -250,8 +243,8 @@ { path="Applications/Graph.app/Main.lua", id=238, shortcut = true }, "Applications/Graph.app/Icon.pic", -- HEX - { path="Applications/HEX.app/Main.lua", id=248, shortcut = true }, - "Applications/HEX.app/Icon.pic", + { path="Applications/HEX Editor.app/Main.lua", id=248, shortcut = true }, + "Applications/HEX Editor.app/Icon.pic", -- Running string { path="Applications/Running String.app/Main.lua", id=410, shortcut = true }, "Applications/Running String.app/Icon.pic", @@ -291,6 +284,13 @@ "Applications/VK.app/Styles/Default.lua", "Applications/VK.app/Styles/Bright.lua", "Applications/VK.app/Styles/Dark.lua", + -- Calendar + { path="Applications/Calendar.app/Main.lua", shortcut = true }, + "Applications/Calendar.app/Icon.pic", + "Applications/Calendar.app/Icons/ArrowLeft.pic", + "Applications/Calendar.app/Icons/ArrowRight.pic", + "Applications/Calendar.app/Localizations/English.lang", + "Applications/Calendar.app/Localizations/Russian.lang", }, wallpapers = { "Pictures/AhsokaTano.pic", diff --git a/Libraries/Color.lua b/Libraries/Color.lua index 31c02008..9f38da65 100755 --- a/Libraries/Color.lua +++ b/Libraries/Color.lua @@ -23,6 +23,7 @@ if computer.getArchitecture and computer.getArchitecture() == "Lua 5.3" then function(color1, color2, transparency) local invertedTransparency = 1 - transparency + return ((color2 >> 16) * invertedTransparency + (color1 >> 16) * transparency) // 1 << 16 | ((color2 >> 8 & 0xFF) * invertedTransparency + (color1 >> 8 & 0xFF) * transparency) // 1 << 8 | @@ -31,6 +32,7 @@ if computer.getArchitecture and computer.getArchitecture() == "Lua 5.3" then function(color1, color2, position) local r1, g1, b1 = color1 >> 16, color1 >> 8 & 0xFF, color1 & 0xFF + return (r1 + ((color2 >> 16) - r1) * position) // 1 << 16 | (g1 + ((color2 >> 8 & 0xFF) - g1) * position) // 1 << 8 | @@ -49,6 +51,7 @@ if computer.getArchitecture and computer.getArchitecture() == "Lua 5.3" then paletteR, paletteG, paletteB = paletteColor >> 16, paletteColor >> 8 & 0xFF, paletteColor & 0xFF delta = (paletteR - r) ^ 2 + (paletteG - g) ^ 2 + (paletteB - b) ^ 2 + if delta < closestDelta then closestDelta, closestIndex = delta, i end @@ -66,6 +69,7 @@ else function(integerColor) local r = integerColor / 65536 r = r - r % 1 + local g = (integerColor - r * 65536) / 256 g = g - g % 1 @@ -81,11 +85,13 @@ else local r1 = color1 / 65536 r1 = r1 - r1 % 1 + local g1 = (color1 - r1 * 65536) / 256 g1 = g1 - g1 % 1 local r2 = color2 / 65536 r2 = r2 - r2 % 1 + local g2 = (color2 - r2 * 65536) / 256 g2 = g2 - g2 % 1 @@ -103,12 +109,15 @@ else function(color1, color2, position) local r1 = color1 / 65536 r1 = r1 - r1 % 1 + local g1 = (color1 - r1 * 65536) / 256 g1 = g1 - g1 % 1 + local b1 = color1 - r1 * 65536 - g1 * 256 local r2 = color2 / 65536 r2 = r2 - r2 % 1 + local g2 = (color2 - r2 * 65536) / 256 g2 = g2 - g2 % 1 @@ -128,12 +137,15 @@ else local r = color24Bit / 65536 r = r - r % 1 + local g = (color24Bit - r * 65536) / 256 g = g - g % 1 + local b = color24Bit - r * 65536 - g * 256 for index = 1, #palette do paletteColor = palette[index] + if color24Bit == paletteColor then return index - 1 else @@ -144,6 +156,7 @@ else paletteB = paletteColor - paletteR * 65536 - paletteG * 256 delta = (paletteR - r) ^ 2 + (paletteG - g) ^ 2 + (paletteB - b) ^ 2 + if delta < closestDelta then closestDelta, closestIndex = delta, index end diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index d38cd011..459b52db 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -4289,6 +4289,7 @@ local function windowCheck(window, x, y) return true elseif child.children then local result = windowCheck(child, x, y) + if result == true then return true elseif result == false then @@ -4313,6 +4314,7 @@ local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...) end elseif e1 == "drag" and window.lastTouchX and not windowCheck(window, e3, e4) then local xOffset, yOffset = e3 - window.lastTouchX, e4 - window.lastTouchY + if xOffset ~= 0 or yOffset ~= 0 then window.localX, window.localY = window.localX + xOffset, window.localY + yOffset window.lastTouchX, window.lastTouchY = e3, e4 @@ -4344,10 +4346,22 @@ function GUI.windowMaximize(window, animationDisabled) if window.maximized then toX, toY, toWidth, toHeight = window.oldGeometryX, window.oldGeometryY, window.oldGeometryWidth, window.oldGeometryHeight + window.oldGeometryX, window.oldGeometryY, window.oldGeometryWidth, window.oldGeometryHeight = nil, nil, nil, nil window.maximized = nil else - toX, toY, toWidth, toHeight = 1, 1, window.parent.width, window.parent.height + toWidth, toHeight = window.parent.width, window.parent.height + + if window.maxWidth then + toWidth = math.min(toWidth, window.maxWidth) + end + + if window.maxHeight then + toHeight = math.min(toHeight, window.maxHeight) + end + + toX, toY = math.floor(1 + window.parent.width / 2 - toWidth / 2), math.floor(1 + window.parent.height / 2 - toHeight / 2) + window.oldGeometryX, window.oldGeometryY, window.oldGeometryWidth, window.oldGeometryHeight = window.localX, window.localY, window.width, window.height window.maximized = true end diff --git a/Libraries/Image.lua b/Libraries/Image.lua index 9b84094f..2a1215ac 100755 --- a/Libraries/Image.lua +++ b/Libraries/Image.lua @@ -78,32 +78,32 @@ encodingMethodsLoad[5] = function(file, picture) end end -local function loadOCIF67(file, picture, mode) - picture[1] = file:readBytes(1) - picture[2] = file:readBytes(1) +local function loadOCIF678(file, picture, is7, is8) + picture[1] = file:readBytes(1) + is8 + picture[2] = file:readBytes(1) + is8 local currentAlpha, currentSymbol, currentBackground, currentForeground, currentY - for alpha = 1, file:readBytes(1) + mode do + for alpha = 1, file:readBytes(1) + is7 do currentAlpha = file:readBytes(1) / 255 - for symbol = 1, file:readBytes(2) + mode do + for symbol = 1, file:readBytes(2) + is7 do currentSymbol = file:readUnicodeChar() - for background = 1, file:readBytes(1) + mode do + for background = 1, file:readBytes(1) + is7 do currentBackground = color.to24Bit(file:readBytes(1)) - for foreground = 1, file:readBytes(1) + mode do + for foreground = 1, file:readBytes(1) + is7 do currentForeground = color.to24Bit(file:readBytes(1)) - for y = 1, file:readBytes(1) + mode do + for y = 1, file:readBytes(1) + is7 do currentY = file:readBytes(1) - for x = 1, file:readBytes(1) + mode do + for x = 1, file:readBytes(1) + is7 do image.set( picture, - file:readBytes(1), - currentY, + file:readBytes(1) + is8, + currentY + is8, currentBackground, currentForeground, currentAlpha, @@ -117,9 +117,9 @@ local function loadOCIF67(file, picture, mode) end end -local function saveOCIF67(file, picture, mode) +local function saveOCIF678(file, picture, is7, is8) local function getGroupSize(t) - local size = mode == 1 and -1 or 0 + local size = -is7 for key in pairs(t) do size = size + 1 @@ -133,8 +133,8 @@ local function saveOCIF67(file, picture, mode) -- Writing 1 byte per image width and height file:writeBytes( - picture[1], - picture[2] + picture[1] - is8, + picture[2] - is8 ) -- Writing 1 byte for alphas array size @@ -178,13 +178,14 @@ local function saveOCIF67(file, picture, mode) for y in pairs(groupedPicture[alpha][symbol][background][foreground]) do file:writeBytes( -- Writing 1 byte for current y value - y, + y - is8, -- Writing 1 byte for x array size - #groupedPicture[alpha][symbol][background][foreground][y] - mode + #groupedPicture[alpha][symbol][background][foreground][y] - is7 ) for x = 1, #groupedPicture[alpha][symbol][background][foreground][y] do - file:writeBytes(groupedPicture[alpha][symbol][background][foreground][y][x]) + -- Wrting 1 byte for current x value + file:writeBytes(groupedPicture[alpha][symbol][background][foreground][y][x] - is8) end end end @@ -194,19 +195,27 @@ local function saveOCIF67(file, picture, mode) end encodingMethodsSave[6] = function(file, picture) - saveOCIF67(file, picture, 0) + saveOCIF678(file, picture, 0, 0) end encodingMethodsLoad[6] = function(file, picture) - loadOCIF67(file, picture, 0) + loadOCIF678(file, picture, 0, 0) end encodingMethodsSave[7] = function(file, picture) - saveOCIF67(file, picture, 1) + saveOCIF678(file, picture, 1, 0) end encodingMethodsLoad[7] = function(file, picture) - loadOCIF67(file, picture, 1) + loadOCIF678(file, picture, 1, 0) +end + +encodingMethodsSave[8] = function(file, picture) + saveOCIF678(file, picture, 1, 1) +end + +encodingMethodsLoad[8] = function(file, picture) + loadOCIF678(file, picture, 1, 1) end -------------------------------------------------------------------------------- From 45f2c0b2a1dbea238b956f653f09beb9ca1e9de5 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Sat, 4 Sep 2021 19:49:25 +0700 Subject: [PATCH 17/18] Added OCIF8 image format support & fixed HEX editor app --- Installer/Files.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Installer/Files.cfg b/Installer/Files.cfg index 73e22de8..102997ab 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -243,8 +243,8 @@ { path="Applications/Graph.app/Main.lua", id=238, shortcut = true }, "Applications/Graph.app/Icon.pic", -- HEX - { path="Applications/HEX Editor.app/Main.lua", id=248, shortcut = true }, - "Applications/HEX Editor.app/Icon.pic", + { path="Applications/HEX.app/Main.lua", id=248, shortcut = true }, + "Applications/HEX.app/Icon.pic", -- Running string { path="Applications/Running String.app/Main.lua", id=410, shortcut = true }, "Applications/Running String.app/Icon.pic", From ceb8b40136133cdafcad3e137c2df8dc03137e8a Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Sat, 11 Sep 2021 02:15:50 +0700 Subject: [PATCH 18/18] =?UTF-8?q?=D0=91=D0=BB=D1=8F))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/MineCode IDE.app/Main.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Applications/MineCode IDE.app/Main.lua b/Applications/MineCode IDE.app/Main.lua index 18982634..08c49bfa 100755 --- a/Applications/MineCode IDE.app/Main.lua +++ b/Applications/MineCode IDE.app/Main.lua @@ -533,8 +533,10 @@ end local function openFile(path) local file, reason = filesystem.open(path, "r") + if file then newFile() + leftTreeView.selectedItem = path codeView.hidden = true @@ -548,11 +550,12 @@ local function openFile(path) local counter, currentSize, totalSize = 1, 0, filesystem.size(path) for line in file:lines() do + counter, currentSize = counter + 1, currentSize + #line + 1 + line = optimizeString(line) table.insert(lines, line) codeView.maximumLineLength = math.max(codeView.maximumLineLength, unicode.len(line)) - counter, currentSize = counter + 1, currentSize + #line if counter % config.linesToShowOpenProgress == 0 then progressBar.value = math.floor(currentSize / totalSize * 100) computer.pullSignal(0) @@ -562,15 +565,15 @@ local function openFile(path) file:close() - if #lines > 1 then - table.remove(lines, 1) - end - if counter > config.linesToShowOpenProgress then progressBar.value = 100 workspace:draw() end + if #lines > 1 then + table.remove(lines, 1) + end + codeView.hidden = false container:remove() updateAutocompleteDatabaseFromAllLines()