mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-27 05:22:40 +01:00
Шикарный буст скорости загрузки пикч без временной директории
This commit is contained in:
parent
f6627c5499
commit
3b7ea846f2
@ -227,7 +227,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=2.03,
|
||||
version=2.04,
|
||||
},
|
||||
{
|
||||
path="/lib/MineOSNetwork.lua",
|
||||
@ -253,7 +253,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/advancedLua.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.35,
|
||||
version=1.36,
|
||||
},
|
||||
{
|
||||
path="/lib/web.lua",
|
||||
@ -973,7 +973,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/AppMarket/Icon.pic",
|
||||
forceDownload=true,
|
||||
version=1.76,
|
||||
version=1.77,
|
||||
resources={
|
||||
{
|
||||
path="/Update.pic",
|
||||
|
||||
@ -19,7 +19,6 @@ local applicationList
|
||||
local localization = MineOSCore.getCurrentApplicationLocalization()
|
||||
local resources = MineOSCore.getCurrentApplicationResourcesDirectory()
|
||||
local updateImage = image.load(resources .. "Update.pic")
|
||||
local temproraryIconPath = resources .. "TempIcon.pic"
|
||||
local appsPerPage = 6
|
||||
|
||||
local mainContainer, window = MineOSInterface.addWindow(MineOSInterface.tabbedWindow(1, 1, 80, 32))
|
||||
@ -31,8 +30,7 @@ local function newApp(x, y, width, applicationListElement, hideDownloadButton)
|
||||
|
||||
app.icon = app:addChild(GUI.image(1, 1, MineOSInterface.iconsCache.script))
|
||||
if applicationListElement.icon then
|
||||
web.download(applicationListElement.icon, temproraryIconPath)
|
||||
app.icon.image = image.load(temproraryIconPath)
|
||||
app.icon.image = MineOSCore.loadImageFromURL(applicationListElement.icon)
|
||||
end
|
||||
|
||||
app.downloadButton = app:addChild(GUI.roundedButton(1, 1, 13, 1, 0x66DB80, 0xFFFFFF, 0x339240, 0xFFFFFF, localization.download))
|
||||
@ -51,11 +49,11 @@ local function newApp(x, y, width, applicationListElement, hideDownloadButton)
|
||||
end
|
||||
app.downloadButton.hidden = hideDownloadButton
|
||||
|
||||
app.pathLabel = app:addChild(GUI.label(app.icon.width + 2, 1, width - app.icon.width - app.downloadButton.width - 3, 1, 0x0, fs.name(applicationListElement.path)))
|
||||
app.versionLabel = app:addChild(GUI.label(app.icon.width + 2, 2, app.pathLabel.width, 1, 0x555555, localization.version .. applicationListElement.version))
|
||||
app.pathLabel = app:addChild(GUI.label(app.icon.width + 3, 1, width - app.icon.width - app.downloadButton.width - 5, 1, 0x0, fs.name(applicationListElement.path)))
|
||||
app.versionLabel = app:addChild(GUI.label(app.icon.width + 3, 2, app.pathLabel.width, 1, 0x555555, localization.version .. applicationListElement.version))
|
||||
if applicationListElement.about then
|
||||
local lines = string.wrap({web.request(applicationListElement.about .. MineOSCore.properties.language .. ".txt")}, app.pathLabel.width)
|
||||
app.aboutTextBox = app:addChild(GUI.textBox(app.icon.width + 2, 3, app.pathLabel.width, #lines, nil, 0x999999, lines, 1, 0, 0))
|
||||
app.aboutTextBox = app:addChild(GUI.textBox(app.icon.width + 3, 3, app.pathLabel.width, #lines, nil, 0x999999, lines, 1, 0, 0))
|
||||
app.aboutTextBox.eventHandler = nil
|
||||
if #lines > 2 then
|
||||
app.height = #lines + 2
|
||||
|
||||
@ -5,6 +5,8 @@ local component = require("component")
|
||||
local buffer = require("doubleBuffering")
|
||||
local filesystem = require("filesystem")
|
||||
local unicode = require("unicode")
|
||||
local image = require("image")
|
||||
local color = require("color")
|
||||
local MineOSPaths = require("MineOSPaths")
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------
|
||||
@ -284,6 +286,85 @@ end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function MineOSCore.loadImageFromURL(url)
|
||||
local bytes = web.request(url)
|
||||
bytes = { string.byte(bytes, 1, #bytes) }
|
||||
|
||||
local signature = string.char(bytes[1], bytes[2], bytes[3], bytes[4])
|
||||
if signature == "OCIF" then
|
||||
local encodingMethod = bytes[5]
|
||||
if encodingMethod == 6 then
|
||||
local width, height = bytes[6], bytes[7]
|
||||
local picture = {width, height}
|
||||
|
||||
local i = 8
|
||||
while i <= #bytes do
|
||||
local alphaSize = bytes[i]
|
||||
i = i + 1
|
||||
|
||||
for a = 1, alphaSize do
|
||||
local alpha = bytes[i] / 255
|
||||
local symbolSize = bit32.bor(bit32.lshift(bytes[i + 1], 8), bytes[i + 2])
|
||||
i = i + 3
|
||||
|
||||
for s = 1, symbolSize do
|
||||
local utf8CharSize = 1
|
||||
for j = 1, 7 do
|
||||
if bit32.band(bit32.rshift(bytes[i], 8 - j), 0x1) == 0x0 then
|
||||
utf8CharSize = j
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local symbol
|
||||
if utf8CharSize == 1 then
|
||||
symbol = string.char(bytes[i])
|
||||
i = i + 1
|
||||
else
|
||||
symbol = string.char(table.unpack(bytes, i, i + utf8CharSize - 2))
|
||||
i = i + utf8CharSize - 1
|
||||
end
|
||||
|
||||
local backgroundSize = bytes[i]
|
||||
i = i + 1
|
||||
|
||||
for b = 1, backgroundSize do
|
||||
local background = color.to24Bit(bytes[i])
|
||||
local foregroundSize = bytes[i + 1]
|
||||
i = i + 2
|
||||
|
||||
for f = 1, foregroundSize do
|
||||
local foreground = color.to24Bit(bytes[i])
|
||||
local ySize = bytes[i + 1]
|
||||
i = i + 2
|
||||
|
||||
for ys = 1, ySize do
|
||||
local y = bytes[i]
|
||||
local xSize = bytes[i + 1]
|
||||
i = i + 2
|
||||
|
||||
for xs = 1, xSize do
|
||||
image.set(picture, bytes[i], y, background, foreground, alpha, symbol)
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return picture
|
||||
else
|
||||
return false, "Unsupported encoding method: " .. encodingMethod
|
||||
end
|
||||
else
|
||||
return false, "Unsupported signature: " .. signature
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
MineOSCore.loadPropeties()
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -576,50 +576,6 @@ end
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
-- local text = {
|
||||
-- "Ты пидор\n\n ебаныйкактыменязаманал,сын шелудивой блядоидной псины, лицензию он не читает, а? Где текст лицензии? Чекнул хоть ради приличия, хуй ты впернутый?",
|
||||
-- "Вот это ебососина, вообще не ожидал. Как так можна? Д@ды ваивале!!11",
|
||||
-- "Тест мультипереноса еба-строчек. Кошка еще скребется, зараза"
|
||||
-- }
|
||||
-- local limit = 20
|
||||
-- local result = string.wrap(text, 20)
|
||||
-- print(string.rep("-", limit))
|
||||
-- for i = 1, #result do
|
||||
-- print(result[i])
|
||||
-- end
|
||||
|
||||
-- local t = {
|
||||
-- "hello",
|
||||
-- "my",
|
||||
-- abc = 123,
|
||||
-- def = {
|
||||
-- cyka = "pidor",
|
||||
-- vagina = {
|
||||
-- chlen = 555,
|
||||
-- devil = 666,
|
||||
-- god = 777,
|
||||
-- serost = {
|
||||
-- tripleTable = "aefaef",
|
||||
-- aaa = "bbb",
|
||||
-- ccc = 123,
|
||||
-- "mda",
|
||||
-- "lol",
|
||||
-- "kek",
|
||||
-- "cheburek",
|
||||
-- }
|
||||
-- }
|
||||
-- },
|
||||
-- ghi = "HEHE",
|
||||
-- emptyTable = {},
|
||||
-- "beautiful",
|
||||
-- "world",
|
||||
-- "meow",
|
||||
-- }
|
||||
|
||||
-- print(table.toString(t, true))
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
return {loaded = true}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user