mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Added OCIF8 image format support & fixed HEX editor app
This commit is contained in:
parent
f1c7f3efe8
commit
ae18379ca8
@ -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()
|
||||||
|
|||||||
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
@ -182,13 +182,6 @@
|
|||||||
"Applications/Settings.app/Localizations/Italian.lang",
|
"Applications/Settings.app/Localizations/Italian.lang",
|
||||||
"Applications/Settings.app/Localizations/Japanese.lang",
|
"Applications/Settings.app/Localizations/Japanese.lang",
|
||||||
"Applications/Settings.app/Localizations/Dutch.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
|
-- 3D Print
|
||||||
{ path="Applications/3D Print.app/Main.lua", id=859, shortcut = true },
|
{ path="Applications/3D Print.app/Main.lua", id=859, shortcut = true },
|
||||||
"Applications/3D Print.app/Icon.pic",
|
"Applications/3D Print.app/Icon.pic",
|
||||||
@ -250,8 +243,8 @@
|
|||||||
{ path="Applications/Graph.app/Main.lua", id=238, shortcut = true },
|
{ path="Applications/Graph.app/Main.lua", id=238, shortcut = true },
|
||||||
"Applications/Graph.app/Icon.pic",
|
"Applications/Graph.app/Icon.pic",
|
||||||
-- HEX
|
-- HEX
|
||||||
{ path="Applications/HEX.app/Main.lua", id=248, shortcut = true },
|
{ path="Applications/HEX Editor.app/Main.lua", id=248, shortcut = true },
|
||||||
"Applications/HEX.app/Icon.pic",
|
"Applications/HEX Editor.app/Icon.pic",
|
||||||
-- Running string
|
-- Running string
|
||||||
{ path="Applications/Running String.app/Main.lua", id=410, shortcut = true },
|
{ path="Applications/Running String.app/Main.lua", id=410, shortcut = true },
|
||||||
"Applications/Running String.app/Icon.pic",
|
"Applications/Running String.app/Icon.pic",
|
||||||
@ -291,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
|
||||||
|
|||||||
@ -4289,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
|
||||||
@ -4313,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
|
||||||
@ -4344,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
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user