mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-06 11:12:40 +01:00
Значительный прирост производительности
This commit is contained in:
parent
72e0169f42
commit
65d2936268
@ -4,7 +4,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/OS.lua",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=4.03,
|
||||
version=4.04,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Pictures/MoonTouch.pic",
|
||||
@ -235,13 +235,13 @@
|
||||
path="/lib/MineOSNetwork.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSNetwork.lua",
|
||||
type="Library",
|
||||
version=1.06,
|
||||
version=1.07,
|
||||
},
|
||||
{
|
||||
path="/lib/MineOSInterface.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSInterface.lua",
|
||||
type="Library",
|
||||
version=1.15,
|
||||
version=1.16,
|
||||
},
|
||||
{
|
||||
path="/lib/MineOSPaths.lua",
|
||||
@ -281,7 +281,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/color.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
},
|
||||
{
|
||||
path="/lib/ImageFormatModules/OCIF.lua",
|
||||
@ -308,13 +308,13 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.95,
|
||||
version=1.96,
|
||||
},
|
||||
{
|
||||
path="/lib/rayEngine.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/rayEngine.lua",
|
||||
type="Library",
|
||||
version=1.43,
|
||||
version=1.44,
|
||||
},
|
||||
{
|
||||
path="/lib/json.lua",
|
||||
@ -338,7 +338,7 @@
|
||||
path="/lib/syntax.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/syntax.lua",
|
||||
type="Library",
|
||||
version=1.17,
|
||||
version=1.18,
|
||||
},
|
||||
{
|
||||
path="/lib/palette.lua",
|
||||
@ -351,7 +351,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/doubleBuffering.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.34,
|
||||
version=1.35,
|
||||
},
|
||||
{
|
||||
path="/lib/compressor.lua",
|
||||
@ -381,25 +381,25 @@
|
||||
path="/lib/OpenComputersGL/Main.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Main.lua",
|
||||
type="Library",
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Materials.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Materials.lua",
|
||||
type="Library",
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Renderer.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Renderer.lua",
|
||||
type="Library",
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
},
|
||||
{
|
||||
path="/lib/MeowEngine/Main.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MeowEngine/Main.lua",
|
||||
type="Library",
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
},
|
||||
|
||||
----------------------------------------------------- Скрипты и дополнения к ним --------------------------------------------------------------------------
|
||||
@ -469,7 +469,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic",
|
||||
forceDownload=true,
|
||||
version=1.82,
|
||||
version=1.83,
|
||||
resources={
|
||||
{
|
||||
path="/Localization/Russian.lang",
|
||||
@ -489,7 +489,7 @@
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DTest/Icon.pic",
|
||||
createShortcut=true,
|
||||
forceDownload=true,
|
||||
version=1.22,
|
||||
version=1.23,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/HEX",
|
||||
@ -573,7 +573,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/GeoScan2/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
resources={
|
||||
{
|
||||
path="/Earth.pic",
|
||||
@ -588,7 +588,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/VK/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.36,
|
||||
version=1.37,
|
||||
resources={
|
||||
{
|
||||
path="/VKLogo.pic",
|
||||
@ -603,7 +603,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Finder/Icon.pic",
|
||||
forceDownload=true,
|
||||
version=1.30,
|
||||
version=1.31,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/Weather",
|
||||
@ -612,7 +612,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Weather/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.17,
|
||||
version=1.18,
|
||||
resources={
|
||||
{
|
||||
path="/Cloudy.pic",
|
||||
@ -651,7 +651,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DPrint/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.13,
|
||||
version=1.14,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/FlappyBird",
|
||||
@ -660,7 +660,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/FlappyBird/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.16,
|
||||
version=1.17,
|
||||
resources={
|
||||
{
|
||||
path="/Flappy.pic",
|
||||
@ -675,7 +675,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/RayWalk/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.69,
|
||||
version=1.70,
|
||||
resources={
|
||||
{
|
||||
path="/Localization/Russian.lang",
|
||||
@ -798,7 +798,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/PrintImage/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.16,
|
||||
version=1.17,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/Palette",
|
||||
@ -875,7 +875,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Radio/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.03,
|
||||
version=1.04,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/FuckTheRain",
|
||||
@ -945,7 +945,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Photoshop/Icon.pic",
|
||||
forceDownload=true,
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
resources={
|
||||
{
|
||||
path="/Localization/Russian.lang",
|
||||
@ -971,7 +971,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/HoloClock/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.06,
|
||||
version=1.07,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/AppMarket",
|
||||
@ -1012,7 +1012,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Camera/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.01,
|
||||
version=1.02,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/ChristmasTree",
|
||||
@ -1058,7 +1058,7 @@
|
||||
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/TurretControl/About/",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/TurretControl/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.04,
|
||||
version=1.05,
|
||||
resources={
|
||||
{
|
||||
path="/Turret.pic",
|
||||
@ -1091,7 +1091,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/BufferDemo/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.02,
|
||||
version=1.03,
|
||||
resources={
|
||||
{
|
||||
path="/Wallpaper.pic",
|
||||
|
||||
@ -51,7 +51,7 @@ local colors = {
|
||||
local xOld, yOld = gpu.getResolution()
|
||||
local xSize, ySize = 160, 50
|
||||
gpu.setResolution(160, 50)
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
|
||||
local widthOfToolbar = 33
|
||||
local xToolbar = xSize - widthOfToolbar + 1
|
||||
@ -659,7 +659,7 @@ while true do
|
||||
drawModelOnHologram()
|
||||
elseif action == "Выход" then
|
||||
gpu.setResolution(xOld, yOld)
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
buffer.draw(true)
|
||||
if hologramAvailable then component.hologram.clear() end
|
||||
return
|
||||
|
||||
@ -24,7 +24,7 @@ local meowEngine = require("MeowEngine/Main")
|
||||
|
||||
-- /MineOS/Desktop/3DTest.app/3DTest.lua
|
||||
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
meowEngine.intro(vector.newVector3(0, 0, 0), 20)
|
||||
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
@ -317,7 +317,7 @@ local controls = {
|
||||
local OCGLView = GUI.object(1, 1, mainContainer.width, mainContainer.height)
|
||||
|
||||
local function drawInvertedText(x, y, text)
|
||||
local index = buffer.getIndexByCoordinates(x, y)
|
||||
local index = buffer.getIndex(x, y)
|
||||
local background, foreground = buffer.rawGet(index)
|
||||
buffer.rawSet(index, background, 0xFFFFFF - foreground, text)
|
||||
end
|
||||
|
||||
@ -11,12 +11,13 @@ local xWindow, yWindow = 5, 5
|
||||
|
||||
local fon = image.load("MineOS/Applications/BufferDemo.app/Resources/Wallpaper.pic")
|
||||
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
||||
|
||||
local function drawBackground()
|
||||
--Заполним весь наш экран цветом фона 0x262626, цветом текста 0xFFFFFF и символом " "
|
||||
if not risovatKartinku then
|
||||
buffer.square(1, 1, buffer.width, buffer.height, currentBackground, 0xFFFFFF, " ")
|
||||
buffer.square(1, 1, bufferWidth, bufferHeight, currentBackground, 0xFFFFFF, " ")
|
||||
else
|
||||
buffer.image(1, 1, fon)
|
||||
end
|
||||
@ -119,7 +120,7 @@ while true do
|
||||
drawWindow(xWindow, yWindow)
|
||||
buffer.draw()
|
||||
elseif e[4] == 28 then
|
||||
buffer.square(1, 1, buffer.width, buffer.height, 0x262626, 0xFFFFFF, " ")
|
||||
buffer.square(1, 1, bufferWidth, bufferHeight, 0x262626, 0xFFFFFF, " ")
|
||||
buffer.draw()
|
||||
return
|
||||
elseif e[4] == 57 then
|
||||
|
||||
@ -122,7 +122,7 @@ end
|
||||
|
||||
local xOld, yOld = gpu.getResolution()
|
||||
gpu.setResolution(100, 50)
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
|
||||
gui()
|
||||
ecs.square(1, 2, widthOfImage, heightOfImage - 1, 0x000000)
|
||||
|
||||
@ -160,14 +160,14 @@ end
|
||||
|
||||
window.titlePanel = window:addChild(GUI.panel(1, 1, 1, 3, 0xDDDDDD))
|
||||
|
||||
window.prevButton = window:addChild(GUI.adaptiveRoundedButton(3, 2, 1, 0, 0xFFFFFF, 0x3C3C3C, 0x3C3C3C, 0xFFFFFF, "<"))
|
||||
window.prevButton = window:addChild(GUI.adaptiveRoundedButton(9, 2, 1, 0, 0xFFFFFF, 0x3C3C3C, 0x3C3C3C, 0xFFFFFF, "<"))
|
||||
window.prevButton.onTouch = function()
|
||||
prevOrNextWorkpath(false)
|
||||
end
|
||||
window.prevButton.colors.disabled.background = window.prevButton.colors.default.background
|
||||
window.prevButton.colors.disabled.text = 0xCCCCCC
|
||||
|
||||
window.nextButton = window:addChild(GUI.adaptiveRoundedButton(8, 2, 1, 0, 0xFFFFFF, 0x3C3C3C, 0x3C3C3C, 0xFFFFFF, ">"))
|
||||
window.nextButton = window:addChild(GUI.adaptiveRoundedButton(14, 2, 1, 0, 0xFFFFFF, 0x3C3C3C, 0x3C3C3C, 0xFFFFFF, ">"))
|
||||
window.nextButton.onTouch = function()
|
||||
prevOrNextWorkpath(true)
|
||||
end
|
||||
@ -316,8 +316,7 @@ local function calculateSizes(width, height)
|
||||
window.scrollBar.localPosition.x = window.width
|
||||
window.scrollBar.height = window.backgroundPanel.height
|
||||
window.scrollBar.shownValueCount = window.scrollBar.height - 1
|
||||
|
||||
window.actionButtons.localPosition.y = 1
|
||||
|
||||
window.actionButtons:moveToFront()
|
||||
end
|
||||
|
||||
|
||||
@ -10,7 +10,8 @@ local MineOSCore = require("MineOSCore")
|
||||
local MineOSPaths = require("MineOSPaths")
|
||||
--afaefa
|
||||
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
||||
|
||||
local config = {
|
||||
FPS = 0.05,
|
||||
@ -41,12 +42,12 @@ local columns = {}
|
||||
local pathToHighScores = MineOSPaths.applicationData .. "/FlappyBird/Scores.cfg"
|
||||
local pathToFlappyImage = MineOSCore.getCurrentApplicationResourcesDirectory() .. "Flappy.pic"
|
||||
local bird = image.load(pathToFlappyImage)
|
||||
local xBird, yBird = 8, math.floor(buffer.height / 2 - 3)
|
||||
local xBird, yBird = 8, math.floor(bufferHeight / 2 - 3)
|
||||
local birdIsAlive = true
|
||||
|
||||
local scores = {}
|
||||
local currentScore, currentUser = 0, 0
|
||||
local xScore, yScore = math.floor(buffer.width / 2 - 6), math.floor(buffer.height * 0.16)
|
||||
local xScore, yScore = math.floor(bufferWidth / 2 - 6), math.floor(bufferHeight * 0.16)
|
||||
|
||||
local function drawColumn(x, upperCornerStartPosition)
|
||||
local y = 1
|
||||
@ -56,7 +57,7 @@ local function drawColumn(x, upperCornerStartPosition)
|
||||
y = upperCornerStartPosition + config.columnFreeSpace
|
||||
buffer.square(x, y, config.columnPipeWidth, config.columnPipeHeight, colors.columnAlternative, 0x0, " ")
|
||||
y = y + config.columnPipeHeight
|
||||
buffer.square(x + 1, y, config.columnWidth, buffer.height - y + 1, colors.columnMain, 0x0, " ")
|
||||
buffer.square(x + 1, y, config.columnWidth, bufferHeight - y + 1, colors.columnMain, 0x0, " ")
|
||||
end
|
||||
|
||||
local function dieBirdDie()
|
||||
@ -67,8 +68,8 @@ local function dieBirdDie()
|
||||
end
|
||||
|
||||
local function generateColumn()
|
||||
local yFreeZone = math.random(config.columnPipeHeight + 2, buffer.height - config.columnPipeHeight - config.columnFreeSpace)
|
||||
table.insert(columns, {x = buffer.width - 1, yFreeZone = yFreeZone})
|
||||
local yFreeZone = math.random(config.columnPipeHeight + 2, bufferHeight - config.columnPipeHeight - config.columnFreeSpace)
|
||||
table.insert(columns, {x = bufferWidth - 1, yFreeZone = yFreeZone})
|
||||
end
|
||||
|
||||
local scoreCanBeAdded = true
|
||||
@ -113,7 +114,7 @@ end
|
||||
|
||||
local function drawBigCenterText(y, textColor, usePseudoShadow, text)
|
||||
local width = bigLetters.getTextSize(text)
|
||||
local x = math.floor(buffer.width / 2 - width / 2)
|
||||
local x = math.floor(bufferWidth / 2 - width / 2)
|
||||
|
||||
if usePseudoShadow then buffer.square(x - 2, y - 1, width + 4, 7, colors.scoreTextBackground, 0x0, " ") end
|
||||
bigLetters.drawText(x, y, textColor, text)
|
||||
@ -197,8 +198,8 @@ local function finalGUI()
|
||||
local heightOfBoard = 40
|
||||
|
||||
local function draw()
|
||||
local y = math.floor(buffer.height / 2 - 19)
|
||||
local x = math.floor(buffer.width / 2 - widthOfBoard / 2)
|
||||
local y = math.floor(bufferHeight / 2 - 19)
|
||||
local x = math.floor(bufferWidth / 2 - widthOfBoard / 2)
|
||||
|
||||
drawAll()
|
||||
|
||||
@ -234,7 +235,7 @@ local function finalGUI()
|
||||
scoreCanBeAdded = true
|
||||
columns = {}
|
||||
bird = image.load(pathToFlappyImage)
|
||||
yBird = math.floor(buffer.height / 2 - 3)
|
||||
yBird = math.floor(bufferHeight / 2 - 3)
|
||||
drawAll()
|
||||
wait()
|
||||
return
|
||||
@ -273,7 +274,7 @@ while true do
|
||||
end
|
||||
|
||||
if not somethingHappend then
|
||||
if yBird + image.getHeight(bird) - 1 < buffer.height then
|
||||
if yBird + image.getHeight(bird) - 1 < bufferHeight then
|
||||
yBird = yBird + config.birdFlyDownSpeed
|
||||
else
|
||||
scores[currentUser] = math.max(scores[currentUser] or 0, currentScore)
|
||||
|
||||
@ -17,12 +17,13 @@ if not component.isAvailable("hologram") then
|
||||
end
|
||||
|
||||
component.gpu.setResolution(component.gpu.maxResolution())
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
||||
|
||||
local resourcesDirectory = MineOSCore.getCurrentApplicationResourcesDirectory()
|
||||
local earthImage = image.load(resourcesDirectory .. "Earth.pic")
|
||||
|
||||
local onScreenDataXOffset, onScreenDataYOffset = math.floor(buffer.width / 2), buffer.height
|
||||
local onScreenDataXOffset, onScreenDataYOffset = math.floor(bufferWidth / 2), bufferHeight
|
||||
local onProjectorDataYOffset = 0
|
||||
local scanResult = {horizontalRange = 0, verticalRange = 0}
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
@ -69,7 +70,7 @@ end
|
||||
|
||||
local function progressReport(value, text)
|
||||
local width = 40
|
||||
local x, y = math.floor(buffer.width / 2 - width / 2), math.floor(buffer.height / 2)
|
||||
local x, y = math.floor(bufferWidth / 2 - width / 2), math.floor(bufferHeight / 2)
|
||||
GUI.progressBar(x, y, width, 0x00B6FF, 0xFFFFFF, 0xEEEEEE, value, true, true, text, "%"):draw()
|
||||
buffer.draw()
|
||||
end
|
||||
@ -111,10 +112,10 @@ mainContainer.draw = function()
|
||||
end
|
||||
|
||||
local panelWidth = 30
|
||||
local panelX = buffer.width - panelWidth + 1
|
||||
local panelX = bufferWidth - panelWidth + 1
|
||||
local buttonX, objectY = panelX + 2, 2
|
||||
local buttonWidth = panelWidth - 4
|
||||
mainContainer:addChild(GUI.panel(panelX, 1, panelWidth, buffer.height, 0x444444))
|
||||
mainContainer:addChild(GUI.panel(panelX, 1, panelWidth, bufferHeight, 0x444444))
|
||||
|
||||
mainContainer.planetImage = mainContainer:addChild(GUI.image(buttonX, objectY, earthImage))
|
||||
objectY = objectY + mainContainer.planetImage.image[2] + 1
|
||||
@ -173,21 +174,21 @@ end
|
||||
objectY = objectY + 2
|
||||
|
||||
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Projector update:"))
|
||||
mainContainer.projectorUpdateSwitch = mainContainer:addChild(GUI.switch(buffer.width - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
|
||||
mainContainer.projectorUpdateSwitch = mainContainer:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
|
||||
objectY = objectY + 2
|
||||
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Glasses update:"))
|
||||
mainContainer.glassesUpdateSwitch = mainContainer:addChild(GUI.switch(buffer.width - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
|
||||
mainContainer.glassesUpdateSwitch = mainContainer:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
|
||||
objectY = objectY + 2
|
||||
|
||||
mainContainer:addChild(GUI.button(buffer.width, 1, 1, 1, nil, 0xEEEEEE, nil, 0xFF2222, "X")).onTouch = function()
|
||||
mainContainer:addChild(GUI.button(bufferWidth, 1, 1, 1, nil, 0xEEEEEE, nil, 0xFF2222, "X")).onTouch = function()
|
||||
mainContainer:stopEventHandling()
|
||||
createDick(math.random(-48, 48), math.random(1, 32), math.random(-48, 48), 100, true)
|
||||
end
|
||||
|
||||
mainContainer:addChild(GUI.button(panelX, buffer.height - 5, panelWidth, 3, 0x353535, 0xEEEEEE, 0xAAAAAA, 0x262626, "Update")).onTouch = function()
|
||||
mainContainer:addChild(GUI.button(panelX, bufferHeight - 5, panelWidth, 3, 0x353535, 0xEEEEEE, 0xAAAAAA, 0x262626, "Update")).onTouch = function()
|
||||
updateData(false, true, true)
|
||||
end
|
||||
mainContainer.scanButton = mainContainer:addChild(GUI.button(panelX, buffer.height - 2, panelWidth, 3, 0x262626, 0xEEEEEE, 0xAAAAAA, 0x262626, "Scan"))
|
||||
mainContainer.scanButton = mainContainer:addChild(GUI.button(panelX, bufferHeight - 2, panelWidth, 3, 0x262626, 0xEEEEEE, 0xAAAAAA, 0x262626, "Scan"))
|
||||
mainContainer.scanButton.onTouch = function()
|
||||
scanResult = {}
|
||||
local horizontalRange, verticalRange = math.floor(mainContainer.horizontalScanRangeSlider.value), math.floor(mainContainer.verticalScanRangeSlider.value)
|
||||
|
||||
@ -198,15 +198,15 @@ end
|
||||
|
||||
local function drawOnScreen()
|
||||
local width, height = 58, 7
|
||||
local x, y = math.floor(buffer.width / 2 - width / 2), math.floor(buffer.height / 2 - height / 2)
|
||||
local x, y = math.floor(buffer.getWidth() / 2 - width / 2), math.floor(buffer.getHeight() / 2 - height / 2)
|
||||
|
||||
drawText(x, y, "88:88", 0x000000)
|
||||
drawText(x, y, date, config.dateColor)
|
||||
|
||||
y = y + 9
|
||||
GUI.label(1, y, buffer.width, 1, config.dateColor, "Press R to randomize clock color, scroll to change projection scale,"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top):draw(); y = y + 1
|
||||
GUI.label(1, y, buffer.width, 1, config.dateColor, "or press Enter to save and quit"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top):draw()
|
||||
-- GUI.label(1, y, buffer.width, 1, 0xFFFFFF, ""):draw()
|
||||
GUI.label(1, y, buffer.getWidth(), 1, config.dateColor, "Press R to randomize clock color, scroll to change projection scale,"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top):draw(); y = y + 1
|
||||
GUI.label(1, y, buffer.getWidth(), 1, config.dateColor, "or press Enter to save and quit"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top):draw()
|
||||
-- GUI.label(1, y, buffer.getWidth(), 1, 0xFFFFFF, ""):draw()
|
||||
|
||||
buffer.draw()
|
||||
end
|
||||
|
||||
@ -248,7 +248,7 @@ end
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function calculateSizes()
|
||||
mainContainer.width, mainContainer.height = buffer.width, buffer.height
|
||||
mainContainer.width, mainContainer.height = buffer.getResolution()
|
||||
|
||||
if mainContainer.leftTreeView.hidden then
|
||||
mainContainer.codeView.localPosition.x, mainContainer.codeView.width = 1, mainContainer.width
|
||||
|
||||
@ -21,7 +21,7 @@ local event = require("event")
|
||||
------------------------------------------------ Переменные --------------------------------------------------------------
|
||||
|
||||
--Инициализируем библиотеку двойного буфера
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
|
||||
--Массив локалиации
|
||||
local localization = MineOSCore.getCurrentApplicationLocalization()
|
||||
@ -61,12 +61,12 @@ local sizes = {
|
||||
widthOfLeftBar = 6,
|
||||
}
|
||||
sizes.xStartOfDrawingArea = sizes.widthOfLeftBar + 1
|
||||
sizes.xEndOfDrawingArea = buffer.width
|
||||
sizes.xEndOfDrawingArea = buffer.getWidth()
|
||||
sizes.yStartOfDrawingArea = 2
|
||||
sizes.yEndOfDrawingArea = buffer.height - 1
|
||||
sizes.yEndOfDrawingArea = buffer.getHeight() - 1
|
||||
sizes.widthOfDrawingArea = sizes.xEndOfDrawingArea - sizes.xStartOfDrawingArea + 1
|
||||
sizes.heightOfDrawingArea = sizes.yEndOfDrawingArea - sizes.yStartOfDrawingArea + 1
|
||||
sizes.heightOfLeftBar = buffer.height - 1
|
||||
sizes.heightOfLeftBar = buffer.getHeight() - 1
|
||||
sizes.sizeOfPixelData = 4
|
||||
|
||||
--Для изображения
|
||||
@ -161,7 +161,7 @@ end
|
||||
|
||||
--Отрисовка цветов
|
||||
local function drawColors()
|
||||
local xPos, yPos = 2, buffer.height - 4
|
||||
local xPos, yPos = 2, buffer.getHeight() - 4
|
||||
buffer.square(xPos, yPos, 3, 2, currentBackground, 0xFFFFFF, " ")
|
||||
buffer.square(xPos + 3, yPos + 1, 1, 2, currentForeground, 0xFFFFFF, " ")
|
||||
buffer.square(xPos + 1, yPos + 2, 2, 1, currentForeground, 0xFFFFFF, " ")
|
||||
@ -197,7 +197,7 @@ end
|
||||
|
||||
--Отрисовка верхнего меню
|
||||
local function drawTopMenu()
|
||||
obj.menu = GUI.menu(1, 1, buffer.width, colors.topMenu, colors.topMenuText, 0x3366CC, 0xFFFFFF, 0)
|
||||
obj.menu = GUI.menu(1, 1, buffer.getWidth(), colors.topMenu, colors.topMenuText, 0x3366CC, 0xFFFFFF, 0)
|
||||
obj.menu:addItem("PS", ecs.colors.blue)
|
||||
obj.menu:addItem(localization.file)
|
||||
obj.menu:addItem(localization.image)
|
||||
@ -220,13 +220,13 @@ end
|
||||
|
||||
--Мини-консолька для отладки, сообщающая снизу, че происходит ваще
|
||||
local function console(text)
|
||||
buffer.square(sizes.xStartOfDrawingArea, buffer.height, sizes.widthOfDrawingArea, 1, colors.console, colors.consoleText, " ")
|
||||
buffer.square(sizes.xStartOfDrawingArea, buffer.getHeight(), sizes.widthOfDrawingArea, 1, colors.console, colors.consoleText, " ")
|
||||
|
||||
local _, total, used = ecs.getInfoAboutRAM()
|
||||
local RAMText = used .. "/" .. total .. " KB RAM"
|
||||
buffer.text(sizes.xEndOfDrawingArea - unicode.len(RAMText), buffer.height, colors.consoleText, RAMText)
|
||||
buffer.text(sizes.xEndOfDrawingArea - unicode.len(RAMText), buffer.getHeight(), colors.consoleText, RAMText)
|
||||
|
||||
buffer.text(sizes.xStartOfDrawingArea + 1, buffer.height, colors.consoleText, text)
|
||||
buffer.text(sizes.xStartOfDrawingArea + 1, buffer.getHeight(), colors.consoleText, text)
|
||||
end
|
||||
|
||||
--Функция, берущая указанный пиксель из массива изображения и рисующая его в буфере корректно,
|
||||
@ -1007,10 +1007,10 @@ while true do
|
||||
for key in pairs(obj["Colors"]) do
|
||||
if ecs.clickedAtArea(e[3], e[4], obj["Colors"][key][1], obj["Colors"][key][2], obj["Colors"][key][3], obj["Colors"][key][4]) then
|
||||
if key == 1 then
|
||||
currentBackground = palette.show(math.floor(buffer.width / 2 - 35), math.floor(buffer.height / 2 - 12), currentBackground) or currentBackground
|
||||
currentBackground = palette.show(math.floor(buffer.getWidth() / 2 - 35), math.floor(buffer.getHeight() / 2 - 12), currentBackground) or currentBackground
|
||||
drawAll()
|
||||
elseif key == 2 or key == 3 then
|
||||
currentForeground = palette.show(math.floor(buffer.width / 2 - 35), math.floor(buffer.height / 2 - 12), currentForeground) or currentForeground
|
||||
currentForeground = palette.show(math.floor(buffer.getWidth() / 2 - 35), math.floor(buffer.getHeight() / 2 - 12), currentForeground) or currentForeground
|
||||
drawAll()
|
||||
elseif key == 4 then
|
||||
buffer.text(obj["Colors"][key][1], obj["Colors"][key][2], 0xFF0000, "←→")
|
||||
@ -1305,8 +1305,8 @@ while true do
|
||||
else
|
||||
local x, y, width, height = e[3], e[4], 30, 12
|
||||
--А это чтоб за края экрана не лезло
|
||||
if y + height >= buffer.height then y = buffer.height - height end
|
||||
if x + width + 1 >= buffer.width then x = buffer.width - width - 1 end
|
||||
if y + height >= buffer.getHeight() then y = buffer.getHeight() - height end
|
||||
if x + width + 1 >= buffer.getWidth() then x = buffer.getWidth() - width - 1 end
|
||||
|
||||
currentBrushSize, currentAlpha = table.unpack(ecs.universalWindow(x, y, width, 0xeeeeee, true, {"EmptyLine"}, {"CenterText", 0x880000, localization.brushParameters}, {"Slider", 0x262626, 0x880000, 1, 10, currentBrushSize, localization.size .. ": ", " px"}, {"Slider", 0x262626, 0x880000, 0, 255, currentAlpha, localization.transparency .. ": ", ""}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}}))
|
||||
buffer.draw()
|
||||
|
||||
@ -104,7 +104,7 @@ local function beginPrint()
|
||||
addShapePixel(i, jReplacer - 1, foreground, xImage, yImage * 2)
|
||||
end
|
||||
|
||||
GUI.progressBar(math.floor(buffer.width / 2 - 25), math.floor(buffer.height / 2), 50, 0x3366CC, 0xFFFFFF, 0xFFFFFF, math.ceil(counter * 100 / (xShapeCount * yShapeCount)), true, true, "Progress: ", "%"):draw()
|
||||
GUI.progressBar(math.floor(buffer.getWidth() / 2 - 25), math.floor(buffer.getHeight() / 2), 50, 0x3366CC, 0xFFFFFF, 0xFFFFFF, math.ceil(counter * 100 / (xShapeCount * yShapeCount)), true, true, "Progress: ", "%"):draw()
|
||||
buffer.draw()
|
||||
-- else
|
||||
-- error("Printing out of mainImage range")
|
||||
@ -172,8 +172,8 @@ end
|
||||
|
||||
local function drawMainImageObject(object)
|
||||
if mainImage then
|
||||
local xImage = image.getWidth(mainImage) < buffer.width and math.floor(buffer.width / 2 - image.getWidth(mainImage) / 2) or 1
|
||||
local yImage = image.getHeight(mainImage) < buffer.height and math.floor(buffer.height / 2 - image.getHeight(mainImage) / 2) or 1
|
||||
local xImage = image.getWidth(mainImage) < buffer.getWidth() and math.floor(buffer.getWidth() / 2 - image.getWidth(mainImage) / 2) or 1
|
||||
local yImage = image.getHeight(mainImage) < buffer.getHeight() and math.floor(buffer.getHeight() / 2 - image.getHeight(mainImage) / 2) or 1
|
||||
buffer.image(xImage, yImage, mainImage)
|
||||
GUI.windowShadow(xImage, yImage, image.getWidth(mainImage), image.getHeight(mainImage), 50, true)
|
||||
if config.showGrid then
|
||||
@ -308,7 +308,7 @@ end
|
||||
|
||||
----------------------------------------- Shitty meatball rolls -----------------------------------------
|
||||
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
load()
|
||||
getPrinters()
|
||||
createWindow()
|
||||
|
||||
@ -68,7 +68,7 @@ local function drawStation(x, y, name, color)
|
||||
end
|
||||
|
||||
local function drawLine()
|
||||
local x = math.floor(buffer.width / 2)
|
||||
local x = math.floor(buffer.getWidth() / 2)
|
||||
for i = 1, lineHeight do
|
||||
buffer.text(x + 1, i, config.colors.lineShadow, "▎")
|
||||
buffer.text(x, i, config.colors.line, "▍")
|
||||
@ -101,7 +101,7 @@ end
|
||||
|
||||
local function drawMenu()
|
||||
local width = 36 + (3 * 2 + 2) * #radioStations
|
||||
local x, y = math.floor(buffer.width / 2 - width / 2), lineHeight + math.floor((buffer.height - lineHeight) / 2 - 1)
|
||||
local x, y = math.floor(buffer.getWidth() / 2 - width / 2), lineHeight + math.floor((buffer.getHeight() - lineHeight) / 2 - 1)
|
||||
|
||||
obj.gromkostPlus = {x, y, x + 4, y + 3}
|
||||
x = bigLetters.drawText(x, y, config.colors.bottomToolBarDefaultColor, "+", "*") + 1
|
||||
@ -132,7 +132,7 @@ local function drawStations()
|
||||
-- Текущая станция
|
||||
name = ecs.stringLimit("end", unicode.lower(radioStations[radioStations.currentStation].name), stationNameLimit, true)
|
||||
currentWidth = bigLetters.getTextSize(name)
|
||||
local x, y = math.floor(buffer.width / 2 - currentWidth / 2), math.floor(buffer.height / 2 - 3)
|
||||
local x, y = math.floor(buffer.getWidth() / 2 - currentWidth / 2), math.floor(buffer.getHeight() / 2 - 3)
|
||||
drawStation(x, y, name, config.colors.activeStation)
|
||||
|
||||
-- Предедущая
|
||||
@ -159,7 +159,7 @@ local function drawAll()
|
||||
radioStations.currentStation = #radioStations
|
||||
end
|
||||
|
||||
buffer.square(1, 1, buffer.width, buffer.height, config.colors.background, 0xFFFFFF, " ")
|
||||
buffer.square(1, 1, buffer.getWidth(), buffer.getHeight(), config.colors.background, 0xFFFFFF, " ")
|
||||
|
||||
drawStations()
|
||||
drawLine()
|
||||
@ -214,8 +214,8 @@ local function volume(i)
|
||||
end
|
||||
|
||||
|
||||
buffer.start()
|
||||
lineHeight = math.floor(buffer.height * 0.7)
|
||||
buffer.flush()
|
||||
lineHeight = math.floor(buffer.getHeight() * 0.7)
|
||||
loadStations()
|
||||
radio.stop()
|
||||
radio.setURL(radioStations[radioStations.currentStation].url)
|
||||
@ -292,7 +292,7 @@ while true do
|
||||
{"Button", {ecs.colors.orange, 0xffffff, "OK"}}
|
||||
)
|
||||
elseif action == "Выход" then
|
||||
buffer.square(1, 1, buffer.width, buffer.height, config.colors.background, 0xFFFFFF, " ")
|
||||
buffer.square(1, 1, buffer.getWidth(), buffer.getHeight(), config.colors.background, 0xFFFFFF, " ")
|
||||
buffer.draw()
|
||||
ecs.prepareToExit()
|
||||
radio.stop()
|
||||
|
||||
@ -25,7 +25,7 @@ local function menuBackground()
|
||||
end
|
||||
|
||||
local function settings()
|
||||
local window = GUI.container(1, 1, buffer.width, buffer.height, buffer.width, buffer.height)
|
||||
local window = GUI.fullScreenContainer()
|
||||
local oldDraw = window.draw
|
||||
window.draw = function()
|
||||
menuBackground()
|
||||
@ -37,9 +37,9 @@ local function settings()
|
||||
|
||||
window:addChild(GUI.label(1, y, window.width, 1, 0xFFFFFF, localization.rayEngineProperties)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3
|
||||
|
||||
local resolutionTextBoxWidth = window:addChild(GUI.input(x, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(buffer.width), nil, true))
|
||||
local resolutionTextBoxWidth = window:addChild(GUI.input(x, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(buffer.getWidth()), nil, true))
|
||||
window:addChild(GUI.label(x + textBoxWidth + 2, y + 1, 1, 1, 0xFFFFFF, "X"))
|
||||
local resolutionTextBoxHeight = window:addChild(GUI.input(x + textBoxWidth + 5, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(buffer.height), nil, true)); y = y + 4
|
||||
local resolutionTextBoxHeight = window:addChild(GUI.input(x + textBoxWidth + 5, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(buffer.getHeight()), nil, true)); y = y + 4
|
||||
window:addChild(GUI.label(1, y, window.width, 1, 0xDDDDDD, localization.screenResolution)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3
|
||||
resolutionTextBoxWidth.validator = function(text) local num = tonumber(text); if num and num >= 40 and num <= 160 then return true end end
|
||||
resolutionTextBoxHeight.validator = function(text) local num = tonumber(text); if num and num >= 12 and num <= 50 then return true end end
|
||||
@ -113,7 +113,7 @@ local function settings()
|
||||
end
|
||||
|
||||
local function menu()
|
||||
local window = GUI.container(1, 1, buffer.width, buffer.height, buffer.width, buffer.height)
|
||||
local window = GUI.fullScreenContainer()
|
||||
local oldDraw = window.draw
|
||||
window.draw = function()
|
||||
menuBackground()
|
||||
|
||||
@ -11,7 +11,7 @@ local unicode = require("unicode")
|
||||
|
||||
-- /MineOS/Applications/TurretControl.app/TurretControl.lua
|
||||
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
local pathToTurretPicture = "MineOS/Applications/TurretControl.app/Resources/Turret.pic"
|
||||
local turretImage = image.load(pathToTurretPicture)
|
||||
local turrets = {}
|
||||
@ -29,8 +29,8 @@ local spaceBetweenTurretsHorizontal = 2
|
||||
local spaceBetweenTurretsVertical = 1
|
||||
local turretHeight = turretImage[2] + 12
|
||||
local turretWidth = turretImage[1] + 8
|
||||
local countOfTurretsCanBeShowByWidth = math.floor(buffer.width / (turretWidth + spaceBetweenTurretsHorizontal))
|
||||
local xTurrets = math.floor(buffer.width / 2 - (countOfTurretsCanBeShowByWidth * (turretWidth + spaceBetweenTurretsHorizontal)) / 2 ) + math.floor(spaceBetweenTurretsHorizontal / 2)
|
||||
local countOfTurretsCanBeShowByWidth = math.floor(buffer.getWidth() / (turretWidth + spaceBetweenTurretsHorizontal))
|
||||
local xTurrets = math.floor(buffer.getWidth() / 2 - (countOfTurretsCanBeShowByWidth * (turretWidth + spaceBetweenTurretsHorizontal)) / 2 ) + math.floor(spaceBetweenTurretsHorizontal / 2)
|
||||
|
||||
local yellowColor = 0xFFDB40
|
||||
|
||||
@ -95,8 +95,8 @@ local function drawTurrets(y)
|
||||
|
||||
if #turrets <= 0 then
|
||||
local text = "Подключите турели из мода OpenModularTurrets"
|
||||
local x = math.floor(buffer.width / 2 - unicode.len(text) / 2)
|
||||
buffer.text(x, math.floor(buffer.height / 2 - 2), yellowColor, text)
|
||||
local x = math.floor(buffer.getWidth() / 2 - unicode.len(text) / 2)
|
||||
buffer.text(x, math.floor(buffer.getHeight() / 2 - 2), yellowColor, text)
|
||||
return
|
||||
end
|
||||
|
||||
@ -130,7 +130,7 @@ local function drawTurrets(y)
|
||||
end
|
||||
|
||||
local function drawSeparator(y)
|
||||
buffer.text(1, y, yellowColor, string.rep("─", buffer.width))
|
||||
buffer.text(1, y, yellowColor, string.rep("─", buffer.getWidth()))
|
||||
end
|
||||
|
||||
local function drawButtonWithState(x, y, width, height, text, state)
|
||||
@ -145,18 +145,18 @@ end
|
||||
|
||||
local function drawBottomBar()
|
||||
local height = 6
|
||||
local y = buffer.height - height + 1
|
||||
buffer.square(1, y, buffer.width, height, 0x000000, yellowColor, " ")
|
||||
local y = buffer.getHeight() - height + 1
|
||||
buffer.square(1, y, buffer.getWidth(), height, 0x000000, yellowColor, " ")
|
||||
drawSeparator(y)
|
||||
local text = " ECS® Security Systems™ "
|
||||
local x = math.floor(buffer.width / 2 - unicode.len(text) / 2)
|
||||
local x = math.floor(buffer.getWidth() / 2 - unicode.len(text) / 2)
|
||||
buffer.text(x, y, yellowColor, text)
|
||||
|
||||
y = y + 2
|
||||
|
||||
local widthOfButton = 19
|
||||
local totalWidth = (widthOfButton + 2) * 6
|
||||
local x = math.floor(buffer.width / 2 - totalWidth / 2) + 1
|
||||
local x = math.floor(buffer.getWidth() / 2 - totalWidth / 2) + 1
|
||||
|
||||
newObj("BottomButtons", "On", x, y, x + widthOfButton - 1, y + 2)
|
||||
x = drawButtonWithState(x, y, widthOfButton, 3, turretConfig.turretsOn and "Турели ВКЛ" or "Турели ВЫКЛ", turretConfig.turretsOn)
|
||||
|
||||
@ -55,13 +55,13 @@ local colors = {
|
||||
messsageInputBarTextColor = 0x262626,
|
||||
}
|
||||
|
||||
local leftBarHeight = buffer.height - 9
|
||||
local leftBarWidth = math.floor(buffer.width * 0.20)
|
||||
local leftBarHeight = buffer.getHeight() - 9
|
||||
local leftBarWidth = math.floor(buffer.getWidth() * 0.20)
|
||||
|
||||
local topBarHeight = 3
|
||||
|
||||
local mainZoneWidth = buffer.width - leftBarWidth
|
||||
local mainZoneHeight = buffer.height - topBarHeight - 1
|
||||
local mainZoneWidth = buffer.getWidth() - leftBarWidth
|
||||
local mainZoneHeight = buffer.getHeight() - topBarHeight - 1
|
||||
local mainZoneX = leftBarWidth + 1
|
||||
local mainZoneY = topBarHeight + 1
|
||||
|
||||
@ -313,7 +313,7 @@ local function loginGUI(startUsername, startPassword)
|
||||
|
||||
local textFieldWidth = 50
|
||||
local textFieldHeight = 3
|
||||
local x, y = math.floor(buffer.width / 2 - textFieldWidth / 2), math.floor(buffer.height / 2)
|
||||
local x, y = math.floor(buffer.getWidth() / 2 - textFieldWidth / 2), math.floor(buffer.getHeight() / 2)
|
||||
|
||||
local obj = {}
|
||||
obj.username = {x, y, x + textFieldWidth - 1, y + 2}; y = y + textFieldHeight + 1
|
||||
@ -371,8 +371,8 @@ local function drawPersonalAvatar(x, y, width, height)
|
||||
end
|
||||
|
||||
local function status(text)
|
||||
buffer.square(mainZoneX, buffer.height, mainZoneWidth, 1, colors.statusBar, 0x0, " ")
|
||||
buffer.text(mainZoneX + 1, buffer.height, colors.statusBarText, text)
|
||||
buffer.square(mainZoneX, buffer.getHeight(), mainZoneWidth, 1, colors.statusBar, 0x0, " ")
|
||||
buffer.text(mainZoneX + 1, buffer.getHeight(), colors.statusBarText, text)
|
||||
buffer.draw()
|
||||
end
|
||||
|
||||
@ -446,7 +446,7 @@ local function getAttachments(messageArray)
|
||||
end
|
||||
|
||||
local function drawMessageInputBar(currentText)
|
||||
local x, y = mainZoneX, buffer.height - 5
|
||||
local x, y = mainZoneX, buffer.getHeight() - 5
|
||||
buffer.square(x, y, mainZoneWidth, 5, colors.messageInputBarColor, 0x0, " ")
|
||||
obj.messageInputBar = GUI.input(x + 2, y + 1, mainZoneWidth - 4, 3, 0xFFFFFF, 0x444444, 0x444444, 0xFFFFFF, 0x262626, nil, "Введите сообщение", true)
|
||||
obj.messageInputBar:draw()
|
||||
@ -494,9 +494,9 @@ local function messagesGUI()
|
||||
|
||||
buffer.setDrawLimit(mainZoneX, mainZoneY, mainZoneX + mainZoneWidth - 1, mainZoneY + mainZoneHeight - 1)
|
||||
|
||||
local y = buffer.height - 7
|
||||
local y = buffer.getHeight() - 7
|
||||
local xSender = mainZoneX + 2
|
||||
local xYou = buffer.width - 7
|
||||
local xYou = buffer.getWidth() - 7
|
||||
|
||||
for i = 1, #messages.response.items do
|
||||
|
||||
@ -629,7 +629,7 @@ local function dialogsGUI()
|
||||
if dialogs.response.items[i].unread and dialogs.response.items[i].unread ~= 0 then
|
||||
local cyka = tostring(dialogs.response.items[i].unread)
|
||||
local cykaWidth = unicode.len(cyka) + 2
|
||||
local cykaX = buffer.width - cykaWidth - 2
|
||||
local cykaX = buffer.getWidth() - cykaWidth - 2
|
||||
buffer.square(cykaX, y + 2, cykaWidth, 1, ecs.colors.blue, 0x0, " ")
|
||||
buffer.text(cykaX + 1, y + 2, 0xFFFFFF, cyka)
|
||||
end
|
||||
@ -754,7 +754,7 @@ local function userProfileGUI()
|
||||
local function drawInfo(x, y2, key, value)
|
||||
if checkField(value) then
|
||||
value = {value}
|
||||
value = string.wrap(value, buffer.width - x - 4 - informationOffset)
|
||||
value = string.wrap(value, buffer.getWidth() - x - 4 - informationOffset)
|
||||
buffer.text(x, y2, informationKeyColor, key)
|
||||
for i = 1, #value do
|
||||
buffer.text(x + informationOffset, y2, informationValueColor, value[i])
|
||||
@ -766,7 +766,7 @@ local function userProfileGUI()
|
||||
|
||||
local function drawSeparator(x, y2, text)
|
||||
buffer.text(x, y2, informationTitleColor, text)
|
||||
buffer.text(x + unicode.len(text) + 1, y2, informationSeparatorColor, string.rep("─", buffer.width - x - unicode.len(text)))
|
||||
buffer.text(x + unicode.len(text) + 1, y2, informationSeparatorColor, string.rep("─", buffer.getWidth() - x - unicode.len(text)))
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
@ -796,7 +796,7 @@ local function userProfileGUI()
|
||||
|
||||
-- А ВОТ И СТЕНОЧКА ПОДЪЕХАЛА НА ПРАЗДНИК ДУШИ
|
||||
y = y + 1
|
||||
buffer.square(x, y, buffer.width - x - 2, 1, 0xCCCCCC, 0x0, " "); buffer.text(x + 1, y, 0x262626, "Стена"); y = y + 2
|
||||
buffer.square(x, y, buffer.getWidth() - x - 2, 1, 0xCCCCCC, 0x0, " "); buffer.text(x + 1, y, 0x262626, "Стена"); y = y + 2
|
||||
--Перебираем всю стенку
|
||||
for i = 1, #currentProfile.wall.response.items do
|
||||
--Если это не репост или еще не хуйня какая-то
|
||||
@ -805,10 +805,10 @@ local function userProfileGUI()
|
||||
drawAvatar(x, y, 6, 3, currentProfile.wall.response.items[i].from_id, unicode.sub(currentProfile.userNames[currentProfile.wall.response.items[i].from_id].first_name, 1, 1) .. unicode.sub(currentProfile.userNames[currentProfile.wall.response.items[i].from_id].last_name, 1, 1))
|
||||
buffer.text(x + 8, y, informationValueColor, currentProfile.userNames[currentProfile.wall.response.items[i].from_id].first_name .. " " .. currentProfile.userNames[currentProfile.wall.response.items[i].from_id].last_name)
|
||||
local date = os.date("%d.%m.%y в %H:%M", currentProfile.wall.response.items[i].date)
|
||||
buffer.text(buffer.width - unicode.len(date) - 2, y, 0xCCCCCC, date)
|
||||
buffer.text(buffer.getWidth() - unicode.len(date) - 2, y, 0xCCCCCC, date)
|
||||
y = y + 1
|
||||
local text = {currentProfile.wall.response.items[i].text}
|
||||
text = string.wrap(text, buffer.width - x - 10)
|
||||
text = string.wrap(text, buffer.getWidth() - x - 10)
|
||||
for i = 1, #text do
|
||||
buffer.text(x + 8, y, 0x000000, text[i])
|
||||
y = y + 1
|
||||
@ -966,7 +966,7 @@ local function newsGUI()
|
||||
end
|
||||
end
|
||||
--Делаем его еще пизже
|
||||
local text = {news.response.items[item].text}; text = string.wrap(text, buffer.width - x - 10)
|
||||
local text = {news.response.items[item].text}; text = string.wrap(text, buffer.getWidth() - x - 10)
|
||||
--Получаем инфу нужную
|
||||
local avatarText, name = getAvatarTextAndNameForNews(news.response.items[item].source_id)
|
||||
--Сместиться потом на стока вот
|
||||
@ -1003,7 +1003,7 @@ end
|
||||
|
||||
local function drawLeftBar()
|
||||
--Подложка под элементы
|
||||
buffer.square(1, 1, leftBarWidth, buffer.height, colors.leftBar, 0xFFFFFF, " ")
|
||||
buffer.square(1, 1, leftBarWidth, buffer.getHeight(), colors.leftBar, 0xFFFFFF, " ")
|
||||
|
||||
if personalInfo then
|
||||
drawPersonalAvatar(3, 2, 6, 3)
|
||||
@ -1085,7 +1085,7 @@ end
|
||||
|
||||
--Инициализируем библиотеку двойного буффера
|
||||
--Эх, что бы я делал, если б не накодил ее? 0.2 фпс на GPU мертвеца!
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
--Хуярим настррррроечки
|
||||
loadSettings()
|
||||
--Активируем форму логина
|
||||
|
||||
@ -182,13 +182,13 @@ local function drawWeather()
|
||||
--Рисуем обоинку или просто говнофон ССАНЫЙ
|
||||
if fs.exists(MineOSCore.properties.wallpaper or "---aefaefaefaefae") then
|
||||
buffer.image(1, 1, image.load(MineOSCore.properties.wallpaper))
|
||||
buffer.square(1, 1, buffer.width, buffer.height, 0x0, 0x0, " ", 0.6)
|
||||
buffer.square(1, 1, buffer.getWidth(), buffer.getHeight(), 0x0, 0x0, " ", 0.6)
|
||||
else
|
||||
buffer.clear(0x262626)
|
||||
end
|
||||
|
||||
--Рисуем текущую температуру
|
||||
local x, y = 10, buffer.height - 25
|
||||
local x, y = 10, buffer.getHeight() - 25
|
||||
bigLetters.drawText(x, y, 0xFFFFFF, weather.temperature, drawWithSymbol)
|
||||
y = y + 6
|
||||
--Рисуем название города
|
||||
@ -203,7 +203,7 @@ local function drawWeather()
|
||||
--Рисуем КНОПАЧКИ
|
||||
y = y + 2
|
||||
changeCityButton = {buffer.button(x, y, 22, 1, 0xEEEEEE, 0x262626, "Другой город")}
|
||||
exitButton = {buffer.button(buffer.width - 4, 2, 3, 1, 0xEEEEEE, 0x262626, "X")}
|
||||
exitButton = {buffer.button(buffer.getWidth() - 4, 2, 3, 1, 0xEEEEEE, 0x262626, "X")}
|
||||
|
||||
--Рисуем долгосрочный прогноз
|
||||
y = y + 3
|
||||
|
||||
80
ImageConverter/.idea/workspace.xml
generated
80
ImageConverter/.idea/workspace.xml
generated
@ -67,14 +67,10 @@
|
||||
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="227">
|
||||
<caret line="68" column="64" lean-forward="true" selection-start-line="68" selection-start-column="64" selection-end-line="68" selection-end-column="64" />
|
||||
<state relative-caret-position="167">
|
||||
<caret line="64" column="5" lean-forward="false" selection-start-line="64" selection-start-column="5" selection-end-line="64" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -135,7 +131,7 @@
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1920" />
|
||||
<option name="height" value="979" />
|
||||
<option name="height" value="974" />
|
||||
</component>
|
||||
<component name="ProjectReloadState">
|
||||
<option name="STATE" value="0" />
|
||||
@ -155,8 +151,6 @@
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scratches" />
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
@ -226,6 +220,8 @@
|
||||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scratches" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
@ -511,13 +507,12 @@
|
||||
<option name="totallyTimeSpent" value="1302000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="23" width="1920" height="979" extended-state="6" />
|
||||
<frame x="0" y="23" width="1920" height="974" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Nl-Palette" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3296582" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
|
||||
@ -544,6 +539,7 @@
|
||||
<window_info id="Profiler" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3296582" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="JetGradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Problems" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" />
|
||||
@ -574,10 +570,6 @@
|
||||
<caret line="49" column="9" lean-forward="false" selection-start-line="49" selection-start-column="9" selection-end-line="49" selection-end-column="9" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -615,15 +607,15 @@
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="7" column="31" lean-forward="false" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="31" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/Image.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@ -641,10 +633,6 @@
|
||||
<caret line="143" column="46" lean-forward="false" selection-start-line="143" selection-start-column="46" selection-end-line="143" selection-end-column="46" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -682,15 +670,15 @@
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="7" column="31" lean-forward="false" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="31" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/Image.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@ -708,10 +696,6 @@
|
||||
<caret line="143" column="46" lean-forward="false" selection-start-line="143" selection-start-column="46" selection-end-line="143" selection-end-column="46" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -749,15 +733,15 @@
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="7" column="31" lean-forward="false" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="31" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/Image.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@ -775,10 +759,6 @@
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -826,15 +806,15 @@
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="105">
|
||||
<caret line="7" column="31" lean-forward="false" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="31" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@ -842,10 +822,6 @@
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -898,10 +874,6 @@
|
||||
<caret line="8" column="0" lean-forward="false" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -961,15 +933,15 @@
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="318">
|
||||
<caret line="95" column="49" lean-forward="false" selection-start-line="95" selection-start-column="49" selection-end-line="95" selection-end-column="49" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="JavaFX-Scene-Builder">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/Desktop/IMG_2279.JPG" />
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/OCIF.java">
|
||||
@ -984,14 +956,10 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="227">
|
||||
<caret line="68" column="64" lean-forward="true" selection-start-line="68" selection-start-column="64" selection-end-line="68" selection-end-column="64" />
|
||||
<state relative-caret-position="167">
|
||||
<caret line="64" column="5" lean-forward="false" selection-start-line="64" selection-start-column="5" selection-end-line="64" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#3373#3819#0" expanded="true" />
|
||||
<element signature="e#3818#3819#0" expanded="true" />
|
||||
<element signature="e#4074#4463#0" expanded="true" />
|
||||
<element signature="e#4462#4463#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
||||
4
OS.lua
4
OS.lua
@ -238,9 +238,9 @@ end
|
||||
---------------------------------------------- Всякая параша для ОС-контейнера ------------------------------------------------------------------------
|
||||
|
||||
local function changeResolution()
|
||||
buffer.setResolution(table.unpack(MineOSCore.properties.resolution or {buffer.GPUProxy.maxResolution()}))
|
||||
buffer.setResolution(table.unpack(MineOSCore.properties.resolution or {buffer.getGPUProxy().maxResolution()}))
|
||||
|
||||
MineOSInterface.mainContainer.width, MineOSInterface.mainContainer.height = buffer.width, buffer.height
|
||||
MineOSInterface.mainContainer.width, MineOSInterface.mainContainer.height = buffer.getResolution()
|
||||
|
||||
MineOSInterface.mainContainer.iconField.width = MineOSInterface.mainContainer.width
|
||||
MineOSInterface.mainContainer.iconField.height = MineOSInterface.mainContainer.height
|
||||
|
||||
31
lib/GUI.lua
31
lib/GUI.lua
@ -487,7 +487,7 @@ function GUI.container(x, y, width, height)
|
||||
end
|
||||
|
||||
function GUI.fullScreenContainer()
|
||||
return GUI.container(1, 1, buffer.width, buffer.height)
|
||||
return GUI.container(1, 1, buffer.getResolution())
|
||||
end
|
||||
|
||||
----------------------------------------- Buttons -----------------------------------------
|
||||
@ -883,7 +883,8 @@ function GUI.error(...)
|
||||
local sign = image.fromString([[06030000FF 0000FF 00F7FF▟00F7FF▙0000FF 0000FF 0000FF 00F7FF▟F7FF00 F7FF00 00F7FF▙0000FF 00F7FF▟F7FF00CF7FF00yF7FF00kF7FF00a00F7FF▙]])
|
||||
local offset = 2
|
||||
local lines = #args > 1 and "\"" .. table.concat(args, "\", \"") .. "\"" or args[1]
|
||||
local width = math.floor(buffer.width * 0.5)
|
||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
||||
local width = math.floor(bufferWidth * 0.5)
|
||||
local textWidth = width - image.getWidth(sign) - 2
|
||||
|
||||
lines = string.wrap(lines, textWidth)
|
||||
@ -892,10 +893,10 @@ function GUI.error(...)
|
||||
height = #lines + 2
|
||||
end
|
||||
|
||||
local mainContainer = GUI.container(1, math.floor(buffer.height / 2 - height / 2), buffer.width, height + offset * 2)
|
||||
local mainContainer = GUI.container(1, math.floor(bufferHeight / 2 - height / 2), bufferWidth, height + offset * 2)
|
||||
local oldPixels = buffer.copy(mainContainer.x, mainContainer.y, mainContainer.width, mainContainer.height)
|
||||
|
||||
local x, y = math.floor(buffer.width / 2 - width / 2), offset + 1
|
||||
local x, y = math.floor(bufferWidth / 2 - width / 2), offset + 1
|
||||
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x1D1D1D))
|
||||
mainContainer:addChild(GUI.image(x, y, sign))
|
||||
mainContainer:addChild(GUI.textBox(x + image.getWidth(sign) + 2, y, textWidth, #lines, 0x1D1D1D, 0xE1E1E1, lines, 1, 0, 0)).eventHandler = nil
|
||||
@ -1365,7 +1366,7 @@ local function dropDownMenuItemEventHandler(mainContainer, object, eventData)
|
||||
if object.subMenu then
|
||||
object.subMenu.y = object.parent.y + object.localPosition.y - 1
|
||||
object.subMenu.x = object.parent.x + object.parent.width
|
||||
if buffer.width - object.parent.x - object.parent.width + 1 < object.subMenu.width then
|
||||
if buffer.getWidth() - object.parent.x - object.parent.width + 1 < object.subMenu.width then
|
||||
object.subMenu.x = object.parent.x - object.subMenu.width
|
||||
end
|
||||
|
||||
@ -1392,7 +1393,7 @@ local function dropDownMenuCalculateSizes(menu)
|
||||
totalHeight = totalHeight + (menu.itemsContainer.children[i].type == GUI.dropDownMenuElementTypes.separator and 1 or menu.itemHeight)
|
||||
menu.itemsContainer.children[i].width = menu.width
|
||||
end
|
||||
menu.height = math.min(totalHeight, menu.maximumHeight, buffer.height - menu.y)
|
||||
menu.height = math.min(totalHeight, menu.maximumHeight, buffer.getHeight() - menu.y)
|
||||
menu.itemsContainer.width, menu.itemsContainer.height = menu.width, menu.height
|
||||
|
||||
menu.nextButton.localPosition.y = menu.height
|
||||
@ -1475,6 +1476,8 @@ local function dropDownMenuShow(menu)
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
mainContainer:addChild(GUI.object(1, 1, mainContainer.width, mainContainer.height)).eventHandler = function(mainContainer, object, eventData)
|
||||
if eventData[1] == "touch" then
|
||||
buffer.paste(menu.x, menu.y, menu.oldPixels)
|
||||
buffer.draw()
|
||||
mainContainer:stopEventHandling()
|
||||
end
|
||||
end
|
||||
@ -1553,8 +1556,10 @@ end
|
||||
|
||||
local function contextMenuShow(menu)
|
||||
contextMenuCalculate(menu)
|
||||
if menu.y + menu.height >= buffer.height then menu.y = buffer.height - menu.height end
|
||||
if menu.x + menu.width + 1 >= buffer.width then menu.x = buffer.width - menu.width - 1 end
|
||||
|
||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
||||
if menu.y + menu.height >= bufferHeight then menu.y = bufferHeight - menu.height end
|
||||
if menu.x + menu.width + 1 >= bufferWidth then menu.x = bufferWidth - menu.width - 1 end
|
||||
|
||||
return dropDownMenuShow(menu)
|
||||
end
|
||||
@ -1578,7 +1583,7 @@ local function contextMenuAddSubMenu(menu, text)
|
||||
end
|
||||
|
||||
function GUI.contextMenu(x, y, backgroundColor, textColor, backgroundPressedColor, textPressedColor, disabledColor, separatorColor, backgroundTransparency, shadowTransparency)
|
||||
local menu = GUI.dropDownMenu(x, y, 1, math.ceil(buffer.height * 0.5), 1,
|
||||
local menu = GUI.dropDownMenu(x, y, 1, math.ceil(buffer.getHeight() * 0.5), 1,
|
||||
backgroundColor or GUI.colors.contextMenu.default.background,
|
||||
textColor or GUI.colors.contextMenu.default.text,
|
||||
backgroundPressedColor or GUI.colors.contextMenu.pressed.background,
|
||||
@ -1681,7 +1686,7 @@ function GUI.comboBox(x, y, width, elementHeight, backgroundColor, textColor, ar
|
||||
}
|
||||
}
|
||||
|
||||
object.dropDownMenu = GUI.dropDownMenu(1, 1, 1, math.ceil(buffer.height * 0.5), elementHeight,
|
||||
object.dropDownMenu = GUI.dropDownMenu(1, 1, 1, math.ceil(buffer.getHeight() * 0.5), elementHeight,
|
||||
object.colors.default.background,
|
||||
object.colors.default.text,
|
||||
object.colors.pressed.background,
|
||||
@ -1845,7 +1850,7 @@ local function brailleCanvasDraw(brailleCanvas)
|
||||
local index, background, foreground, symbol
|
||||
for y = 1, brailleCanvas.height do
|
||||
for x = 1, brailleCanvas.width do
|
||||
index = buffer.getIndexByCoordinates(brailleCanvas.x + x - 1, brailleCanvas.y + y - 1)
|
||||
index = buffer.getIndex(brailleCanvas.x + x - 1, brailleCanvas.y + y - 1)
|
||||
background, foreground, symbol = buffer.rawGet(index)
|
||||
buffer.rawSet(index, background, brailleCanvas.pixels[y][x][9], brailleCanvas.pixels[y][x][10])
|
||||
end
|
||||
@ -2504,7 +2509,7 @@ local function resizerDraw(object)
|
||||
else
|
||||
local x = math.floor(object.x + object.width / 2)
|
||||
for i = object.y, object.y + object.height - 1 do
|
||||
local index = buffer.getIndexByCoordinates(x, i)
|
||||
local index = buffer.getIndex(x, i)
|
||||
buffer.rawSet(index, buffer.rawGet(index), object.colors.helper, "┃")
|
||||
end
|
||||
end
|
||||
@ -3093,7 +3098,7 @@ local function inputDraw(input)
|
||||
)
|
||||
|
||||
if input.cursorBlinkState then
|
||||
local index = buffer.getIndexByCoordinates(input.x + input.cursorPosition - input.textCutFrom + input.textOffset, y)
|
||||
local index = buffer.getIndex(input.x + input.cursorPosition - input.textCutFrom + input.textOffset, y)
|
||||
local background = buffer.rawGet(index)
|
||||
buffer.rawSet(index, background, input.colors.cursor, input.cursorSymbol)
|
||||
end
|
||||
|
||||
@ -296,7 +296,7 @@ local function sceneAddObjects(scene, objects)
|
||||
end
|
||||
|
||||
local function sceneRender(scene)
|
||||
renderer.setViewport( 1, 1, buffer.width, buffer.height * 2, scene.camera.nearClippingSurface, scene.camera.farClippingSurface, scene.camera.projectionSurface)
|
||||
renderer.setViewport( 1, 1, buffer.getWidth(), buffer.getHeight() * 2, scene.camera.nearClippingSurface, scene.camera.farClippingSurface, scene.camera.projectionSurface)
|
||||
OCGL.clearBuffer(scene.backgroundColor)
|
||||
OCGL.renderMode = scene.renderMode
|
||||
OCGL.auxiliaryMode = scene.auxiliaryMode
|
||||
|
||||
@ -230,7 +230,7 @@ function MineOSCore.safeLaunch(path, ...)
|
||||
path = path:gsub("/+", "/")
|
||||
MineOSCore.lastLaunchPath = path
|
||||
|
||||
local oldResolutionWidth, oldResolutionHeight = buffer.width, buffer.height
|
||||
local oldResolutionWidth, oldResolutionHeight = buffer.getResolution()
|
||||
local finalSuccess, finalPath, finalLine, finalTraceback = true
|
||||
|
||||
if filesystem.exists(path) then
|
||||
|
||||
@ -730,6 +730,12 @@ function MineOSInterface.iconRightClick(icon, eventData)
|
||||
require("compressor").pack(fs.path(icon.path) .. icon.nameWithoutExtension .. ".pkg", icon.path)
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
if icon.extension ~= ".app" then
|
||||
menu:addItem(MineOSCore.localization.addToFavourites).onTouch = function()
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
else
|
||||
@ -877,7 +883,7 @@ function MineOSInterface.addUniversalContainer(parentContainer, title)
|
||||
container.layout:setCellFitting(2, 1, true, false)
|
||||
|
||||
if title then
|
||||
container.layout:addChild(GUI.label(1, 1, 1, 1, 0xEEEEEE, title)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
container.layout:addChild(GUI.label(1, 1, 1, 1, 0xE1E1E1, title)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
end
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, eventData)
|
||||
@ -894,7 +900,7 @@ end
|
||||
local function addUniversalContainerWithInputTextBox(parentWindow, text, title, placeholder)
|
||||
local container = MineOSInterface.addUniversalContainer(parentWindow, title)
|
||||
|
||||
container.inputField = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, text, placeholder, false))
|
||||
container.inputField = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, text, placeholder, false))
|
||||
container.label = container.layout:addChild(GUI.label(1, 1, 36, 1, 0xFF4940, MineOSCore.localization.file .. " " .. MineOSCore.localization.alreadyExists)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
container.label.hidden = true
|
||||
|
||||
@ -957,7 +963,7 @@ end
|
||||
function MineOSInterface.newFileFromURL(parentWindow, iconField, x, y, path)
|
||||
local container = addUniversalContainerWithInputTextBox(parentWindow, nil, "Загрузить файл по URL", MineOSCore.localization.fileName)
|
||||
|
||||
container.inputFieldURL = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, nil, "URL", false))
|
||||
container.inputFieldURL = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, nil, "URL", false))
|
||||
container.inputField.onInputFinished = function()
|
||||
if container.inputField.text then
|
||||
if fs.exists(path .. container.inputField.text) then
|
||||
@ -987,7 +993,7 @@ end
|
||||
function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
|
||||
local container = addUniversalContainerWithInputTextBox(parentWindow, nil, MineOSCore.localization.newApplication, MineOSCore.localization.applicationName)
|
||||
|
||||
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x444444, 0x999999, nil, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.iconPath, "/"))
|
||||
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x444444, 0x999999, nil, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.iconPath, "/"))
|
||||
filesystemChooser:addExtensionFilter(".pic")
|
||||
filesystemChooser:moveBackward()
|
||||
|
||||
@ -1109,7 +1115,7 @@ function MineOSInterface.applicationHelp(parentWindow, path)
|
||||
end
|
||||
|
||||
container.layout:addChild(GUI.textBox(1, 1, 50, 1, nil, 0xcccccc, lines, 1, 0, 0, true, true))
|
||||
local button = container.layout:addChild(GUI.button(1, 1, 30, 1, 0xEEEEEE, 0x262626, 0xAAAAAA, 0x262626, MineOSCore.localization.dontShowAnymore))
|
||||
local button = container.layout:addChild(GUI.button(1, 1, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xAAAAAA, 0x2D2D2D, MineOSCore.localization.dontShowAnymore))
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, eventData)
|
||||
if eventData[1] == "touch" then
|
||||
@ -1292,18 +1298,18 @@ local function GUICopy(parentContainer, fileList, toPath)
|
||||
|
||||
local container = MineOSInterface.addUniversalContainer(parentContainer, MineOSCore.localization.copying)
|
||||
local textBox = container.layout:addChild(GUI.textBox(1, 1, container.width, 1, nil, 0x777777, {}, 1, 0, 0, true, true):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top))
|
||||
local switchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 37, 8, 0x66DB80, 0x1E1E1E, 0xEEEEEE, 0x777777, MineOSCore.localization.applyToAll .. ":", false))
|
||||
local switchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 37, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x777777, MineOSCore.localization.applyToAll .. ":", false))
|
||||
container.panel.eventHandler = nil
|
||||
|
||||
local buttonsLayout = container.layout:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xEEEEEE, 0x262626, 0xAAAAAA, 0x262626, MineOSCore.localization.yes)).onTouch = function()
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xAAAAAA, 0x2D2D2D, MineOSCore.localization.yes)).onTouch = function()
|
||||
applyYes = true
|
||||
parentContainer:stopEventHandling()
|
||||
end
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xEEEEEE, 0x262626, 0xAAAAAA, 0x262626, MineOSCore.localization.no)).onTouch = function()
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xAAAAAA, 0x2D2D2D, MineOSCore.localization.no)).onTouch = function()
|
||||
parentContainer:stopEventHandling()
|
||||
end
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xEEEEEE, 0x262626, 0xAAAAAA, 0x262626, MineOSCore.localization.cancel)).onTouch = function()
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xAAAAAA, 0x2D2D2D, MineOSCore.localization.cancel)).onTouch = function()
|
||||
breakRecursion = true
|
||||
parentContainer:stopEventHandling()
|
||||
end
|
||||
@ -1400,8 +1406,8 @@ end
|
||||
function MineOSInterface.showErrorWindow(path, line, traceback)
|
||||
buffer.clear(0x0, 0.5)
|
||||
|
||||
local mainContainer = GUI.container(1, 1, buffer.width, math.floor(buffer.height * 0.45))
|
||||
mainContainer.y = math.floor(buffer.height / 2 - mainContainer.height / 2)
|
||||
local mainContainer = GUI.container(1, 1, buffer.getWidth(), math.floor(buffer.getHeight() * 0.45))
|
||||
mainContainer.y = math.floor(buffer.getHeight() / 2 - mainContainer.height / 2)
|
||||
|
||||
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, 3, 0x383838))
|
||||
mainContainer:addChild(GUI.label(1, 2, mainContainer.width, 1, 0xFFFFFF, MineOSCore.localization.errorWhileRunningProgram .. "\"" .. fs.name(path) .. "\"")):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
|
||||
@ -43,7 +43,7 @@ function renderer.setPixelUsingDepthBuffer(x, y, pixelDepthValue, pixelColor)
|
||||
then
|
||||
if pixelDepthValue < renderer.depthBuffer[y][x] then
|
||||
renderer.depthBuffer[y][x] = pixelDepthValue
|
||||
buffer.semiPixelRawSet(buffer.getIndexByCoordinates(x, math.ceil(y / 2)), pixelColor, y % 2 == 0)
|
||||
buffer.semiPixelRawSet(buffer.getIndex(x, math.ceil(y / 2)), pixelColor, y % 2 == 0)
|
||||
-- buffer.set(x, y, pixelColor, 0x0, " ")
|
||||
end
|
||||
end
|
||||
@ -271,7 +271,7 @@ function renderer.renderFloatingText(x, y, z, color, text)
|
||||
end
|
||||
end
|
||||
|
||||
index = buffer.getIndexByCoordinates(x, yInteger)
|
||||
index = buffer.getIndex(x, yInteger)
|
||||
background = buffer.rawGet(index)
|
||||
buffer.rawSet(index, background, color, unicode.sub(text, i, i))
|
||||
end
|
||||
|
||||
@ -6,27 +6,28 @@ local color = {}
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- Optimized Lua 5.3 bitwise support
|
||||
local RGBToHEX
|
||||
if computer.getArchitecture and computer.getArchitecture() == "Lua 5.3" then
|
||||
color.RGBToHEX = load([[
|
||||
RGBToHEX = load([[
|
||||
return function(r, g, b)
|
||||
return (r // 1 << 16) | (g // 1 << 8) | b // 1
|
||||
end
|
||||
]])()
|
||||
else
|
||||
color.RGBToHEX = load([[
|
||||
RGBToHEX = load([[
|
||||
return function(r, g, b)
|
||||
return bit32.bor(bit32.bor(bit32.lshift(r, 16), bit32.lshift(g, 8)), b)
|
||||
end
|
||||
]])()
|
||||
end
|
||||
|
||||
function color.HEXToRGB(HEXColor)
|
||||
local function HEXToRGB(HEXColor)
|
||||
return bit32.rshift(HEXColor, 16), bit32.band(bit32.rshift(HEXColor, 8), 0xFF), bit32.band(HEXColor, 0xFF)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function color.RGBToHSB(r, g, b)
|
||||
local function RGBToHSB(r, g, b)
|
||||
local max, min = math.max(r, g, b), math.min(r, g, b)
|
||||
|
||||
if max == min then
|
||||
@ -44,7 +45,7 @@ function color.RGBToHSB(r, g, b)
|
||||
end
|
||||
end
|
||||
|
||||
function color.HSBToRGB(h, s, b)
|
||||
local function HSBToRGB(h, s, b)
|
||||
s, b = s / 100, b / 100
|
||||
local integer, fractional = math.modf(h / 60)
|
||||
local p, q, t = b * (1 - s), b * (1 - s * fractional), b * (1 - (1 - fractional) * s)
|
||||
@ -64,45 +65,45 @@ function color.HSBToRGB(h, s, b)
|
||||
end
|
||||
end
|
||||
|
||||
function color.HEXToHSB(HEXColor)
|
||||
return color.RGBToHSB(color.HEXToRGB(HEXColor))
|
||||
local function HEXToHSB(HEXColor)
|
||||
return RGBToHSB(HEXToRGB(HEXColor))
|
||||
end
|
||||
|
||||
function color.HSBToHEX(h, s, b)
|
||||
return color.RGBToHEX(color.HSBToRGB(h, s, b))
|
||||
local function HSBToHEX(h, s, b)
|
||||
return RGBToHEX(HSBToRGB(h, s, b))
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function color.blend(firstColor, secondColor, secondColorTransparency)
|
||||
local invertedTransparency, firstColorR, firstColorG, firstColorB = 1 - secondColorTransparency, color.HEXToRGB(firstColor)
|
||||
local secondColorR, secondColorG, secondColorB = color.HEXToRGB(secondColor)
|
||||
local function blend(firstColor, secondColor, secondColorTransparency)
|
||||
local invertedTransparency, firstColorR, firstColorG, firstColorB = 1 - secondColorTransparency, HEXToRGB(firstColor)
|
||||
local secondColorR, secondColorG, secondColorB = HEXToRGB(secondColor)
|
||||
|
||||
return color.RGBToHEX(
|
||||
return RGBToHEX(
|
||||
secondColorR * invertedTransparency + firstColorR * secondColorTransparency,
|
||||
secondColorG * invertedTransparency + firstColorG * secondColorTransparency,
|
||||
secondColorB * invertedTransparency + firstColorB * secondColorTransparency
|
||||
)
|
||||
end
|
||||
|
||||
function color.blendRGBA(c1, c2, a1, a2)
|
||||
local function blendRGBA(c1, c2, a1, a2)
|
||||
local oneMinusA1, oneMinusA2 = 1 - a1, 1 - a2
|
||||
return
|
||||
color.blend(c1, c2, a2),
|
||||
blend(c1, c2, a2),
|
||||
1 - (oneMinusA1 + a1 * oneMinusA2)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function color.difference(r1, g1, b1, r2, g2, b2)
|
||||
local function difference(r1, g1, b1, r2, g2, b2)
|
||||
return r2 - r1, g2 - g1, b2 - b1
|
||||
end
|
||||
|
||||
function color.sum(r1, g1, b1, r2, g2, b2)
|
||||
local function sum(r1, g1, b1, r2, g2, b2)
|
||||
return r2 + r1, g2 + g1, b2 + b1
|
||||
end
|
||||
|
||||
function color.multiply(r, g, b, multiplyer)
|
||||
local function multiply(r, g, b, multiplyer)
|
||||
r, g, b = r * multiplyer, g * multiplyer, b * multiplyer
|
||||
if r > 255 then r = 255 end
|
||||
if g > 255 then g = 255 end
|
||||
@ -111,29 +112,29 @@ function color.multiply(r, g, b, multiplyer)
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
function color.average(colors)
|
||||
local function average(colors)
|
||||
local sColors, averageRed, averageGreen, averageBlue, r, g, b = #colors, 0, 0, 0
|
||||
|
||||
for i = 1, sColors do
|
||||
r, g, b = color.HEXToRGB(colors[i])
|
||||
r, g, b = HEXToRGB(colors[i])
|
||||
averageRed, averageGreen, averageBlue = averageRed + r, averageGreen + g, averageBlue + b
|
||||
end
|
||||
|
||||
return color.RGBToHEX(math.floor(averageRed / sColors), math.floor(averageGreen / sColors), math.floor(averageBlue / sColors))
|
||||
return RGBToHEX(math.floor(averageRed / sColors), math.floor(averageGreen / sColors), math.floor(averageBlue / sColors))
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local openComputersPalette = { 0x000000, 0x000040, 0x000080, 0x0000BF, 0x0000FF, 0x002400, 0x002440, 0x002480, 0x0024BF, 0x0024FF, 0x004900, 0x004940, 0x004980, 0x0049BF, 0x0049FF, 0x006D00, 0x006D40, 0x006D80, 0x006DBF, 0x006DFF, 0x009200, 0x009240, 0x009280, 0x0092BF, 0x0092FF, 0x00B600, 0x00B640, 0x00B680, 0x00B6BF, 0x00B6FF, 0x00DB00, 0x00DB40, 0x00DB80, 0x00DBBF, 0x00DBFF, 0x00FF00, 0x00FF40, 0x00FF80, 0x00FFBF, 0x00FFFF, 0x0F0F0F, 0x1E1E1E, 0x2D2D2D, 0x330000, 0x330040, 0x330080, 0x3300BF, 0x3300FF, 0x332400, 0x332440, 0x332480, 0x3324BF, 0x3324FF, 0x334900, 0x334940, 0x334980, 0x3349BF, 0x3349FF, 0x336D00, 0x336D40, 0x336D80, 0x336DBF, 0x336DFF, 0x339200, 0x339240, 0x339280, 0x3392BF, 0x3392FF, 0x33B600, 0x33B640, 0x33B680, 0x33B6BF, 0x33B6FF, 0x33DB00, 0x33DB40, 0x33DB80, 0x33DBBF, 0x33DBFF, 0x33FF00, 0x33FF40, 0x33FF80, 0x33FFBF, 0x33FFFF, 0x3C3C3C, 0x4B4B4B, 0x5A5A5A, 0x660000, 0x660040, 0x660080, 0x6600BF, 0x6600FF, 0x662400, 0x662440, 0x662480, 0x6624BF, 0x6624FF, 0x664900, 0x664940, 0x664980, 0x6649BF, 0x6649FF, 0x666D00, 0x666D40, 0x666D80, 0x666DBF, 0x666DFF, 0x669200, 0x669240, 0x669280, 0x6692BF, 0x6692FF, 0x66B600, 0x66B640, 0x66B680, 0x66B6BF, 0x66B6FF, 0x66DB00, 0x66DB40, 0x66DB80, 0x66DBBF, 0x66DBFF, 0x66FF00, 0x66FF40, 0x66FF80, 0x66FFBF, 0x66FFFF, 0x696969, 0x787878, 0x878787, 0x969696, 0x990000, 0x990040, 0x990080, 0x9900BF, 0x9900FF, 0x992400, 0x992440, 0x992480, 0x9924BF, 0x9924FF, 0x994900, 0x994940, 0x994980, 0x9949BF, 0x9949FF, 0x996D00, 0x996D40, 0x996D80, 0x996DBF, 0x996DFF, 0x999200, 0x999240, 0x999280, 0x9992BF, 0x9992FF, 0x99B600, 0x99B640, 0x99B680, 0x99B6BF, 0x99B6FF, 0x99DB00, 0x99DB40, 0x99DB80, 0x99DBBF, 0x99DBFF, 0x99FF00, 0x99FF40, 0x99FF80, 0x99FFBF, 0x99FFFF, 0xA5A5A5, 0xB4B4B4, 0xC3C3C3, 0xCC0000, 0xCC0040, 0xCC0080, 0xCC00BF, 0xCC00FF, 0xCC2400, 0xCC2440, 0xCC2480, 0xCC24BF, 0xCC24FF, 0xCC4900, 0xCC4940, 0xCC4980, 0xCC49BF, 0xCC49FF, 0xCC6D00, 0xCC6D40, 0xCC6D80, 0xCC6DBF, 0xCC6DFF, 0xCC9200, 0xCC9240, 0xCC9280, 0xCC92BF, 0xCC92FF, 0xCCB600, 0xCCB640, 0xCCB680, 0xCCB6BF, 0xCCB6FF, 0xCCDB00, 0xCCDB40, 0xCCDB80, 0xCCDBBF, 0xCCDBFF, 0xCCFF00, 0xCCFF40, 0xCCFF80, 0xCCFFBF, 0xCCFFFF, 0xD2D2D2, 0xE1E1E1, 0xF0F0F0, 0xFF0000, 0xFF0040, 0xFF0080, 0xFF00BF, 0xFF00FF, 0xFF2400, 0xFF2440, 0xFF2480, 0xFF24BF, 0xFF24FF, 0xFF4900, 0xFF4940, 0xFF4980, 0xFF49BF, 0xFF49FF, 0xFF6D00, 0xFF6D40, 0xFF6D80, 0xFF6DBF, 0xFF6DFF, 0xFF9200, 0xFF9240, 0xFF9280, 0xFF92BF, 0xFF92FF, 0xFFB600, 0xFFB640, 0xFFB680, 0xFFB6BF, 0xFFB6FF, 0xFFDB00, 0xFFDB40, 0xFFDB80, 0xFFDBBF, 0xFFDBFF, 0xFFFF00, 0xFFFF40, 0xFFFF80, 0xFFFFBF, 0xFFFFFF }
|
||||
|
||||
function color.to8Bit(color24Bit)
|
||||
local closestDelta, r, g, b, closestIndex, delta, openComputersPaletteR, openComputersPaletteG, openComputersPaletteB = math.huge, color.HEXToRGB(color24Bit)
|
||||
local function to8Bit(color24Bit)
|
||||
local closestDelta, r, g, b, closestIndex, delta, openComputersPaletteR, openComputersPaletteG, openComputersPaletteB = math.huge, HEXToRGB(color24Bit)
|
||||
|
||||
for index = 1, #openComputersPalette do
|
||||
if color24Bit == openComputersPalette[index] then
|
||||
return index - 1
|
||||
else
|
||||
openComputersPaletteR, openComputersPaletteG, openComputersPaletteB = color.HEXToRGB(openComputersPalette[index])
|
||||
openComputersPaletteR, openComputersPaletteG, openComputersPaletteB = HEXToRGB(openComputersPalette[index])
|
||||
delta = (openComputersPaletteR - r) ^ 2 + (openComputersPaletteG - g) ^ 2 + (openComputersPaletteB - b) ^ 2
|
||||
|
||||
if delta < closestDelta then
|
||||
@ -145,22 +146,38 @@ function color.to8Bit(color24Bit)
|
||||
return closestIndex - 1
|
||||
end
|
||||
|
||||
function color.to24Bit(color8Bit)
|
||||
local function to24Bit(color8Bit)
|
||||
return openComputersPalette[color8Bit + 1]
|
||||
end
|
||||
|
||||
function color.optimize(color24Bit)
|
||||
return color.to24Bit(color.to8Bit(color24Bit))
|
||||
local function optimize(color24Bit)
|
||||
return to24Bit(to8Bit(color24Bit))
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- local c, a = color.blendRGBA(0x0000FF, 0xFF0000, 0.5, 0.5)
|
||||
-- local c, a = blendRGBA(0x0000FF, 0xFF0000, 0.5, 0.5)
|
||||
-- print(string.format("0x%06X", c), a)
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
return color
|
||||
return {
|
||||
RGBToHEX = RGBToHEX,
|
||||
HEXToRGB = HEXToRGB,
|
||||
RGBToHSB = RGBToHSB,
|
||||
HSBToRGB = HSBToRGB,
|
||||
HEXToHSB = HEXToHSB,
|
||||
HSBToHEX = HSBToHEX,
|
||||
blend = blend,
|
||||
blendRGBA = blendRGBA,
|
||||
difference = difference,
|
||||
sum = sum,
|
||||
multiply = multiply,
|
||||
average = average,
|
||||
to8Bit = to8Bit,
|
||||
to24Bit = to24Bit,
|
||||
optimize = optimize,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,120 +6,159 @@ local image = require("image")
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local buffer = {
|
||||
GPUProxy = component.getPrimary("gpu"),
|
||||
currentFrame = {},
|
||||
newFrame = {},
|
||||
drawLimit = {},
|
||||
}
|
||||
local buffer = {}
|
||||
|
||||
local bufferWidth, bufferHeight, bufferTripleWidth
|
||||
local currentFrame, newFrame
|
||||
local drawLimitX1, drawLimitX2, drawLimitY1, drawLimitY2
|
||||
|
||||
local GPUProxy, GPUProxyGetResolution, GPUProxySetResolution, GPUProxyBind, GPUProxyGetBackground, GPUProxyGetForeground, GPUProxySetBackground, GPUProxySetForeground, GPUProxyGet, GPUProxySet
|
||||
local mathCeil, mathFloor, mathModf, mathAbs = math.ceil, math.floor, math.modf, math.abs
|
||||
local tableInsert = table.insert
|
||||
local colorBlend = color.blend
|
||||
local unicodeLen, unicodeSub = unicode.len, unicode.sub
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function buffer.getCoordinatesByIndex(index)
|
||||
local integer, fractional = math.modf(index / (buffer.tripleWidth))
|
||||
return math.ceil(fractional * buffer.width), integer + 1
|
||||
local function getCoordinates(index)
|
||||
local integer, fractional = mathModf(index / bufferTripleWidth)
|
||||
return mathCeil(fractional * bufferWidth), integer + 1
|
||||
end
|
||||
|
||||
function buffer.getIndexByCoordinates(x, y)
|
||||
return buffer.tripleWidth * (y - 1) + x * 3 - 2
|
||||
local function getIndex(x, y)
|
||||
return bufferTripleWidth * (y - 1) + x * 3 - 2
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function buffer.setDrawLimit(x1, y1, x2, y2)
|
||||
buffer.drawLimit.x1, buffer.drawLimit.y1, buffer.drawLimit.x2, buffer.drawLimit.y2 = x1, y1, x2, y2
|
||||
local function setDrawLimit(x1, y1, x2, y2)
|
||||
drawLimitX1, drawLimitY1, drawLimitX2, drawLimitY2 = x1, y1, x2, y2
|
||||
end
|
||||
|
||||
function buffer.resetDrawLimit()
|
||||
buffer.drawLimit.x1, buffer.drawLimit.y1, buffer.drawLimit.x2, buffer.drawLimit.y2 = 1, 1, buffer.width, buffer.height
|
||||
local function resetDrawLimit()
|
||||
drawLimitX1, drawLimitY1, drawLimitX2, drawLimitY2 = 1, 1, bufferWidth, bufferHeight
|
||||
end
|
||||
|
||||
function buffer.getDrawLimit()
|
||||
return buffer.drawLimit.x1, buffer.drawLimit.y1, buffer.drawLimit.x2, buffer.drawLimit.y2
|
||||
local function getDrawLimit()
|
||||
return drawLimitX1, drawLimitY1, drawLimitX2, drawLimitY2
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function buffer.flush(width, height)
|
||||
local function flush(width, height)
|
||||
if not width or not height then
|
||||
width, height = buffer.GPUProxy.getResolution()
|
||||
width, height = GPUProxyGetResolution()
|
||||
end
|
||||
|
||||
buffer.currentFrame, buffer.newFrame = {}, {}
|
||||
buffer.width = width
|
||||
buffer.height = height
|
||||
buffer.tripleWidth = width * 3
|
||||
buffer.resetDrawLimit()
|
||||
currentFrame, newFrame = {}, {}
|
||||
bufferWidth = width
|
||||
bufferHeight = height
|
||||
bufferTripleWidth = width * 3
|
||||
resetDrawLimit()
|
||||
|
||||
for y = 1, buffer.height do
|
||||
for x = 1, buffer.width do
|
||||
table.insert(buffer.currentFrame, 0x010101)
|
||||
table.insert(buffer.currentFrame, 0xFEFEFE)
|
||||
table.insert(buffer.currentFrame, " ")
|
||||
for y = 1, bufferHeight do
|
||||
for x = 1, bufferWidth do
|
||||
tableInsert(currentFrame, 0x010101)
|
||||
tableInsert(currentFrame, 0xFEFEFE)
|
||||
tableInsert(currentFrame, " ")
|
||||
|
||||
table.insert(buffer.newFrame, 0x010101)
|
||||
table.insert(buffer.newFrame, 0xFEFEFE)
|
||||
table.insert(buffer.newFrame, " ")
|
||||
tableInsert(newFrame, 0x010101)
|
||||
tableInsert(newFrame, 0xFEFEFE)
|
||||
tableInsert(newFrame, " ")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.setResolution(width, height)
|
||||
buffer.GPUProxy.setResolution(width, height)
|
||||
buffer.flush(width, height)
|
||||
local function setResolution(width, height)
|
||||
GPUProxySetResolution(width, height)
|
||||
flush(width, height)
|
||||
end
|
||||
|
||||
function buffer.bindScreen(...)
|
||||
buffer.GPUProxy.bind(...)
|
||||
buffer.flush(buffer.GPUProxy.getResolution())
|
||||
local function getResolution()
|
||||
return bufferWidth, bufferHeight
|
||||
end
|
||||
|
||||
function buffer.bindGPU(address)
|
||||
buffer.GPUProxy = component.proxy(address)
|
||||
buffer.flush(buffer.GPUProxy.getResolution())
|
||||
local function getWidth()
|
||||
return bufferWidth
|
||||
end
|
||||
|
||||
local function getHeight()
|
||||
return bufferHeight
|
||||
end
|
||||
|
||||
local function bindScreen(...)
|
||||
GPUProxyBind(...)
|
||||
flush(GPUProxyGetResolution())
|
||||
end
|
||||
|
||||
local function getGPUProxy()
|
||||
return GPUProxy
|
||||
end
|
||||
|
||||
local function updateGPUProxyMethods()
|
||||
GPUProxyGet = GPUProxy.get
|
||||
GPUProxyGetResolution = GPUProxy.getResolution
|
||||
GPUProxyGetBackground = GPUProxy.getBackground
|
||||
GPUProxyGetForeground = GPUProxy.getForeground
|
||||
|
||||
GPUProxySet = GPUProxy.set
|
||||
GPUProxySetResolution = GPUProxy.setResolution
|
||||
GPUProxySetBackground = GPUProxy.setBackground
|
||||
GPUProxySetForeground = GPUProxy.setForeground
|
||||
|
||||
GPUProxyBind = GPUProxy.bind
|
||||
GPUProxyFill = GPUProxy.fill
|
||||
end
|
||||
|
||||
local function bindGPU(address)
|
||||
GPUProxy = component.proxy(address)
|
||||
updateGPUProxyMethods()
|
||||
flush(GPUProxyGetResolution())
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function buffer.rawSet(index, background, foreground, symbol)
|
||||
buffer.newFrame[index], buffer.newFrame[index + 1], buffer.newFrame[index + 2] = background, foreground, symbol
|
||||
local function rawSet(index, background, foreground, symbol)
|
||||
newFrame[index], newFrame[index + 1], newFrame[index + 2] = background, foreground, symbol
|
||||
end
|
||||
|
||||
function buffer.rawGet(index)
|
||||
return buffer.newFrame[index], buffer.newFrame[index + 1], buffer.newFrame[index + 2]
|
||||
local function rawGet(index)
|
||||
return newFrame[index], newFrame[index + 1], newFrame[index + 2]
|
||||
end
|
||||
|
||||
function buffer.get(x, y)
|
||||
local index = buffer.getIndexByCoordinates(x, y)
|
||||
if x >= 1 and y >= 1 and x <= buffer.width and y <= buffer.height then
|
||||
return buffer.rawGet(index)
|
||||
local function get(x, y)
|
||||
local index = getIndex(x, y)
|
||||
if x >= 1 and y >= 1 and x <= bufferWidth and y <= bufferHeight then
|
||||
return newFrame[index], newFrame[index + 1], newFrame[index + 2]
|
||||
else
|
||||
return 0x000000, 0x000000, " "
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.set(x, y, background, foreground, symbol)
|
||||
local index = buffer.getIndexByCoordinates(x, y)
|
||||
if x >= buffer.drawLimit.x1 and y >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and y <= buffer.drawLimit.y2 then
|
||||
buffer.rawSet(index, background, foreground or 0x0, symbol or " ")
|
||||
local function set(x, y, background, foreground, symbol)
|
||||
local index = getIndex(x, y)
|
||||
if x >= drawLimitX1 and y >= drawLimitY1 and x <= drawLimitX2 and y <= drawLimitY2 then
|
||||
newFrame[index] = background
|
||||
newFrame[index + 1] = foreground
|
||||
newFrame[index + 2] = symbol
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.square(x, y, width, height, background, foreground, symbol, transparency)
|
||||
local index, indexStepOnEveryLine, indexPlus1 = buffer.getIndexByCoordinates(x, y), (buffer.width - width) * 3
|
||||
local function square(x, y, width, height, background, foreground, symbol, transparency)
|
||||
local index, indexStepOnEveryLine, indexPlus1 = getIndex(x, y), (bufferWidth - width) * 3
|
||||
|
||||
for j = y, y + height - 1 do
|
||||
if j >= buffer.drawLimit.y1 and j <= buffer.drawLimit.y2 then
|
||||
if j >= drawLimitY1 and j <= drawLimitY2 then
|
||||
for i = x, x + width - 1 do
|
||||
if i >= buffer.drawLimit.x1 and i <= buffer.drawLimit.x2 then
|
||||
if i >= drawLimitX1 and i <= drawLimitX2 then
|
||||
indexPlus1 = index + 1
|
||||
|
||||
if transparency then
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1] =
|
||||
color.blend(buffer.newFrame[index], background, transparency),
|
||||
color.blend(buffer.newFrame[indexPlus1], background, transparency)
|
||||
newFrame[index], newFrame[indexPlus1] =
|
||||
colorBlend(newFrame[index], background, transparency),
|
||||
colorBlend(newFrame[indexPlus1], background, transparency)
|
||||
else
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[index + 2] = background, foreground, symbol
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[index + 2] = background, foreground, symbol
|
||||
end
|
||||
end
|
||||
|
||||
@ -128,30 +167,30 @@ function buffer.square(x, y, width, height, background, foreground, symbol, tran
|
||||
|
||||
index = index + indexStepOnEveryLine
|
||||
else
|
||||
index = index + buffer.tripleWidth
|
||||
index = index + bufferTripleWidth
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.clear(color, transparency)
|
||||
buffer.square(1, 1, buffer.width, buffer.height, color or 0x0, 0x000000, " ", transparency)
|
||||
local function clear(color, transparency)
|
||||
square(1, 1, bufferWidth, bufferHeight, color or 0x0, 0x000000, " ", transparency)
|
||||
end
|
||||
|
||||
function buffer.copy(x, y, width, height)
|
||||
local function copy(x, y, width, height)
|
||||
local copyArray = { width = width, height = height }
|
||||
|
||||
local index
|
||||
for j = y, y + height - 1 do
|
||||
for i = x, x + width - 1 do
|
||||
if i >= 1 and j >= 1 and i <= buffer.width and j <= buffer.height then
|
||||
index = buffer.getIndexByCoordinates(i, j)
|
||||
table.insert(copyArray, buffer.newFrame[index])
|
||||
table.insert(copyArray, buffer.newFrame[index + 1])
|
||||
table.insert(copyArray, buffer.newFrame[index + 2])
|
||||
if i >= 1 and j >= 1 and i <= bufferWidth and j <= bufferHeight then
|
||||
index = getIndex(i, j)
|
||||
tableInsert(copyArray, newFrame[index])
|
||||
tableInsert(copyArray, newFrame[index + 1])
|
||||
tableInsert(copyArray, newFrame[index + 2])
|
||||
else
|
||||
table.insert(copyArray, 0x0)
|
||||
table.insert(copyArray, 0x0)
|
||||
table.insert(copyArray, " ")
|
||||
tableInsert(copyArray, 0x0)
|
||||
tableInsert(copyArray, 0x0)
|
||||
tableInsert(copyArray, " ")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -159,29 +198,29 @@ function buffer.copy(x, y, width, height)
|
||||
return copyArray
|
||||
end
|
||||
|
||||
function buffer.paste(x, y, copyArray)
|
||||
local function paste(x, y, copyArray)
|
||||
local index, arrayIndex
|
||||
if not copyArray or #copyArray == 0 then error("Массив области экрана пуст.") end
|
||||
|
||||
for j = y, y + copyArray.height - 1 do
|
||||
for i = x, x + copyArray.width - 1 do
|
||||
if i >= buffer.drawLimit.x1 and j >= buffer.drawLimit.y1 and i <= buffer.drawLimit.x2 and j <= buffer.drawLimit.y2 then
|
||||
if i >= drawLimitX1 and j >= drawLimitY1 and i <= drawLimitX2 and j <= drawLimitY2 then
|
||||
--Рассчитываем индекс массива основного изображения
|
||||
index = buffer.getIndexByCoordinates(i, j)
|
||||
index = getIndex(i, j)
|
||||
--Копипаст формулы, аккуратнее!
|
||||
--Рассчитываем индекс массива вставочного изображения
|
||||
arrayIndex = (copyArray.width * (j - y) + (i - x + 1)) * 3 - 2
|
||||
--Вставляем данные
|
||||
buffer.newFrame[index] = copyArray[arrayIndex]
|
||||
buffer.newFrame[index + 1] = copyArray[arrayIndex + 1]
|
||||
buffer.newFrame[index + 2] = copyArray[arrayIndex + 2]
|
||||
newFrame[index] = copyArray[arrayIndex]
|
||||
newFrame[index + 1] = copyArray[arrayIndex + 1]
|
||||
newFrame[index + 2] = copyArray[arrayIndex + 2]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.rasterizeLine(x1, y1, x2, y2, method)
|
||||
local inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = x1, x2, y1, y2, false, math.abs(x2 - x1), math.abs(y2 - y1)
|
||||
local function rasterizeLine(x1, y1, x2, y2, method)
|
||||
local inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = x1, x2, y1, y2, false, mathAbs(x2 - x1), mathAbs(y2 - y1)
|
||||
if inLoopValueDelta < outLoopValueDelta then
|
||||
inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = y1, y2, x1, x2, true, outLoopValueDelta, inLoopValueDelta
|
||||
end
|
||||
@ -207,25 +246,25 @@ function buffer.rasterizeLine(x1, y1, x2, y2, method)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
buffer.rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||
buffer.set(x, y, background, foreground, alpha, symbol)
|
||||
local function line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||
set(x, y, background, foreground, alpha, symbol)
|
||||
end)
|
||||
end
|
||||
|
||||
function buffer.text(x, y, textColor, text, transparency)
|
||||
if y >= buffer.drawLimit.y1 and y <= buffer.drawLimit.y2 then
|
||||
local charIndex, bufferIndex = 1, buffer.getIndexByCoordinates(x, y) + 1
|
||||
local function text(x, y, textColor, data, transparency)
|
||||
if y >= drawLimitY1 and y <= drawLimitY2 then
|
||||
local charIndex, bufferIndex = 1, getIndex(x, y) + 1
|
||||
|
||||
for charIndex = 1, unicode.len(text) do
|
||||
if x >= buffer.drawLimit.x1 and x <= buffer.drawLimit.x2 then
|
||||
for charIndex = 1, unicodeLen(data) do
|
||||
if x >= drawLimitX1 and x <= drawLimitX2 then
|
||||
if transparency then
|
||||
buffer.newFrame[bufferIndex] = color.blend(buffer.newFrame[bufferIndex - 1], textColor, transparency)
|
||||
newFrame[bufferIndex] = colorBlend(newFrame[bufferIndex - 1], textColor, transparency)
|
||||
else
|
||||
buffer.newFrame[bufferIndex] = textColor
|
||||
newFrame[bufferIndex] = textColor
|
||||
end
|
||||
|
||||
buffer.newFrame[bufferIndex + 1] = unicode.sub(text, charIndex, charIndex)
|
||||
newFrame[bufferIndex + 1] = unicodeSub(data, charIndex, charIndex)
|
||||
end
|
||||
|
||||
x, bufferIndex = x + 1, bufferIndex + 3
|
||||
@ -233,22 +272,22 @@ function buffer.text(x, y, textColor, text, transparency)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.formattedText(x, y, text)
|
||||
if y >= buffer.drawLimit.y1 and y <= buffer.drawLimit.y2 then
|
||||
local charIndex, bufferIndex, textColor, char, number = 1, buffer.getIndexByCoordinates(x, y) + 1, 0xFFFFFF
|
||||
local function formattedText(x, y, data)
|
||||
if y >= drawLimitY1 and y <= drawLimitY2 then
|
||||
local charIndex, bufferIndex, textColor, char, number = 1, getIndex(x, y) + 1, 0xFFFFFF
|
||||
|
||||
while charIndex <= unicode.len(text) do
|
||||
if x >= buffer.drawLimit.x1 and x <= buffer.drawLimit.x2 then
|
||||
char = unicode.sub(text, charIndex, charIndex)
|
||||
while charIndex <= unicodeLen(text) do
|
||||
if x >= drawLimitX1 and x <= drawLimitX2 then
|
||||
char = unicodeSub(data, charIndex, charIndex)
|
||||
if char == "#" then
|
||||
local number = tonumber("0x" .. unicode.sub(text, charIndex + 1, charIndex + 6))
|
||||
number = tonumber("0x" .. unicodeSub(data, charIndex + 1, charIndex + 6))
|
||||
if number then
|
||||
textColor, charIndex = number, charIndex + 7
|
||||
else
|
||||
buffer.newFrame[bufferIndex], buffer.newFrame[bufferIndex + 1], x, charIndex, bufferIndex = textColor, char, x + 1, charIndex + 1, bufferIndex + 3
|
||||
newFrame[bufferIndex], newFrame[bufferIndex + 1], x, charIndex, bufferIndex = textColor, char, x + 1, charIndex + 1, bufferIndex + 3
|
||||
end
|
||||
else
|
||||
buffer.newFrame[bufferIndex], buffer.newFrame[bufferIndex + 1], x, charIndex, bufferIndex = textColor, char, x + 1, charIndex + 1, bufferIndex + 3
|
||||
newFrame[bufferIndex], newFrame[bufferIndex + 1], x, charIndex, bufferIndex = textColor, char, x + 1, charIndex + 1, bufferIndex + 3
|
||||
end
|
||||
else
|
||||
x, charIndex, bufferIndex = x + 1, charIndex + 1, bufferIndex + 3
|
||||
@ -257,29 +296,29 @@ function buffer.formattedText(x, y, text)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.image(x, y, picture, blendForeground)
|
||||
local xPos, xEnd, bufferIndexStepOnReachOfImageWidth = x, x + picture[1] - 1, (buffer.width - picture[1]) * 3
|
||||
local bufferIndex, bufferIndexPlus1, imageIndexPlus1, imageIndexPlus2, imageIndexPlus3 = buffer.getIndexByCoordinates(x, y)
|
||||
local function image(x, y, picture, blendForeground)
|
||||
local xPos, xEnd, bufferIndexStepOnReachOfImageWidth = x, x + picture[1] - 1, (bufferWidth - picture[1]) * 3
|
||||
local bufferIndex, bufferIndexPlus1, imageIndexPlus1, imageIndexPlus2, imageIndexPlus3 = getIndex(x, y)
|
||||
|
||||
for imageIndex = 3, #picture, 4 do
|
||||
if xPos >= buffer.drawLimit.x1 and y >= buffer.drawLimit.y1 and xPos <= buffer.drawLimit.x2 and y <= buffer.drawLimit.y2 then
|
||||
if xPos >= drawLimitX1 and y >= drawLimitY1 and xPos <= drawLimitX2 and y <= drawLimitY2 then
|
||||
bufferIndexPlus1, imageIndexPlus1, imageIndexPlus2, imageIndexPlus3 = bufferIndex + 1, imageIndex + 1, imageIndex + 2, imageIndex + 3
|
||||
|
||||
if picture[imageIndexPlus2] == 0 then
|
||||
buffer.newFrame[bufferIndex], buffer.newFrame[bufferIndexPlus1] = picture[imageIndex], picture[imageIndexPlus1]
|
||||
newFrame[bufferIndex], newFrame[bufferIndexPlus1] = picture[imageIndex], picture[imageIndexPlus1]
|
||||
elseif picture[imageIndexPlus2] > 0 and picture[imageIndexPlus2] < 1 then
|
||||
buffer.newFrame[bufferIndex] = color.blend(buffer.newFrame[bufferIndex], picture[imageIndex], picture[imageIndexPlus2])
|
||||
newFrame[bufferIndex] = colorBlend(newFrame[bufferIndex], picture[imageIndex], picture[imageIndexPlus2])
|
||||
|
||||
if blendForeground then
|
||||
buffer.newFrame[bufferIndexPlus1] = color.blend(buffer.newFrame[bufferIndexPlus1], picture[imageIndexPlus1], picture[imageIndexPlus2])
|
||||
newFrame[bufferIndexPlus1] = colorBlend(newFrame[bufferIndexPlus1], picture[imageIndexPlus1], picture[imageIndexPlus2])
|
||||
else
|
||||
buffer.newFrame[bufferIndexPlus1] = picture[imageIndexPlus1]
|
||||
newFrame[bufferIndexPlus1] = picture[imageIndexPlus1]
|
||||
end
|
||||
elseif picture[imageIndexPlus2] == 1 and picture[imageIndexPlus3] ~= " " then
|
||||
buffer.newFrame[bufferIndexPlus1] = picture[imageIndexPlus1]
|
||||
newFrame[bufferIndexPlus1] = picture[imageIndexPlus1]
|
||||
end
|
||||
|
||||
buffer.newFrame[bufferIndex + 2] = picture[imageIndexPlus3]
|
||||
newFrame[bufferIndex + 2] = picture[imageIndexPlus3]
|
||||
end
|
||||
|
||||
xPos, bufferIndex = xPos + 1, bufferIndex + 3
|
||||
@ -289,72 +328,72 @@ function buffer.image(x, y, picture, blendForeground)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.frame(x, y, width, height, color)
|
||||
local function frame(x, y, width, height, color)
|
||||
local stringUp, stringDown, x2 = "┌" .. string.rep("─", width - 2) .. "┐", "└" .. string.rep("─", width - 2) .. "┘", x + width - 1
|
||||
buffer.text(x, y, color, stringUp); y = y + 1
|
||||
text(x, y, color, stringUp); y = y + 1
|
||||
for i = 1, height - 2 do
|
||||
buffer.text(x, y, color, "│")
|
||||
buffer.text(x2, y, color, "│")
|
||||
text(x, y, color, "│")
|
||||
text(x2, y, color, "│")
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
buffer.text(x, y, color, stringDown)
|
||||
text(x, y, color, stringDown)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function buffer.semiPixelRawSet(index, color, yPercentTwoEqualsZero)
|
||||
local function semiPixelRawSet(index, color, yPercentTwoEqualsZero)
|
||||
local upperPixel, lowerPixel, bothPixel, indexPlus1, indexPlus2 = "▀", "▄", " ", index + 1, index + 2
|
||||
local background, foreground, symbol = buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2]
|
||||
local background, foreground, symbol = newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2]
|
||||
|
||||
if yPercentTwoEqualsZero then
|
||||
if symbol == upperPixel then
|
||||
if color == foreground then
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = color, foreground, bothPixel
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = color, foreground, bothPixel
|
||||
else
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = color, foreground, symbol
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = color, foreground, symbol
|
||||
end
|
||||
elseif symbol == bothPixel then
|
||||
if color ~= background then
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = background, color, lowerPixel
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = background, color, lowerPixel
|
||||
end
|
||||
else
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = background, color, lowerPixel
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = background, color, lowerPixel
|
||||
end
|
||||
else
|
||||
if symbol == lowerPixel then
|
||||
if color == foreground then
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = color, foreground, bothPixel
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = color, foreground, bothPixel
|
||||
else
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = color, foreground, symbol
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = color, foreground, symbol
|
||||
end
|
||||
elseif symbol == bothPixel then
|
||||
if color ~= background then
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = background, color, upperPixel
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = background, color, upperPixel
|
||||
end
|
||||
else
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[indexPlus2] = background, color, upperPixel
|
||||
newFrame[index], newFrame[indexPlus1], newFrame[indexPlus2] = background, color, upperPixel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.semiPixelSet(x, y, color)
|
||||
local yFixed = math.ceil(y / 2)
|
||||
if x >= buffer.drawLimit.x1 and yFixed >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and yFixed <= buffer.drawLimit.y2 then
|
||||
buffer.semiPixelRawSet(buffer.getIndexByCoordinates(x, yFixed), color, y % 2 == 0)
|
||||
local function semiPixelSet(x, y, color)
|
||||
local yFixed = mathCeil(y / 2)
|
||||
if x >= drawLimitX1 and yFixed >= drawLimitY1 and x <= drawLimitX2 and yFixed <= drawLimitY2 then
|
||||
semiPixelRawSet(getIndex(x, yFixed), color, y % 2 == 0)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.semiPixelSquare(x, y, width, height, color)
|
||||
-- for j = y, y + height - 1 do for i = x, x + width - 1 do buffer.semiPixelSet(i, j, color) end end
|
||||
local index, indexStepForward, indexStepBackward, jPercentTwoEqualsZero, jFixed = buffer.getIndexByCoordinates(x, math.ceil(y / 2)), (buffer.width - width) * 3, width * 3
|
||||
local function semiPixelSquare(x, y, width, height, color)
|
||||
-- for j = y, y + height - 1 do for i = x, x + width - 1 do semiPixelSet(i, j, color) end end
|
||||
local index, indexStepForward, indexStepBackward, jPercentTwoEqualsZero, jFixed = getIndex(x, mathCeil(y / 2)), (bufferWidth - width) * 3, width * 3
|
||||
for j = y, y + height - 1 do
|
||||
jPercentTwoEqualsZero = j % 2 == 0
|
||||
|
||||
for i = x, x + width - 1 do
|
||||
jFixed = math.ceil(j / 2)
|
||||
-- if x >= buffer.drawLimit.x1 and jFixed >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and jFixed <= buffer.drawLimit.y2 then
|
||||
buffer.semiPixelRawSet(index, color, jPercentTwoEqualsZero)
|
||||
jFixed = mathCeil(j / 2)
|
||||
-- if x >= drawLimitX1 and jFixed >= drawLimitY1 and x <= drawLimitX2 and jFixed <= drawLimitY2 then
|
||||
semiPixelRawSet(index, color, jPercentTwoEqualsZero)
|
||||
-- end
|
||||
index = index + 3
|
||||
end
|
||||
@ -367,18 +406,18 @@ function buffer.semiPixelSquare(x, y, width, height, color)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.semiPixelLine(x1, y1, x2, y2, color)
|
||||
buffer.rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||
buffer.semiPixelSet(x, y, color)
|
||||
local function semiPixelLine(x1, y1, x2, y2, color)
|
||||
rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||
semiPixelSet(x, y, color)
|
||||
end)
|
||||
end
|
||||
|
||||
function buffer.semiPixelCircle(xCenter, yCenter, radius, color)
|
||||
local function semiPixelCircle(xCenter, yCenter, radius, color)
|
||||
local function insertPoints(x, y)
|
||||
buffer.semiPixelSet(xCenter + x, yCenter + y, color)
|
||||
buffer.semiPixelSet(xCenter + x, yCenter - y, color)
|
||||
buffer.semiPixelSet(xCenter - x, yCenter + y, color)
|
||||
buffer.semiPixelSet(xCenter - x, yCenter - y, color)
|
||||
semiPixelSet(xCenter + x, yCenter + y, color)
|
||||
semiPixelSet(xCenter + x, yCenter - y, color)
|
||||
semiPixelSet(xCenter - x, yCenter + y, color)
|
||||
semiPixelSet(xCenter - x, yCenter - y, color)
|
||||
end
|
||||
|
||||
local x, y = 0, radius
|
||||
@ -410,7 +449,7 @@ end
|
||||
local function getConnectionPoints(points, time)
|
||||
local connectionPoints = {}
|
||||
for point = 1, #points - 1 do
|
||||
table.insert(connectionPoints, getPointTimedPosition(points[point], points[point + 1], time))
|
||||
tableInsert(connectionPoints, getPointTimedPosition(points[point], points[point + 1], time))
|
||||
end
|
||||
return connectionPoints
|
||||
end
|
||||
@ -423,77 +462,77 @@ local function getMainPointPosition(points, time)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.semiPixelBezierCurve(points, color, precision)
|
||||
local function semiPixelBezierCurve(points, color, precision)
|
||||
local linePoints = {}
|
||||
for time = 0, 1, precision or 0.01 do
|
||||
table.insert(linePoints, getMainPointPosition(points, time))
|
||||
tableInsert(linePoints, getMainPointPosition(points, time))
|
||||
end
|
||||
|
||||
for point = 1, #linePoints - 1 do
|
||||
buffer.semiPixelLine(math.floor(linePoints[point].x), math.floor(linePoints[point].y), math.floor(linePoints[point + 1].x), math.floor(linePoints[point + 1].y), color)
|
||||
semiPixelLine(mathFloor(linePoints[point].x), mathFloor(linePoints[point].y), mathFloor(linePoints[point + 1].x), mathFloor(linePoints[point + 1].y), color)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- DELETE THIS CYKA BLYAD NAHOOOY ZAEBAL GOVNOKOD PLODIT ----------------------------------------------
|
||||
|
||||
function buffer.button(x, y, width, height, background, foreground, text)
|
||||
local textLength = unicode.len(text)
|
||||
if textLength > width - 2 then text = unicode.sub(text, 1, width - 2) end
|
||||
local function button(x, y, width, height, background, foreground, data)
|
||||
local textLength = unicodeLen(data)
|
||||
if textLength > width - 2 then data = unicodeSub(data, 1, width - 2) end
|
||||
|
||||
local textPosX = math.floor(x + width / 2 - textLength / 2)
|
||||
local textPosY = math.floor(y + height / 2)
|
||||
buffer.square(x, y, width, height, background, foreground, " ")
|
||||
buffer.text(textPosX, textPosY, foreground, text)
|
||||
local textPosX = mathFloor(x + width / 2 - textLength / 2)
|
||||
local textPosY = mathFloor(y + height / 2)
|
||||
square(x, y, width, height, background, foreground, " ")
|
||||
text(textPosX, textPosY, foreground, data)
|
||||
|
||||
return x, y, (x + width - 1), (y + height - 1)
|
||||
end
|
||||
|
||||
function buffer.adaptiveButton(x, y, xOffset, yOffset, background, foreground, text)
|
||||
local width = xOffset * 2 + unicode.len(text)
|
||||
local function adaptiveButton(x, y, xOffset, yOffset, background, foreground, data)
|
||||
local width = xOffset * 2 + unicodeLen(data)
|
||||
local height = yOffset * 2 + 1
|
||||
|
||||
buffer.square(x, y, width, height, background, 0xFFFFFF, " ")
|
||||
buffer.text(x + xOffset, y + yOffset, foreground, text)
|
||||
square(x, y, width, height, background, 0xFFFFFF, " ")
|
||||
text(x + xOffset, y + yOffset, foreground, data)
|
||||
|
||||
return x, y, (x + width - 1), (y + height - 1)
|
||||
end
|
||||
|
||||
function buffer.framedButton(x, y, width, height, backColor, buttonColor, text)
|
||||
buffer.square(x, y, width, height, backColor, buttonColor, " ")
|
||||
buffer.frame(x, y, width, height, buttonColor)
|
||||
local function framedButton(x, y, width, height, backColor, buttonColor, data)
|
||||
square(x, y, width, height, backColor, buttonColor, " ")
|
||||
frame(x, y, width, height, buttonColor)
|
||||
|
||||
x = math.floor(x + width / 2 - unicode.len(text) / 2)
|
||||
y = math.floor(y + height / 2)
|
||||
x = mathFloor(x + width / 2 - unicodeLen(data) / 2)
|
||||
y = mathFloor(y + height / 2)
|
||||
|
||||
buffer.text(x, y, buttonColor, text)
|
||||
text(x, y, buttonColor, data)
|
||||
end
|
||||
|
||||
function buffer.scrollBar(x, y, width, height, countOfAllElements, currentElement, backColor, frontColor)
|
||||
local sizeOfScrollBar = math.ceil(height / countOfAllElements)
|
||||
local displayBarFrom = math.floor(y + height * ((currentElement - 1) / countOfAllElements))
|
||||
local function scrollBar(x, y, width, height, countOfAllElements, currentElement, backColor, frontColor)
|
||||
local sizeOfScrollBar = mathCeil(height / countOfAllElements)
|
||||
local displayBarFrom = mathFloor(y + height * ((currentElement - 1) / countOfAllElements))
|
||||
|
||||
buffer.square(x, y, width, height, backColor, 0xFFFFFF, " ")
|
||||
buffer.square(x, displayBarFrom, width, sizeOfScrollBar, frontColor, 0xFFFFFF, " ")
|
||||
square(x, y, width, height, backColor, 0xFFFFFF, " ")
|
||||
square(x, displayBarFrom, width, sizeOfScrollBar, frontColor, 0xFFFFFF, " ")
|
||||
|
||||
sizeOfScrollBar, displayBarFrom = nil, nil
|
||||
end
|
||||
|
||||
function buffer.horizontalScrollBar(x, y, width, countOfAllElements, currentElement, background, foreground)
|
||||
local pipeSize = math.ceil(width / countOfAllElements)
|
||||
local displayBarFrom = math.floor(x + width * ((currentElement - 1) / countOfAllElements))
|
||||
local function horizontalScrollBar(x, y, width, countOfAllElements, currentElement, background, foreground)
|
||||
local pipeSize = mathCeil(width / countOfAllElements)
|
||||
local displayBarFrom = mathFloor(x + width * ((currentElement - 1) / countOfAllElements))
|
||||
|
||||
buffer.text(x, y, background, string.rep("▄", width))
|
||||
buffer.text(displayBarFrom, y, foreground, string.rep("▄", pipeSize))
|
||||
text(x, y, background, string.rep("▄", width))
|
||||
text(displayBarFrom, y, foreground, string.rep("▄", pipeSize))
|
||||
end
|
||||
|
||||
function buffer.customImage(x, y, pixels)
|
||||
local function customImage(x, y, pixels)
|
||||
x = x - 1
|
||||
y = y - 1
|
||||
|
||||
for i=1, #pixels do
|
||||
for j=1, #pixels[1] do
|
||||
if pixels[i][j][3] ~= "#" then
|
||||
buffer.set(x + j, y + i, pixels[i][j][1], pixels[i][j][2], pixels[i][j][3])
|
||||
set(x + j, y + i, pixels[i][j][1], pixels[i][j][2], pixels[i][j][3])
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -507,58 +546,57 @@ local function info(...)
|
||||
local args = {...}
|
||||
local text = {}
|
||||
for i = 1, #args do
|
||||
table.insert(text, tostring(args[i]))
|
||||
tableInsert(text, tostring(args[i]))
|
||||
end
|
||||
|
||||
local b = buffer.GPUProxy.getBackground()
|
||||
local f = buffer.GPUProxy.getForeground()
|
||||
buffer.GPUProxy.setBackground(0x0)
|
||||
buffer.GPUProxy.setForeground(0xFFFFFF)
|
||||
buffer.GPUProxy.fill(1, buffer.height, buffer.width, 1, " ")
|
||||
buffer.GPUProxy.set(2, buffer.height, table.concat(text, ", "))
|
||||
buffer.GPUProxy.setBackground(b)
|
||||
buffer.GPUProxy.setForeground(f)
|
||||
|
||||
require("event").pull("touch")
|
||||
local b = GPUProxyGetBackground()
|
||||
local f = GPUProxyGetForeground()
|
||||
GPUProxySetBackground(0x0)
|
||||
GPUProxySetForeground(0xFFFFFF)
|
||||
GPUProxyFill(1, bufferHeight, bufferWidth, 1, " ")
|
||||
GPUProxySet(2, bufferHeight, table.concat(text, ", "))
|
||||
GPUProxySetBackground(b)
|
||||
GPUProxySetForeground(f)
|
||||
end
|
||||
|
||||
local function calculateDifference(index, indexPlus1, indexPlus2)
|
||||
local somethingIsChanged =
|
||||
buffer.currentFrame[index] ~= buffer.newFrame[index] or
|
||||
buffer.currentFrame[indexPlus1] ~= buffer.newFrame[indexPlus1] or
|
||||
buffer.currentFrame[indexPlus2] ~= buffer.newFrame[indexPlus2]
|
||||
currentFrame[index] ~= newFrame[index] or
|
||||
currentFrame[indexPlus1] ~= newFrame[indexPlus1] or
|
||||
currentFrame[indexPlus2] ~= newFrame[indexPlus2]
|
||||
|
||||
buffer.currentFrame[index] = buffer.newFrame[index]
|
||||
buffer.currentFrame[indexPlus1] = buffer.newFrame[indexPlus1]
|
||||
buffer.currentFrame[indexPlus2] = buffer.newFrame[indexPlus2]
|
||||
currentFrame[index] = newFrame[index]
|
||||
currentFrame[indexPlus1] = newFrame[indexPlus1]
|
||||
currentFrame[indexPlus2] = newFrame[indexPlus2]
|
||||
|
||||
return somethingIsChanged
|
||||
end
|
||||
|
||||
function buffer.draw(force)
|
||||
local changes, index, indexStepOnEveryLine, indexPlus1, indexPlus2, sameCharArray, x, xCharCheck, indexCharCheck, indexCharCheckPlus1, indexCharCheckPlus2, currentForeground = {}, buffer.getIndexByCoordinates(buffer.drawLimit.x1, buffer.drawLimit.y1), (buffer.width - buffer.drawLimit.x2 + buffer.drawLimit.x1 - 1) * 3
|
||||
local function draw(force)
|
||||
-- local oldClock = os.clock()
|
||||
local changes, index, indexStepOnEveryLine, indexPlus1, indexPlus2, sameCharArray, x, xCharCheck, indexCharCheck, indexCharCheckPlus1, indexCharCheckPlus2, currentForeground = {}, getIndex(drawLimitX1, drawLimitY1), (bufferWidth - drawLimitX2 + drawLimitX1 - 1) * 3
|
||||
|
||||
for y = buffer.drawLimit.y1, buffer.drawLimit.y2 do
|
||||
x = buffer.drawLimit.x1
|
||||
for y = drawLimitY1, drawLimitY2 do
|
||||
x = drawLimitX1
|
||||
|
||||
while x <= buffer.drawLimit.x2 do
|
||||
while x <= drawLimitX2 do
|
||||
indexPlus1, indexPlus2 = index + 1, index + 2
|
||||
|
||||
if calculateDifference(index, indexPlus1, indexPlus2) or force then
|
||||
sameCharArray = { buffer.currentFrame[indexPlus2] }
|
||||
sameCharArray = { currentFrame[indexPlus2] }
|
||||
xCharCheck, indexCharCheck = x + 1, index + 3
|
||||
|
||||
while xCharCheck <= buffer.drawLimit.x2 do
|
||||
while xCharCheck <= drawLimitX2 do
|
||||
indexCharCheckPlus1, indexCharCheckPlus2 = indexCharCheck + 1, indexCharCheck + 2
|
||||
if
|
||||
buffer.currentFrame[index] == buffer.newFrame[indexCharCheck] and
|
||||
currentFrame[index] == newFrame[indexCharCheck] and
|
||||
(
|
||||
buffer.newFrame[indexCharCheckPlus2] == " " or
|
||||
buffer.currentFrame[indexPlus1] == buffer.newFrame[indexCharCheckPlus1]
|
||||
newFrame[indexCharCheckPlus2] == " " or
|
||||
currentFrame[indexPlus1] == newFrame[indexCharCheckPlus1]
|
||||
)
|
||||
then
|
||||
calculateDifference(indexCharCheck, indexCharCheckPlus1, indexCharCheckPlus2)
|
||||
table.insert(sameCharArray, buffer.currentFrame[indexCharCheckPlus2])
|
||||
tableInsert(sameCharArray, currentFrame[indexCharCheckPlus2])
|
||||
else
|
||||
break
|
||||
end
|
||||
@ -566,12 +604,12 @@ function buffer.draw(force)
|
||||
indexCharCheck, xCharCheck = indexCharCheck + 3, xCharCheck + 1
|
||||
end
|
||||
|
||||
changes[buffer.currentFrame[index]] = changes[buffer.currentFrame[index]] or {}
|
||||
changes[buffer.currentFrame[index]][buffer.currentFrame[indexPlus1]] = changes[buffer.currentFrame[index]][buffer.currentFrame[indexPlus1]] or {}
|
||||
changes[currentFrame[index]] = changes[currentFrame[index]] or {}
|
||||
changes[currentFrame[index]][currentFrame[indexPlus1]] = changes[currentFrame[index]][currentFrame[indexPlus1]] or {}
|
||||
|
||||
table.insert(changes[buffer.currentFrame[index]][buffer.currentFrame[indexPlus1]], x)
|
||||
table.insert(changes[buffer.currentFrame[index]][buffer.currentFrame[indexPlus1]], y)
|
||||
table.insert(changes[buffer.currentFrame[index]][buffer.currentFrame[indexPlus1]], table.concat(sameCharArray))
|
||||
tableInsert(changes[currentFrame[index]][currentFrame[indexPlus1]], x)
|
||||
tableInsert(changes[currentFrame[index]][currentFrame[indexPlus1]], y)
|
||||
tableInsert(changes[currentFrame[index]][currentFrame[indexPlus1]], table.concat(sameCharArray))
|
||||
|
||||
x, index = x + #sameCharArray - 1, index + #sameCharArray * 3 - 3
|
||||
end
|
||||
@ -583,35 +621,73 @@ function buffer.draw(force)
|
||||
end
|
||||
|
||||
for background in pairs(changes) do
|
||||
buffer.GPUProxy.setBackground(background)
|
||||
GPUProxySetBackground(background)
|
||||
|
||||
for foreground in pairs(changes[background]) do
|
||||
if currentForeground ~= foreground then
|
||||
buffer.GPUProxy.setForeground(foreground)
|
||||
GPUProxySetForeground(foreground)
|
||||
currentForeground = foreground
|
||||
end
|
||||
|
||||
for i = 1, #changes[background][foreground], 3 do
|
||||
buffer.GPUProxy.set(changes[background][foreground][i], changes[background][foreground][i + 1], changes[background][foreground][i + 2])
|
||||
GPUProxySet(changes[background][foreground][i], changes[background][foreground][i + 1], changes[background][foreground][i + 2])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
changes = nil
|
||||
-- info("clock: " .. (os.clock() - oldClock))
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
|
||||
buffer.start = buffer.flush
|
||||
buffer.rectangle = buffer.square
|
||||
buffer.flush()
|
||||
bindGPU(component.getPrimary("gpu").address)
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- buffer.formattedText(2, 2, "Hello world #FFDB40meow! #FF4940This is colored #44FF44text")
|
||||
-- buffer.draw(true)
|
||||
return {
|
||||
getCoordinates = getCoordinates,
|
||||
getIndex = getIndex,
|
||||
setDrawLimit = setDrawLimit,
|
||||
resetDrawLimit = resetDrawLimit,
|
||||
getDrawLimit = getDrawLimit,
|
||||
flush = flush,
|
||||
setResolution = setResolution,
|
||||
bindScreen = bindScreen,
|
||||
bindGPU = bindGPU,
|
||||
getGPUProxy = getGPUProxy,
|
||||
getResolution = getResolution,
|
||||
getWidth = getWidth,
|
||||
getHeight = getHeight,
|
||||
rawSet = rawSet,
|
||||
rawGet = rawGet,
|
||||
get = get,
|
||||
set = set,
|
||||
square = square,
|
||||
clear = clear,
|
||||
copy = copy,
|
||||
paste = paste,
|
||||
rasterizeLine = rasterizeLine,
|
||||
line = line,
|
||||
text = text,
|
||||
formattedText = formattedText,
|
||||
image = image,
|
||||
frame = frame,
|
||||
semiPixelRawSet = semiPixelRawSet,
|
||||
semiPixelSet = semiPixelSet,
|
||||
semiPixelSquare = semiPixelSquare,
|
||||
semiPixelLine = semiPixelLine,
|
||||
semiPixelCircle = semiPixelCircle,
|
||||
semiPixelBezierCurve = semiPixelBezierCurve,
|
||||
draw = draw,
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
|
||||
return buffer
|
||||
button = button,
|
||||
adaptiveButton = adaptiveButton,
|
||||
framedButton = framedButton,
|
||||
scrollBar = scrollBar,
|
||||
horizontalScrollBar = horizontalScrollBar,
|
||||
customImage = customImage,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -25,33 +25,33 @@ rayEngine.chatHistory = {}
|
||||
|
||||
-- Позиция горизонта, относительно которой рисуется мир
|
||||
function rayEngine.calculateHorizonPosition()
|
||||
rayEngine.horizonPosition = math.floor(buffer.height / 2)
|
||||
rayEngine.horizonPosition = math.floor(buffer.getHeight() / 2)
|
||||
end
|
||||
|
||||
-- Размер панели чата и лимита его истории
|
||||
function rayEngine.calculateChatSize()
|
||||
rayEngine.chatPanelWidth, rayEngine.chatPanelHeight = math.floor(buffer.width * 0.4), math.floor(buffer.height * 0.4)
|
||||
rayEngine.chatPanelWidth, rayEngine.chatPanelHeight = math.floor(buffer.getWidth() * 0.4), math.floor(buffer.getHeight() * 0.4)
|
||||
rayEngine.chatHistoryLimit = rayEngine.chatPanelHeight
|
||||
end
|
||||
|
||||
-- Шаг, с которым будет изменяться угол рейкаста
|
||||
function rayEngine.calculateRaycastStep()
|
||||
rayEngine.raycastStep = rayEngine.player.fieldOfView / buffer.width
|
||||
rayEngine.raycastStep = rayEngine.player.fieldOfView / buffer.getWidth()
|
||||
end
|
||||
|
||||
-- Позиция оружия на экране и всех его вспомогательных текстур
|
||||
function rayEngine.calculateWeaponPosition()
|
||||
rayEngine.currentWeapon.xWeapon = buffer.width - rayEngine.currentWeapon.weaponTexture[1] + 1
|
||||
rayEngine.currentWeapon.yWeapon = buffer.height - rayEngine.currentWeapon.weaponTexture[2] + 1
|
||||
rayEngine.currentWeapon.xWeapon = buffer.getWidth() - rayEngine.currentWeapon.weaponTexture[1] + 1
|
||||
rayEngine.currentWeapon.yWeapon = buffer.getHeight() - rayEngine.currentWeapon.weaponTexture[2] + 1
|
||||
rayEngine.currentWeapon.xFire = rayEngine.currentWeapon.xWeapon + rayEngine.weapons[rayEngine.currentWeapon.ID].firePosition.x
|
||||
rayEngine.currentWeapon.yFire = rayEngine.currentWeapon.yWeapon + rayEngine.weapons[rayEngine.currentWeapon.ID].firePosition.y
|
||||
rayEngine.currentWeapon.xCrosshair = math.floor(buffer.width / 2 - rayEngine.currentWeapon.crosshairTexture[1] / 2)
|
||||
rayEngine.currentWeapon.yCrosshair = math.floor(buffer.height / 2 - rayEngine.currentWeapon.crosshairTexture[2] / 2)
|
||||
rayEngine.currentWeapon.xCrosshair = math.floor(buffer.getWidth() / 2 - rayEngine.currentWeapon.crosshairTexture[1] / 2)
|
||||
rayEngine.currentWeapon.yCrosshair = math.floor(buffer.getHeight() / 2 - rayEngine.currentWeapon.crosshairTexture[2] / 2)
|
||||
end
|
||||
|
||||
-- Грубо говоря, это расстояние от камеры до виртуального экрана, на котором рисуется весь наш мир, влияет на размер блоков
|
||||
function rayEngine.calculateDistanceToProjectionPlane()
|
||||
rayEngine.distanceToProjectionPlane = (buffer.width / 2) / math.tan(math.rad((rayEngine.player.fieldOfView / 2)))
|
||||
rayEngine.distanceToProjectionPlane = (buffer.getWidth() / 2) / math.tan(math.rad((rayEngine.player.fieldOfView / 2)))
|
||||
end
|
||||
|
||||
-- Быстрый перерасчет всего, что нужно
|
||||
@ -287,11 +287,11 @@ end
|
||||
|
||||
function rayEngine.intro()
|
||||
local logo = image.fromString("17060000FF 0000FF 0000FF 0000FF 007EFF▄007EFF▄007EFF▄007EFF▀007EFF▀007EFF▀007EFF▀007EFF▀007EFF▀007EFF▀007EFF▄007EFF▄007EFF▄0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 007EFF▄007EFF▀007EFF▀0000FF 0000FF 0000FF 0000FF 0053FF▄0053FF▀0053FF▀0053FF▀0053FF▄0000FF 0000FF 0000FF 0000FF 007EFF▀007EFF▀007EFF▄0000FF 0000FF 0000FF 007EFF▀007EFF▄0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 530000 0000FF 0078FF▀0000FF 537800▀0078FF▀0078FF▀0078FF▀0078FF▀0078FF▀0078FF▀7E7800▀0078FF▀0000FF 0078FF▀0000FF 0000FF 007EFF▀007EFF▀007EFF▄007EFF▄007EFF▄0000FF 0000FF 0053FF▀0053FF▀0053FF▀0000FF 0000FF 007EFF▄007EFF▄007EFF▄007EFF▀007EFF▀0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 007EFF▀007EFF▀007EFF▀007EFF▀007EFF▀007EFF▀007EFF▀0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 007EFFP007EFFo007EFFw007EFFe007EFFr007EFFe007EFFd0000FF 007EFFb007EFFy0000FF 007EFFR007EFFa007EFFy007EFFE007EFFn007EFFg007EFFi007EFFn007EFFe007EFF™0000FF 0000FF ")
|
||||
local x, y = math.floor(buffer.width / 2 - logo[1] / 2), math.floor(buffer.height / 2 - logo[2] / 2)
|
||||
local x, y = math.floor(buffer.getWidth() / 2 - logo[1] / 2), math.floor(buffer.getHeight() / 2 - logo[2] / 2)
|
||||
local function draw(transparency)
|
||||
buffer.clear(0xF0F0F0);
|
||||
buffer.image(x, y, logo)
|
||||
buffer.square(1, 1, buffer.width, buffer.height, 0x000000, 0x000000, " ", transparency)
|
||||
buffer.square(1, 1, buffer.getWidth(), buffer.getHeight(), 0x000000, 0x000000, " ", transparency)
|
||||
buffer.draw()
|
||||
os.sleep(0)
|
||||
end
|
||||
@ -347,7 +347,7 @@ local function addItemToChatHistory(text, color)
|
||||
end
|
||||
|
||||
function rayEngine.chat(transparency)
|
||||
local x, y = 1, buffer.height - rayEngine.chatPanelHeight - 3
|
||||
local x, y = 1, buffer.getHeight() - rayEngine.chatPanelHeight - 3
|
||||
buffer.square(x, y, rayEngine.chatPanelWidth, rayEngine.chatPanelHeight, 0x000000, 0xFFFFFF, " ", transparency or 0.5)
|
||||
buffer.setDrawLimit(x, y, x + rayEngine.chatPanelWidth - 1, y + rayEngine.chatPanelHeight - 1)
|
||||
local yMessage = y + rayEngine.chatPanelHeight - 1
|
||||
@ -367,13 +367,13 @@ end
|
||||
function rayEngine.commandLine(transparency)
|
||||
transparency = transparency or 50
|
||||
local inputPanelHeight = 3
|
||||
local x, y = 1, buffer.height - inputPanelHeight + 1
|
||||
local x, y = 1, buffer.getHeight() - inputPanelHeight + 1
|
||||
--Врубаем чат и рисуем все, включая его
|
||||
rayEngine.chatEnabled = true
|
||||
rayEngine.update()
|
||||
|
||||
--Ввод данных
|
||||
local input = GUI.input(x, y, buffer.width, 3, 0xFFFFFF, 0x3C3C3C, 0x666666, 0xFFFFFF, 0x3C3C3C, "")
|
||||
local input = GUI.input(x, y, buffer.getWidth(), 3, 0xFFFFFF, 0x3C3C3C, 0x666666, 0xFFFFFF, 0x3C3C3C, "")
|
||||
input.eventHandler({draw = function() input:draw() end}, input, {[1] = "touch", [3] = input.x, [4] = input.y})
|
||||
|
||||
local words = {}; for word in string.gmatch(input.text, "[^%s]+") do table.insert(words, unicode.lower(word)) end
|
||||
@ -457,9 +457,9 @@ function rayEngine.drawWeapon()
|
||||
end
|
||||
|
||||
function rayEngine.drawStats()
|
||||
local width = math.floor(buffer.width * 0.3)
|
||||
local width = math.floor(buffer.getWidth() * 0.3)
|
||||
local height = 5
|
||||
local x, y = buffer.width - width - 1, 2
|
||||
local x, y = buffer.getWidth() - width - 1, 2
|
||||
buffer.square(x, y, width, height, 0x000000, 0xFFFFFF, " ", 0.5)
|
||||
|
||||
GUI.progressBar(x + 1, y + 4, width - 2, 1, 0x000000, 0xFF5555, rayEngine.player.health.current, rayEngine.player.health.maximum, true)
|
||||
@ -490,7 +490,7 @@ function rayEngine.drawWorld()
|
||||
--Земля
|
||||
buffer.clear(rayEngine.world.colors.groundByTime)
|
||||
--Небо
|
||||
buffer.square(1, 1, buffer.width, rayEngine.horizonPosition, rayEngine.world.colors.sky.current, 0x0, " ")
|
||||
buffer.square(1, 1, buffer.getWidth(), rayEngine.horizonPosition, rayEngine.world.colors.sky.current, 0x0, " ")
|
||||
--Сцена
|
||||
local startAngle, endAngle, startX, distanceToTile, tileID, height, startY, tileColor = rayEngine.player.rotation - rayEngine.player.fieldOfView / 2, rayEngine.player.rotation + rayEngine.player.fieldOfView / 2, 1
|
||||
for angle = startAngle, endAngle, rayEngine.raycastStep do
|
||||
@ -512,7 +512,7 @@ function rayEngine.drawWorld()
|
||||
|
||||
--ТИКСТУРКА)))00
|
||||
-- local xTexture = startX % rayEngine.properties.tileWidth + 1
|
||||
-- if xTexture >= 1 and xTexture <= buffer.width then
|
||||
-- if xTexture >= 1 and xTexture <= buffer.getWidth() then
|
||||
-- local column = image.getColumn(rayEngine.wallsTexture, xTexture)
|
||||
-- column = image.transform(column, 1, height)
|
||||
-- buffer.image(math.floor(startX), math.floor(startY), column)
|
||||
@ -529,7 +529,7 @@ function rayEngine.update()
|
||||
if rayEngine.currentWeapon then rayEngine.drawWeapon() end
|
||||
if rayEngine.minimapEnabled then rayEngine.drawMap(3, 2, 24, 24, 0.5) end
|
||||
-- rayEngine.drawStats()
|
||||
local xTools, yTools = 3, buffer.height - 25
|
||||
local xTools, yTools = 3, buffer.getHeight() - 25
|
||||
if rayEngine.compassEnabled then rayEngine.compass(xTools, yTools); xTools = xTools + 30 end
|
||||
if rayEngine.watchEnabled then rayEngine.watch(xTools, yTools) end
|
||||
if rayEngine.chatEnabled then rayEngine.chat() end
|
||||
@ -550,7 +550,7 @@ end
|
||||
|
||||
function rayEngine.changeResolution(width, height)
|
||||
component.gpu.setResolution(width, height)
|
||||
buffer.start()
|
||||
buffer.flush()
|
||||
rayEngine.calculateAllParameters()
|
||||
end
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ syntax.colorScheme = {
|
||||
scrollBarBackground = 0x2D2D2D,
|
||||
scrollBarForeground = 0x5A5A5A,
|
||||
selection = 0x555555,
|
||||
indentation = 0x3C3C3C,
|
||||
indentation = 0x2D2D2D,
|
||||
}
|
||||
|
||||
syntax.patterns = {
|
||||
@ -86,8 +86,10 @@ syntax.patterns = {
|
||||
|
||||
-- Отрисовка строки с подсвеченным синтаксисом
|
||||
function syntax.highlightString(x, y, str, indentationWidth)
|
||||
if y >= buffer.drawLimit.y1 and y <= buffer.drawLimit.y2 then
|
||||
local stringLength, symbols, colors, searchFrom, starting, ending, bufferIndex = unicode.len(str), {}, {}
|
||||
local x1, y1, x2, y2 = buffer.getDrawLimit()
|
||||
|
||||
if y >= y1 and y <= y2 then
|
||||
local stringLength, symbols, colors, searchFrom, starting, ending, bufferIndex, background = unicode.len(str), {}, {}
|
||||
|
||||
for symbol = 1, stringLength do
|
||||
symbols[symbol] = unicode.sub(str, symbol, symbol)
|
||||
@ -124,12 +126,13 @@ function syntax.highlightString(x, y, str, indentationWidth)
|
||||
indentationSymbolCounter = indentationSymbolCounter - 1
|
||||
end
|
||||
|
||||
if x > buffer.drawLimit.x2 then
|
||||
if x > x2 then
|
||||
break
|
||||
elseif x >= buffer.drawLimit.x1 then
|
||||
bufferIndex = bufferIndex or buffer.getIndexByCoordinates(x, y)
|
||||
buffer.newFrame[bufferIndex + 1] = colors[symbol] or syntax.colorScheme.text
|
||||
buffer.newFrame[bufferIndex + 2] = symbols[symbol]
|
||||
elseif x >= x1 then
|
||||
bufferIndex = bufferIndex or buffer.getIndex(x, y)
|
||||
background = buffer.rawGet(bufferIndex)
|
||||
buffer.rawSet(bufferIndex, background, colors[symbol] or syntax.colorScheme.text, symbols[symbol])
|
||||
|
||||
bufferIndex = bufferIndex + 3
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user