mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Merge branch 'IgorTimofeev:master' into master
This commit is contained in:
commit
c051b742c5
@ -241,7 +241,7 @@ local function checkImage(url, mneTolkoSprosit)
|
|||||||
if data:sub(1, 4) == "OCIF" then
|
if data:sub(1, 4) == "OCIF" then
|
||||||
local encodingMethod = string.byte(data:sub(5, 5))
|
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 string.byte(data:sub(6, 6)) == 8 and string.byte(data:sub(7, 7)) == 4 then
|
||||||
if mneTolkoSprosit then
|
if mneTolkoSprosit then
|
||||||
handle:close()
|
handle:close()
|
||||||
|
|||||||
BIN
Applications/Calendar.app/Icon.pic
Normal file
BIN
Applications/Calendar.app/Icon.pic
Normal file
Binary file not shown.
BIN
Applications/Calendar.app/Icons/ArrowLeft.pic
Normal file
BIN
Applications/Calendar.app/Icons/ArrowLeft.pic
Normal file
Binary file not shown.
BIN
Applications/Calendar.app/Icons/ArrowRight.pic
Normal file
BIN
Applications/Calendar.app/Icons/ArrowRight.pic
Normal file
Binary file not shown.
21
Applications/Calendar.app/Localizations/English.lang
Normal file
21
Applications/Calendar.app/Localizations/English.lang
Normal file
@ -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"
|
||||||
|
}
|
||||||
21
Applications/Calendar.app/Localizations/Russian.lang
Normal file
21
Applications/Calendar.app/Localizations/Russian.lang
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
weekLine = "Пн Вт Ср Чт Пт Сб Вс",
|
||||||
|
weekLineAlt = "Вс Пн Вт Ср Чт Пт Сб",
|
||||||
|
months = {
|
||||||
|
"Январь",
|
||||||
|
"Февраль",
|
||||||
|
"Март",
|
||||||
|
"Апрель",
|
||||||
|
"Май",
|
||||||
|
"Июнь",
|
||||||
|
"Июль",
|
||||||
|
"Август",
|
||||||
|
"Сентябрь",
|
||||||
|
"Октябрь",
|
||||||
|
"Ноябрь",
|
||||||
|
"Декабрь",
|
||||||
|
},
|
||||||
|
startWeek = "Начинать неделю с ",
|
||||||
|
monday = "Понедельника",
|
||||||
|
sunday = "Воскресенья"
|
||||||
|
}
|
||||||
257
Applications/Calendar.app/Main.lua
Normal file
257
Applications/Calendar.app/Main.lua
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
local GUI = require("GUI")
|
||||||
|
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 currentScriptPath = fs.path(system.getCurrentScript())
|
||||||
|
local localization = system.getLocalization(currentScriptPath .. "Localizations/")
|
||||||
|
|
||||||
|
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}
|
||||||
|
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
|
||||||
|
|
||||||
|
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, 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
|
||||||
|
|
||||||
|
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 = 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 config.isWeekAlt then
|
||||||
|
counter = counter + 1 == 7 and 0 or counter + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, curYearList[monthPos].countOfDays do
|
||||||
|
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, 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
|
||||||
|
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, 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
|
||||||
|
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, false, prevMonth)
|
||||||
|
local arrowRight = makeIconButton(39, 15, window, true, nextMonth)
|
||||||
|
|
||||||
|
local weekType = menu:addItem(localization.startWeek..localization.sunday)
|
||||||
|
weekType.onTouch = function()
|
||||||
|
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
|
||||||
|
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()
|
||||||
@ -1,13 +1,18 @@
|
|||||||
|
|
||||||
local text = require("Text")
|
local text = require("Text")
|
||||||
local number = require("Number")
|
|
||||||
local filesystem = require("Filesystem")
|
local filesystem = require("Filesystem")
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local screen = require("Screen")
|
local screen = require("Screen")
|
||||||
local system = require("System")
|
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 = {
|
local colors = {
|
||||||
background = 0xF0F0F0,
|
background = 0xF0F0F0,
|
||||||
backgroundText = 0x555555,
|
backgroundText = 0x555555,
|
||||||
@ -39,8 +44,13 @@ local scrollBar, titleTextBox
|
|||||||
|
|
||||||
local workspace, window = system.addWindow(GUI.filledWindow(1, 1, 98, 25, colors.background))
|
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.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 function byteArrayToNumber(b)
|
||||||
local n = 0
|
local n = 0
|
||||||
@ -204,8 +214,8 @@ local function byteFieldEventHandler(workspace, object, e1, e2, e3, e4, e5)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function newByteField(x, y, width, height, elementWidth, elementHeight, asChar)
|
local function newByteField(x, y, width, elementWidth, elementHeight, asChar)
|
||||||
local object = GUI.object(x, y, width, height)
|
local object = GUI.object(x, y, width, 1)
|
||||||
|
|
||||||
object.elementWidth = elementWidth
|
object.elementWidth = elementWidth
|
||||||
object.elementHeight = elementHeight
|
object.elementHeight = elementHeight
|
||||||
@ -221,20 +231,19 @@ end
|
|||||||
|
|
||||||
window:addChild(GUI.panel(1, 1, window.width, 3, 0x3C3C3C)):moveToBack()
|
window:addChild(GUI.panel(1, 1, window.width, 3, 0x3C3C3C)):moveToBack()
|
||||||
|
|
||||||
local byteField = window:addChild(newByteField(13, 6, 64, 20, 4, 2, false))
|
local byteField = window:addChild(newByteField(13, 6, 64, 4, 2, false))
|
||||||
local charField = window:addChild(newByteField(byteField.localX + byteField.width + 3, 6, 16, 20, 1, 2, true))
|
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, 21))
|
local separator = window:addChild(GUI.object(byteField.localX + byteField.width, 5, 1, 1))
|
||||||
separator.draw = function(object)
|
separator.draw = function(object)
|
||||||
for i = object.y, object.y + object.height - 1 do
|
for i = object.y, object.y + object.height - 1 do
|
||||||
screen.drawText(object.x, i, colors.separator, "│")
|
screen.drawText(object.x, i, colors.separator, "│")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
window:addChild(GUI.panel(11, 4, window.width - 10, 1, colors.panel))
|
window:addChild(GUI.panel(11, 4, window.width - 10, 1, colors.panel))
|
||||||
|
|
||||||
-- Vertical
|
-- 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)
|
verticalCounter.draw = function(object)
|
||||||
screen.drawRectangle(object.x, object.y, object.width, object.height, colors.panel, colors.panelText, " ")
|
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
|
||||||
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
|
scrollBar.eventHandler = nil
|
||||||
|
|
||||||
titleTextBox = window:addChild(
|
titleTextBox = window:addChild(
|
||||||
GUI.textBox(
|
GUI.textBox(1, 1, math.floor(window.width * 0.35), 3,
|
||||||
1, 1, math.floor(window.width * 0.35), 3,
|
|
||||||
colors.titleBackground,
|
colors.titleBackground,
|
||||||
colors.titleText,
|
colors.titleText,
|
||||||
{
|
{
|
||||||
@ -293,6 +301,7 @@ titleTextBox = window:addChild(
|
|||||||
1, 1, 0
|
1, 1, 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
titleTextBox.localX = math.floor(window.width / 2 - titleTextBox.width / 2)
|
titleTextBox.localX = math.floor(window.width / 2 - titleTextBox.width / 2)
|
||||||
titleTextBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
titleTextBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
titleTextBox.eventHandler = nil
|
titleTextBox.eventHandler = nil
|
||||||
@ -307,6 +316,7 @@ local function load(path)
|
|||||||
|
|
||||||
if file then
|
if file then
|
||||||
bytes = {}
|
bytes = {}
|
||||||
|
|
||||||
local byte
|
local byte
|
||||||
while true do
|
while true do
|
||||||
byte = file:readBytes(1)
|
byte = file:readBytes(1)
|
||||||
@ -318,9 +328,11 @@ local function load(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
file:close()
|
file:close()
|
||||||
|
|
||||||
offset = 0
|
offset = 0
|
||||||
selection.from, selection.to = 1, 1
|
selection.from, selection.to = 1, 1
|
||||||
scrollBar.value, scrollBar.maximumValue = 0, #bytes
|
scrollBar.value, scrollBar.maximumValue = 0, #bytes
|
||||||
|
|
||||||
status()
|
status()
|
||||||
else
|
else
|
||||||
GUI.alert("Failed to open file for reading: " .. tostring(reason))
|
GUI.alert("Failed to open file for reading: " .. tostring(reason))
|
||||||
@ -329,18 +341,26 @@ end
|
|||||||
|
|
||||||
openFileButton.onTouch = function()
|
openFileButton.onTouch = function()
|
||||||
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Open", "Cancel", "File name", "/")
|
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:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
|
||||||
filesystemDialog:show()
|
filesystemDialog:show()
|
||||||
|
|
||||||
filesystemDialog.onSubmit = function(path)
|
filesystemDialog.onSubmit = function(path)
|
||||||
load(path)
|
load(path)
|
||||||
|
|
||||||
|
config.recentPath = path
|
||||||
|
filesystem.writeTable(configPath, config)
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
saveFileButton.onTouch = function()
|
saveFileButton.onTouch = function()
|
||||||
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Save", "Cancel", "File name", "/")
|
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:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
|
||||||
filesystemDialog:show()
|
filesystemDialog:show()
|
||||||
|
|
||||||
filesystemDialog.onSubmit = function(path)
|
filesystemDialog.onSubmit = function(path)
|
||||||
local file = filesystem.open(path, "wb")
|
local file = filesystem.open(path, "wb")
|
||||||
if file then
|
if file then
|
||||||
@ -354,31 +374,21 @@ saveFileButton.onTouch = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
window.actionButtons.localY = 2
|
window.onResize = function(width, height)
|
||||||
window.actionButtons.maximize.onTouch = function()
|
byteField.height = height - 6
|
||||||
window.height = window.parent.height
|
|
||||||
byteField.height = window.height - 6
|
|
||||||
charField.height = byteField.height
|
charField.height = byteField.height
|
||||||
scrollBar.height = byteField.height
|
scrollBar.height = byteField.height
|
||||||
window.backgroundPanel.height = window.height - 4
|
window.backgroundPanel.height = height - 4
|
||||||
verticalCounter.height = window.backgroundPanel.height + 1
|
verticalCounter.height = window.backgroundPanel.height + 1
|
||||||
separator.height = byteField.height + 2
|
separator.height = byteField.height + 2
|
||||||
|
|
||||||
window.localY = 1
|
|
||||||
|
|
||||||
workspace:draw()
|
|
||||||
end
|
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()
|
workspace:draw()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -533,8 +533,10 @@ end
|
|||||||
|
|
||||||
local function openFile(path)
|
local function openFile(path)
|
||||||
local file, reason = filesystem.open(path, "r")
|
local file, reason = filesystem.open(path, "r")
|
||||||
|
|
||||||
if file then
|
if file then
|
||||||
newFile()
|
newFile()
|
||||||
|
|
||||||
leftTreeView.selectedItem = path
|
leftTreeView.selectedItem = path
|
||||||
codeView.hidden = true
|
codeView.hidden = true
|
||||||
|
|
||||||
@ -548,11 +550,12 @@ local function openFile(path)
|
|||||||
|
|
||||||
local counter, currentSize, totalSize = 1, 0, filesystem.size(path)
|
local counter, currentSize, totalSize = 1, 0, filesystem.size(path)
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
|
counter, currentSize = counter + 1, currentSize + #line + 1
|
||||||
|
|
||||||
line = optimizeString(line)
|
line = optimizeString(line)
|
||||||
table.insert(lines, line)
|
table.insert(lines, line)
|
||||||
codeView.maximumLineLength = math.max(codeView.maximumLineLength, unicode.len(line))
|
codeView.maximumLineLength = math.max(codeView.maximumLineLength, unicode.len(line))
|
||||||
|
|
||||||
counter, currentSize = counter + 1, currentSize + #line
|
|
||||||
if counter % config.linesToShowOpenProgress == 0 then
|
if counter % config.linesToShowOpenProgress == 0 then
|
||||||
progressBar.value = math.floor(currentSize / totalSize * 100)
|
progressBar.value = math.floor(currentSize / totalSize * 100)
|
||||||
computer.pullSignal(0)
|
computer.pullSignal(0)
|
||||||
@ -562,15 +565,15 @@ local function openFile(path)
|
|||||||
|
|
||||||
file:close()
|
file:close()
|
||||||
|
|
||||||
if #lines > 1 then
|
|
||||||
table.remove(lines, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
if counter > config.linesToShowOpenProgress then
|
if counter > config.linesToShowOpenProgress then
|
||||||
progressBar.value = 100
|
progressBar.value = 100
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if #lines > 1 then
|
||||||
|
table.remove(lines, 1)
|
||||||
|
end
|
||||||
|
|
||||||
codeView.hidden = false
|
codeView.hidden = false
|
||||||
container:remove()
|
container:remove()
|
||||||
updateAutocompleteDatabaseFromAllLines()
|
updateAutocompleteDatabaseFromAllLines()
|
||||||
|
|||||||
@ -85,5 +85,7 @@
|
|||||||
brightness = "Brightness: ",
|
brightness = "Brightness: ",
|
||||||
filterColor = "Filter color",
|
filterColor = "Filter color",
|
||||||
transparency = "Transparency: ",
|
transparency = "Transparency: ",
|
||||||
force = "Force"
|
force = "Force",
|
||||||
|
rasterizePolygon = "Rasterize polygon",
|
||||||
|
polygonEdges = "Number of polygon edges:"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,5 +85,7 @@
|
|||||||
brightness = "Яркость: ",
|
brightness = "Яркость: ",
|
||||||
filterColor = "Цвет фильтра",
|
filterColor = "Цвет фильтра",
|
||||||
transparency = "Прозрачность: ",
|
transparency = "Прозрачность: ",
|
||||||
force = "Сила: "
|
force = "Сила: ",
|
||||||
|
rasterizePolygon = "Растеризировать полигон",
|
||||||
|
polygonEdges = "Количество граней полигона:"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -315,7 +315,7 @@ end
|
|||||||
|
|
||||||
local function save(path)
|
local function save(path)
|
||||||
if filesystem.extension(path) == ".pic" then
|
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
|
if result then
|
||||||
setSavePath(path)
|
setSavePath(path)
|
||||||
|
|||||||
@ -19,6 +19,7 @@ local fillButton = window.newButton1(locale.fill)
|
|||||||
local outlineButton = window.newButton1(locale.outline)
|
local outlineButton = window.newButton1(locale.outline)
|
||||||
local rasterizeLineButton = window.newButton1(locale.rasterizeLine)
|
local rasterizeLineButton = window.newButton1(locale.rasterizeLine)
|
||||||
local rasterizeEllipseButton = window.newButton1(locale.rasterizeEllipse)
|
local rasterizeEllipseButton = window.newButton1(locale.rasterizeEllipse)
|
||||||
|
local rasterizePolygonButton = window.newButton1(locale.rasterizePolygon)
|
||||||
local clearButton = window.newButton2(locale.clear)
|
local clearButton = window.newButton2(locale.clear)
|
||||||
local cropButton = window.newButton2(locale.crop)
|
local cropButton = window.newButton2(locale.crop)
|
||||||
|
|
||||||
@ -101,6 +102,39 @@ tool.onSelection = function()
|
|||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
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()
|
window.currentToolLayout:addChild(clearButton).onTouch = function()
|
||||||
for j = selector.y, selector.y + selector.height - 1 do
|
for j = selector.y, selector.y + selector.height - 1 do
|
||||||
|
|||||||
@ -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)
|
||||||
BIN
Applications/Picture View.app/Extensions/.pic/Icon.pic
Normal file
BIN
Applications/Picture View.app/Extensions/.pic/Icon.pic
Normal file
Binary file not shown.
BIN
Applications/Picture View.app/Icon.pic
Normal file
BIN
Applications/Picture View.app/Icon.pic
Normal file
Binary file not shown.
BIN
Applications/Picture View.app/Icons/ArrowLeft.pic
Normal file
BIN
Applications/Picture View.app/Icons/ArrowLeft.pic
Normal file
Binary file not shown.
BIN
Applications/Picture View.app/Icons/ArrowRight.pic
Normal file
BIN
Applications/Picture View.app/Icons/ArrowRight.pic
Normal file
Binary file not shown.
BIN
Applications/Picture View.app/Icons/Play.pic
Normal file
BIN
Applications/Picture View.app/Icons/Play.pic
Normal file
Binary file not shown.
BIN
Applications/Picture View.app/Icons/SetWallpaper.pic
Normal file
BIN
Applications/Picture View.app/Icons/SetWallpaper.pic
Normal file
Binary file not shown.
12
Applications/Picture View.app/Localizations/English.lang
Normal file
12
Applications/Picture View.app/Localizations/English.lang
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
noPictures = "There is no pictures.",
|
||||||
|
slideShow = "Slideshow",
|
||||||
|
delay = "Delay: ",
|
||||||
|
seconds = " seconds",
|
||||||
|
fullScreen = "Full screen",
|
||||||
|
setWallpaper = "Do you want to set this picture as wallpaper?",
|
||||||
|
yes = "Yes",
|
||||||
|
no = "No",
|
||||||
|
start = "Start",
|
||||||
|
cancel = "Cancel"
|
||||||
|
}
|
||||||
12
Applications/Picture View.app/Localizations/Russian.lang
Normal file
12
Applications/Picture View.app/Localizations/Russian.lang
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
noPictures = "В этой папке отутствуют изображения.",
|
||||||
|
slideShow = "Слайдшоу",
|
||||||
|
delay = "Задержка: ",
|
||||||
|
seconds = " секунд(ы)",
|
||||||
|
fullScreen = "На полный экран",
|
||||||
|
setWallpaper = "Вы хотите установить это изображение в качестве обоев?",
|
||||||
|
yes = "Да",
|
||||||
|
no = "Нет",
|
||||||
|
start = "Начать",
|
||||||
|
cancel = "Отмена"
|
||||||
|
}
|
||||||
236
Applications/Picture View.app/Main.lua
Normal file
236
Applications/Picture View.app/Main.lua
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
local GUI = require("GUI")
|
||||||
|
local system = require("System")
|
||||||
|
local fs = require("Filesystem")
|
||||||
|
local image = require("Image")
|
||||||
|
local text = require("Text")
|
||||||
|
local screen = require("Screen")
|
||||||
|
local paths = require("Paths")
|
||||||
|
|
||||||
|
local localization = system.getCurrentScriptLocalization()
|
||||||
|
|
||||||
|
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, title
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 80, 25, 0x1E1E1E))
|
||||||
|
|
||||||
|
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(halfX - loadedImage[1] / 2),
|
||||||
|
math.floor(halfY - loadedImage[2] / 2),
|
||||||
|
loadedImage
|
||||||
|
)
|
||||||
|
|
||||||
|
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 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
|
||||||
|
|
||||||
|
updateTitle()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function updateSlideshowDeadline()
|
||||||
|
slideShowDeadline = computer.uptime() + slideShowDelay
|
||||||
|
end
|
||||||
|
|
||||||
|
local function loadImage()
|
||||||
|
local result, reason = image.load(files[fileIndex])
|
||||||
|
|
||||||
|
if result then
|
||||||
|
loadedImage = result
|
||||||
|
|
||||||
|
updateTitle()
|
||||||
|
else
|
||||||
|
GUI.alert(reason)
|
||||||
|
window:remove()
|
||||||
|
end
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function loadIncremented(value)
|
||||||
|
fileIndex = fileIndex + value
|
||||||
|
|
||||||
|
if fileIndex > #files then
|
||||||
|
fileIndex = 1
|
||||||
|
elseif fileIndex < 1 then
|
||||||
|
fileIndex = #files
|
||||||
|
end
|
||||||
|
|
||||||
|
loadImage()
|
||||||
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Arrow right
|
||||||
|
addButton("ArrowRight", function()
|
||||||
|
loadIncremented(1)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Set wallpaper
|
||||||
|
addButton("SetWallpaper", function()
|
||||||
|
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 = files[fileIndex]
|
||||||
|
system.saveUserSettings()
|
||||||
|
system.updateWallpaper()
|
||||||
|
|
||||||
|
container:remove()
|
||||||
|
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
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
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)
|
||||||
|
|
||||||
|
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
|
||||||
|
panel.hidden = true
|
||||||
|
panelContainer.hidden = true
|
||||||
|
else
|
||||||
|
loadImage()
|
||||||
|
end
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
@ -134,6 +134,18 @@
|
|||||||
"Applications/Picture Edit.app/Localizations/English.lang",
|
"Applications/Picture Edit.app/Localizations/English.lang",
|
||||||
"Applications/Picture Edit.app/Localizations/Russian.lang",
|
"Applications/Picture Edit.app/Localizations/Russian.lang",
|
||||||
"Applications/Picture Edit.app/Extensions/.pic/Icon.pic",
|
"Applications/Picture Edit.app/Extensions/.pic/Icon.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",
|
||||||
|
"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",
|
||||||
|
"Applications/Picture View.app/Extensions/.pic/Context menu.lua",
|
||||||
-- Finder
|
-- Finder
|
||||||
{ path="Applications/Finder.app/Main.lua", id=175 },
|
{ path="Applications/Finder.app/Main.lua", id=175 },
|
||||||
"Applications/Finder.app/Icon.pic",
|
"Applications/Finder.app/Icon.pic",
|
||||||
@ -272,6 +284,13 @@
|
|||||||
"Applications/VK.app/Styles/Default.lua",
|
"Applications/VK.app/Styles/Default.lua",
|
||||||
"Applications/VK.app/Styles/Bright.lua",
|
"Applications/VK.app/Styles/Bright.lua",
|
||||||
"Applications/VK.app/Styles/Dark.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 = {
|
wallpapers = {
|
||||||
"Pictures/AhsokaTano.pic",
|
"Pictures/AhsokaTano.pic",
|
||||||
|
|||||||
@ -23,6 +23,7 @@ if computer.getArchitecture and computer.getArchitecture() == "Lua 5.3" then
|
|||||||
|
|
||||||
function(color1, color2, transparency)
|
function(color1, color2, transparency)
|
||||||
local invertedTransparency = 1 - transparency
|
local invertedTransparency = 1 - transparency
|
||||||
|
|
||||||
return
|
return
|
||||||
((color2 >> 16) * invertedTransparency + (color1 >> 16) * transparency) // 1 << 16 |
|
((color2 >> 16) * invertedTransparency + (color1 >> 16) * transparency) // 1 << 16 |
|
||||||
((color2 >> 8 & 0xFF) * invertedTransparency + (color1 >> 8 & 0xFF) * transparency) // 1 << 8 |
|
((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)
|
function(color1, color2, position)
|
||||||
local r1, g1, b1 = color1 >> 16, color1 >> 8 & 0xFF, color1 & 0xFF
|
local r1, g1, b1 = color1 >> 16, color1 >> 8 & 0xFF, color1 & 0xFF
|
||||||
|
|
||||||
return
|
return
|
||||||
(r1 + ((color2 >> 16) - r1) * position) // 1 << 16 |
|
(r1 + ((color2 >> 16) - r1) * position) // 1 << 16 |
|
||||||
(g1 + ((color2 >> 8 & 0xFF) - g1) * position) // 1 << 8 |
|
(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
|
paletteR, paletteG, paletteB = paletteColor >> 16, paletteColor >> 8 & 0xFF, paletteColor & 0xFF
|
||||||
|
|
||||||
delta = (paletteR - r) ^ 2 + (paletteG - g) ^ 2 + (paletteB - b) ^ 2
|
delta = (paletteR - r) ^ 2 + (paletteG - g) ^ 2 + (paletteB - b) ^ 2
|
||||||
|
|
||||||
if delta < closestDelta then
|
if delta < closestDelta then
|
||||||
closestDelta, closestIndex = delta, i
|
closestDelta, closestIndex = delta, i
|
||||||
end
|
end
|
||||||
@ -66,6 +69,7 @@ else
|
|||||||
function(integerColor)
|
function(integerColor)
|
||||||
local r = integerColor / 65536
|
local r = integerColor / 65536
|
||||||
r = r - r % 1
|
r = r - r % 1
|
||||||
|
|
||||||
local g = (integerColor - r * 65536) / 256
|
local g = (integerColor - r * 65536) / 256
|
||||||
g = g - g % 1
|
g = g - g % 1
|
||||||
|
|
||||||
@ -81,11 +85,13 @@ else
|
|||||||
|
|
||||||
local r1 = color1 / 65536
|
local r1 = color1 / 65536
|
||||||
r1 = r1 - r1 % 1
|
r1 = r1 - r1 % 1
|
||||||
|
|
||||||
local g1 = (color1 - r1 * 65536) / 256
|
local g1 = (color1 - r1 * 65536) / 256
|
||||||
g1 = g1 - g1 % 1
|
g1 = g1 - g1 % 1
|
||||||
|
|
||||||
local r2 = color2 / 65536
|
local r2 = color2 / 65536
|
||||||
r2 = r2 - r2 % 1
|
r2 = r2 - r2 % 1
|
||||||
|
|
||||||
local g2 = (color2 - r2 * 65536) / 256
|
local g2 = (color2 - r2 * 65536) / 256
|
||||||
g2 = g2 - g2 % 1
|
g2 = g2 - g2 % 1
|
||||||
|
|
||||||
@ -103,12 +109,15 @@ else
|
|||||||
function(color1, color2, position)
|
function(color1, color2, position)
|
||||||
local r1 = color1 / 65536
|
local r1 = color1 / 65536
|
||||||
r1 = r1 - r1 % 1
|
r1 = r1 - r1 % 1
|
||||||
|
|
||||||
local g1 = (color1 - r1 * 65536) / 256
|
local g1 = (color1 - r1 * 65536) / 256
|
||||||
g1 = g1 - g1 % 1
|
g1 = g1 - g1 % 1
|
||||||
|
|
||||||
local b1 = color1 - r1 * 65536 - g1 * 256
|
local b1 = color1 - r1 * 65536 - g1 * 256
|
||||||
|
|
||||||
local r2 = color2 / 65536
|
local r2 = color2 / 65536
|
||||||
r2 = r2 - r2 % 1
|
r2 = r2 - r2 % 1
|
||||||
|
|
||||||
local g2 = (color2 - r2 * 65536) / 256
|
local g2 = (color2 - r2 * 65536) / 256
|
||||||
g2 = g2 - g2 % 1
|
g2 = g2 - g2 % 1
|
||||||
|
|
||||||
@ -128,12 +137,15 @@ else
|
|||||||
|
|
||||||
local r = color24Bit / 65536
|
local r = color24Bit / 65536
|
||||||
r = r - r % 1
|
r = r - r % 1
|
||||||
|
|
||||||
local g = (color24Bit - r * 65536) / 256
|
local g = (color24Bit - r * 65536) / 256
|
||||||
g = g - g % 1
|
g = g - g % 1
|
||||||
|
|
||||||
local b = color24Bit - r * 65536 - g * 256
|
local b = color24Bit - r * 65536 - g * 256
|
||||||
|
|
||||||
for index = 1, #palette do
|
for index = 1, #palette do
|
||||||
paletteColor = palette[index]
|
paletteColor = palette[index]
|
||||||
|
|
||||||
if color24Bit == paletteColor then
|
if color24Bit == paletteColor then
|
||||||
return index - 1
|
return index - 1
|
||||||
else
|
else
|
||||||
@ -144,6 +156,7 @@ else
|
|||||||
paletteB = paletteColor - paletteR * 65536 - paletteG * 256
|
paletteB = paletteColor - paletteR * 65536 - paletteG * 256
|
||||||
|
|
||||||
delta = (paletteR - r) ^ 2 + (paletteG - g) ^ 2 + (paletteB - b) ^ 2
|
delta = (paletteR - r) ^ 2 + (paletteG - g) ^ 2 + (paletteB - b) ^ 2
|
||||||
|
|
||||||
if delta < closestDelta then
|
if delta < closestDelta then
|
||||||
closestDelta, closestIndex = delta, index
|
closestDelta, closestIndex = delta, index
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1242,19 +1242,19 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local function getAxisValue(number, postfix, roundValues)
|
local function getAxisValue(num, postfix, roundValues)
|
||||||
if roundValues then
|
if roundValues then
|
||||||
return math.floor(number) .. postfix
|
return math.floor(num) .. postfix
|
||||||
else
|
else
|
||||||
local integer, fractional = math.modf(number)
|
local integer, fractional = math.modf(num)
|
||||||
local firstPart, secondPart = "", ""
|
local firstPart, secondPart = "", ""
|
||||||
if math.abs(integer) >= 1000 then
|
if math.abs(integer) >= 1000 then
|
||||||
return number.shorten(integer, 2) .. postfix
|
return number.shorten(integer, 2) .. postfix
|
||||||
else
|
else
|
||||||
if math.abs(fractional) > 0 then
|
if math.abs(fractional) > 0 then
|
||||||
return string.format("%.2f", number) .. postfix
|
return string.format("%.2f", num) .. postfix
|
||||||
else
|
else
|
||||||
return number .. postfix
|
return num .. postfix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3524,20 +3524,23 @@ end
|
|||||||
|
|
||||||
local function textUpdate(object)
|
local function textUpdate(object)
|
||||||
object.width = unicode.len(object.text)
|
object.width = unicode.len(object.text)
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
local function textDraw(object)
|
local function textDraw(object)
|
||||||
object:update()
|
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
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function GUI.text(x, y, color, text)
|
function GUI.text(x, y, color, text, transparency)
|
||||||
local object = GUI.object(x, y, 1, 1)
|
local object = GUI.object(x, y, 1, 1)
|
||||||
|
|
||||||
object.text = text
|
object.text = text
|
||||||
object.color = color
|
object.color = color
|
||||||
|
object.transparency = transparency
|
||||||
object.update = textUpdate
|
object.update = textUpdate
|
||||||
object.draw = textDraw
|
object.draw = textDraw
|
||||||
object:update()
|
object:update()
|
||||||
@ -4286,6 +4289,7 @@ local function windowCheck(window, x, y)
|
|||||||
return true
|
return true
|
||||||
elseif child.children then
|
elseif child.children then
|
||||||
local result = windowCheck(child, x, y)
|
local result = windowCheck(child, x, y)
|
||||||
|
|
||||||
if result == true then
|
if result == true then
|
||||||
return true
|
return true
|
||||||
elseif result == false then
|
elseif result == false then
|
||||||
@ -4310,6 +4314,7 @@ local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...)
|
|||||||
end
|
end
|
||||||
elseif e1 == "drag" and window.lastTouchX and not windowCheck(window, e3, e4) then
|
elseif e1 == "drag" and window.lastTouchX and not windowCheck(window, e3, e4) then
|
||||||
local xOffset, yOffset = e3 - window.lastTouchX, e4 - window.lastTouchY
|
local xOffset, yOffset = e3 - window.lastTouchX, e4 - window.lastTouchY
|
||||||
|
|
||||||
if xOffset ~= 0 or yOffset ~= 0 then
|
if xOffset ~= 0 or yOffset ~= 0 then
|
||||||
window.localX, window.localY = window.localX + xOffset, window.localY + yOffset
|
window.localX, window.localY = window.localX + xOffset, window.localY + yOffset
|
||||||
window.lastTouchX, window.lastTouchY = e3, e4
|
window.lastTouchX, window.lastTouchY = e3, e4
|
||||||
@ -4341,10 +4346,22 @@ function GUI.windowMaximize(window, animationDisabled)
|
|||||||
|
|
||||||
if window.maximized then
|
if window.maximized then
|
||||||
toX, toY, toWidth, toHeight = window.oldGeometryX, window.oldGeometryY, window.oldGeometryWidth, window.oldGeometryHeight
|
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.oldGeometryX, window.oldGeometryY, window.oldGeometryWidth, window.oldGeometryHeight = nil, nil, nil, nil
|
||||||
window.maximized = nil
|
window.maximized = nil
|
||||||
else
|
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.oldGeometryX, window.oldGeometryY, window.oldGeometryWidth, window.oldGeometryHeight = window.localX, window.localY, window.width, window.height
|
||||||
window.maximized = true
|
window.maximized = true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -78,32 +78,32 @@ encodingMethodsLoad[5] = function(file, picture)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function loadOCIF67(file, picture, mode)
|
local function loadOCIF678(file, picture, is7, is8)
|
||||||
picture[1] = file:readBytes(1)
|
picture[1] = file:readBytes(1) + is8
|
||||||
picture[2] = file:readBytes(1)
|
picture[2] = file:readBytes(1) + is8
|
||||||
|
|
||||||
local currentAlpha, currentSymbol, currentBackground, currentForeground, currentY
|
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
|
currentAlpha = file:readBytes(1) / 255
|
||||||
|
|
||||||
for symbol = 1, file:readBytes(2) + mode do
|
for symbol = 1, file:readBytes(2) + is7 do
|
||||||
currentSymbol = file:readUnicodeChar()
|
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))
|
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))
|
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)
|
currentY = file:readBytes(1)
|
||||||
|
|
||||||
for x = 1, file:readBytes(1) + mode do
|
for x = 1, file:readBytes(1) + is7 do
|
||||||
image.set(
|
image.set(
|
||||||
picture,
|
picture,
|
||||||
file:readBytes(1),
|
file:readBytes(1) + is8,
|
||||||
currentY,
|
currentY + is8,
|
||||||
currentBackground,
|
currentBackground,
|
||||||
currentForeground,
|
currentForeground,
|
||||||
currentAlpha,
|
currentAlpha,
|
||||||
@ -117,9 +117,9 @@ local function loadOCIF67(file, picture, mode)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function saveOCIF67(file, picture, mode)
|
local function saveOCIF678(file, picture, is7, is8)
|
||||||
local function getGroupSize(t)
|
local function getGroupSize(t)
|
||||||
local size = mode == 1 and -1 or 0
|
local size = -is7
|
||||||
|
|
||||||
for key in pairs(t) do
|
for key in pairs(t) do
|
||||||
size = size + 1
|
size = size + 1
|
||||||
@ -133,8 +133,8 @@ local function saveOCIF67(file, picture, mode)
|
|||||||
|
|
||||||
-- Writing 1 byte per image width and height
|
-- Writing 1 byte per image width and height
|
||||||
file:writeBytes(
|
file:writeBytes(
|
||||||
picture[1],
|
picture[1] - is8,
|
||||||
picture[2]
|
picture[2] - is8
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Writing 1 byte for alphas array size
|
-- 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
|
for y in pairs(groupedPicture[alpha][symbol][background][foreground]) do
|
||||||
file:writeBytes(
|
file:writeBytes(
|
||||||
-- Writing 1 byte for current y value
|
-- Writing 1 byte for current y value
|
||||||
y,
|
y - is8,
|
||||||
-- Writing 1 byte for x array size
|
-- 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
|
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
|
end
|
||||||
end
|
end
|
||||||
@ -194,19 +195,27 @@ local function saveOCIF67(file, picture, mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
encodingMethodsSave[6] = function(file, picture)
|
encodingMethodsSave[6] = function(file, picture)
|
||||||
saveOCIF67(file, picture, 0)
|
saveOCIF678(file, picture, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
encodingMethodsLoad[6] = function(file, picture)
|
encodingMethodsLoad[6] = function(file, picture)
|
||||||
loadOCIF67(file, picture, 0)
|
loadOCIF678(file, picture, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
encodingMethodsSave[7] = function(file, picture)
|
encodingMethodsSave[7] = function(file, picture)
|
||||||
saveOCIF67(file, picture, 1)
|
saveOCIF678(file, picture, 1, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
encodingMethodsLoad[7] = function(file, picture)
|
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
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -23,6 +23,7 @@ paths.system.applicationPictureEdit = paths.system.applications .. "Picture Edit
|
|||||||
paths.system.applicationSettings = paths.system.applications .. "Settings.app/Main.lua"
|
paths.system.applicationSettings = paths.system.applications .. "Settings.app/Main.lua"
|
||||||
paths.system.applicationPrint3D = paths.system.applications .. "3D Print.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.applicationConsole = paths.system.applications .. "Console.app/Main.lua"
|
||||||
|
paths.system.applicationPictureView = paths.system.applications .. "Picture View.app/Main.lua"
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -426,6 +426,38 @@ local function rasterizeEllipse(centerX, centerY, radiusX, radiusY, method)
|
|||||||
end
|
end
|
||||||
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)
|
local function drawLine(x1, y1, x2, y2, background, foreground, symbol)
|
||||||
rasterizeLine(x1, y1, x2, y2, function(x, y)
|
rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||||
set(x, y, background, foreground, symbol)
|
set(x, y, background, foreground, symbol)
|
||||||
@ -438,6 +470,12 @@ local function drawEllipse(centerX, centerY, radiusX, radiusY, background, foreg
|
|||||||
end)
|
end)
|
||||||
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)
|
local function drawText(x, y, textColor, data, transparency)
|
||||||
if y >= drawLimitY1 and y <= drawLimitY2 then
|
if y >= drawLimitY1 and y <= drawLimitY2 then
|
||||||
local charIndex, screenIndex = 1, bufferWidth * (y - 1) + x
|
local charIndex, screenIndex = 1, bufferWidth * (y - 1) + x
|
||||||
@ -776,6 +814,7 @@ return {
|
|||||||
paste = paste,
|
paste = paste,
|
||||||
rasterizeLine = rasterizeLine,
|
rasterizeLine = rasterizeLine,
|
||||||
rasterizeEllipse = rasterizeEllipse,
|
rasterizeEllipse = rasterizeEllipse,
|
||||||
|
rasterizePolygon = rasterizePolygon,
|
||||||
semiPixelRawSet = semiPixelRawSet,
|
semiPixelRawSet = semiPixelRawSet,
|
||||||
semiPixelSet = semiPixelSet,
|
semiPixelSet = semiPixelSet,
|
||||||
update = update,
|
update = update,
|
||||||
@ -783,6 +822,7 @@ return {
|
|||||||
drawRectangle = drawRectangle,
|
drawRectangle = drawRectangle,
|
||||||
drawLine = drawLine,
|
drawLine = drawLine,
|
||||||
drawEllipse = drawEllipse,
|
drawEllipse = drawEllipse,
|
||||||
|
drawPolygon = drawPolygon,
|
||||||
drawText = drawText,
|
drawText = drawText,
|
||||||
drawImage = drawImage,
|
drawImage = drawImage,
|
||||||
drawFrame = drawFrame,
|
drawFrame = drawFrame,
|
||||||
|
|||||||
@ -131,7 +131,7 @@ function system.getDefaultUserSettings()
|
|||||||
[".cfg"] = filesystem.path(paths.system.applicationMineCodeIDE),
|
[".cfg"] = filesystem.path(paths.system.applicationMineCodeIDE),
|
||||||
[".txt"] = filesystem.path(paths.system.applicationMineCodeIDE),
|
[".txt"] = filesystem.path(paths.system.applicationMineCodeIDE),
|
||||||
[".lang"] = filesystem.path(paths.system.applicationMineCodeIDE),
|
[".lang"] = filesystem.path(paths.system.applicationMineCodeIDE),
|
||||||
[".pic"] = filesystem.path(paths.system.applicationPictureEdit),
|
[".pic"] = filesystem.path(paths.system.applicationPictureView),
|
||||||
[".3dm"] = paths.system.applications .. "3D Print.app/"
|
[".3dm"] = paths.system.applications .. "3D Print.app/"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1361,10 +1361,11 @@ local function iconFieldBackgroundClick(iconField, e1, e2, e3, e4, e5, ...)
|
|||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
if #container.input.text > 0 then
|
if #container.input.text > 0 then
|
||||||
local path = iconField.path .. container.input.text .. ".app/"
|
local path = iconField.path .. container.input.text .. ".app/"
|
||||||
|
|
||||||
if checkFileToExists(container, path) then
|
if checkFileToExists(container, path) then
|
||||||
system.copy({ paths.system.applicationSample }, iconField.path)
|
system.copy({ paths.system.applicationSample }, paths.system.temporary)
|
||||||
filesystem.rename(iconField.path .. filesystem.name(paths.system.applicationSample), path)
|
filesystem.rename(paths.system.temporary .. filesystem.name(paths.system.applicationSample), path)
|
||||||
|
|
||||||
container:remove()
|
container:remove()
|
||||||
iconFieldSaveIconPosition(iconField, container.input.text .. ".app/", e3, e4)
|
iconFieldSaveIconPosition(iconField, container.input.text .. ".app/", e3, e4)
|
||||||
computer.pushSignal("system", "updateFileList")
|
computer.pushSignal("system", "updateFileList")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user