mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Жирная оптимизация производительности
This commit is contained in:
parent
c271347f29
commit
a2552759f1
@ -5,7 +5,7 @@
|
||||
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/About/",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=3.74,
|
||||
version=3.76,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Pictures/MoonTouch.pic",
|
||||
@ -223,7 +223,7 @@
|
||||
path="/lib/MineOSCore.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
|
||||
type="Library",
|
||||
version=1.75,
|
||||
version=1.76,
|
||||
},
|
||||
{
|
||||
path="/lib/advancedLua.lua",
|
||||
@ -256,7 +256,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/color.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
},
|
||||
{
|
||||
path="/lib/ImageFormatModules/OCIF.lua",
|
||||
@ -270,7 +270,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/image.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.28,
|
||||
version=1.29,
|
||||
},
|
||||
{
|
||||
path="/lib/serialization.lua",
|
||||
@ -283,13 +283,13 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.75,
|
||||
version=1.77,
|
||||
},
|
||||
{
|
||||
path="/lib/rayEngine.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/rayEngine.lua",
|
||||
type="Library",
|
||||
version=1.41,
|
||||
version=1.42,
|
||||
},
|
||||
{
|
||||
path="/lib/json.lua",
|
||||
@ -350,7 +350,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/doubleBuffering.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.30,
|
||||
version=1.31,
|
||||
},
|
||||
{
|
||||
path="/lib/compressor.lua",
|
||||
@ -374,31 +374,31 @@
|
||||
path="/lib/vector.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/vector.lua",
|
||||
type="Library",
|
||||
version=1.03,
|
||||
version=1.10,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Main.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Main.lua",
|
||||
type="Library",
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Materials.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Materials.lua",
|
||||
type="Library",
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
},
|
||||
{
|
||||
path="/lib/OpenComputersGL/Renderer.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/OpenComputersGL/Renderer.lua",
|
||||
type="Library",
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
},
|
||||
{
|
||||
path="/lib/MeowEngine/Main.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MeowEngine/Main.lua",
|
||||
type="Library",
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
},
|
||||
|
||||
----------------------------------------------------- Скрипты и дополнения к ним --------------------------------------------------------------------------
|
||||
@ -462,7 +462,7 @@
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic",
|
||||
createShortcut="dock",
|
||||
forceDownload=true,
|
||||
version=1.77,
|
||||
version=1.78,
|
||||
resources={
|
||||
{
|
||||
path="/Localization/Russian.lang",
|
||||
@ -482,7 +482,7 @@
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DTest/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
forceDownload=true,
|
||||
version=1.21,
|
||||
version=1.22,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/Spinner",
|
||||
@ -548,7 +548,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/GeoScan2/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.08,
|
||||
version=1.09,
|
||||
resources={
|
||||
{
|
||||
path="/Earth.pic",
|
||||
@ -578,7 +578,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Weather/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.14,
|
||||
version=1.15,
|
||||
resources={
|
||||
{
|
||||
path="/Cloudy.pic",
|
||||
@ -626,7 +626,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/FlappyBird/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.14,
|
||||
version=1.15,
|
||||
resources={
|
||||
{
|
||||
path="/Flappy.pic",
|
||||
@ -641,7 +641,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/RayWalk/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.66,
|
||||
version=1.68,
|
||||
resources={
|
||||
{
|
||||
path="/Localization/Russian.lang",
|
||||
@ -764,7 +764,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/PrintImage/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.13,
|
||||
version=1.14,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/Palette",
|
||||
@ -904,7 +904,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/HoloClock/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.04,
|
||||
version=1.05,
|
||||
},
|
||||
-- {
|
||||
-- path="/MineOS/Applications/Finder",
|
||||
@ -1044,7 +1044,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/BufferDemo/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.01,
|
||||
version=1.02,
|
||||
resources={
|
||||
{
|
||||
path="/Wallpaper.pic",
|
||||
|
||||
@ -386,7 +386,7 @@ mainContainer:addChild(GUI.textBox(1, mainContainer.height - #lines + 1, mainCon
|
||||
local elementY = 2
|
||||
mainContainer.toolbar = mainContainer:addChild(GUI.container(mainContainer.width - 31, 1, 32, mainContainer.height))
|
||||
local elementWidth = mainContainer.toolbar.width - 2
|
||||
mainContainer.toolbar:addChild(GUI.panel(1, 1, mainContainer.toolbar.width, mainContainer.toolbar.height, 0x0, 50))
|
||||
mainContainer.toolbar:addChild(GUI.panel(1, 1, mainContainer.toolbar.width, mainContainer.toolbar.height, 0x0, 0.5))
|
||||
|
||||
mainContainer.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Render mode")):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); elementY = elementY + 2
|
||||
mainContainer.toolbar.renderModeComboBox = mainContainer.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + mainContainer.toolbar.renderModeComboBox.height + 1
|
||||
|
||||
@ -6,7 +6,7 @@ local image = require("image")
|
||||
local currentBackground = 0x990000
|
||||
local risovatKartinku = true
|
||||
local showPanel = true
|
||||
local transparency = 25
|
||||
local transparency = 0.25
|
||||
local xWindow, yWindow = 5, 5
|
||||
|
||||
local fon = image.load("MineOS/Applications/BufferDemo.app/Resources/Wallpaper.pic")
|
||||
@ -31,7 +31,7 @@ local width, height = 82, 25
|
||||
local function drawWindow(x, y)
|
||||
|
||||
--Тени
|
||||
local shadowTransparency = 60
|
||||
local shadowTransparency = 0.6
|
||||
buffer.square(x + width, y + 1, 2, height, 0x000000, 0xFFFFFF, " ", shadowTransparency)
|
||||
buffer.square(x + 2, y + height, width - 2, 1, 0x000000, 0xFFFFFF, " ", shadowTransparency)
|
||||
|
||||
@ -135,15 +135,15 @@ while true do
|
||||
end
|
||||
elseif e[1] == "scroll" then
|
||||
if e[5] == 1 then
|
||||
if transparency > 5 then
|
||||
transparency = transparency - 5
|
||||
if transparency > 0.05 then
|
||||
transparency = transparency - 0.05
|
||||
drawBackground()
|
||||
drawWindow(xWindow, yWindow)
|
||||
buffer.draw()
|
||||
end
|
||||
else
|
||||
if transparency < 100 then
|
||||
transparency = transparency + 5
|
||||
if transparency < 1 then
|
||||
transparency = transparency + 0.05
|
||||
drawBackground()
|
||||
drawWindow(xWindow, yWindow)
|
||||
buffer.draw()
|
||||
|
||||
@ -48,18 +48,18 @@ local xScore, yScore = math.floor(buffer.width / 2 - 6), math.floor(buffer.heigh
|
||||
|
||||
local function drawColumn(x, upperCornerStartPosition)
|
||||
local y = 1
|
||||
buffer.square(x + 1, y, config.columnWidth, upperCornerStartPosition - config.columnPipeHeight, colors.columnMain)
|
||||
buffer.square(x, upperCornerStartPosition - config.columnPipeHeight, config.columnPipeWidth, config.columnPipeHeight, colors.columnAlternative)
|
||||
buffer.square(x + 1, y, config.columnWidth, upperCornerStartPosition - config.columnPipeHeight, colors.columnMain, 0x0, " ")
|
||||
buffer.square(x, upperCornerStartPosition - config.columnPipeHeight, config.columnPipeWidth, config.columnPipeHeight, colors.columnAlternative, 0x0, " ")
|
||||
|
||||
y = upperCornerStartPosition + config.columnFreeSpace
|
||||
buffer.square(x, y, config.columnPipeWidth, config.columnPipeHeight, colors.columnAlternative)
|
||||
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)
|
||||
buffer.square(x + 1, y, config.columnWidth, buffer.height - y + 1, colors.columnMain, 0x0, " ")
|
||||
end
|
||||
|
||||
local function dieBirdDie()
|
||||
if birdIsAlive then
|
||||
bird = image.blend(bird, 0x880000, 50)
|
||||
bird = image.blend(bird, 0x880000, 0.5)
|
||||
birdIsAlive = false
|
||||
end
|
||||
end
|
||||
@ -113,7 +113,7 @@ local function drawBigCenterText(y, textColor, usePseudoShadow, text)
|
||||
local width = bigLetters.getTextSize(text)
|
||||
local x = math.floor(buffer.width / 2 - width / 2)
|
||||
|
||||
if usePseudoShadow then buffer.square(x - 2, y - 1, width + 4, 7, colors.scoreTextBackground) end
|
||||
if usePseudoShadow then buffer.square(x - 2, y - 1, width + 4, 7, colors.scoreTextBackground, 0x0, " ") end
|
||||
bigLetters.drawText(x, y, textColor, text)
|
||||
end
|
||||
|
||||
@ -200,7 +200,7 @@ local function finalGUI()
|
||||
|
||||
drawAll()
|
||||
|
||||
buffer.square(x, y, widthOfBoard, heightOfBoard, colors.board, 0xFFFFFF, " ", 30)
|
||||
buffer.square(x, y, widthOfBoard, heightOfBoard, colors.board, 0xFFFFFF, " ", 0.3)
|
||||
|
||||
y = y + 2
|
||||
drawBigCenterText(y, colors.boardText, false, "score")
|
||||
|
||||
@ -29,22 +29,22 @@ local mainContainer = GUI.fullScreenContainer()
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function getOpenGLValidColorChannels(color)
|
||||
local r, g, b = color.HEXToRGB(color)
|
||||
local function getOpenGLValidColorChannels(cykaColor)
|
||||
local r, g, b = color.HEXToRGB(cykaColor)
|
||||
return r / 255, g / 255, b / 255
|
||||
end
|
||||
|
||||
local function createCube(x, y, z, color, isVisThrObj)
|
||||
local function createCube(x, y, z, cykaColor, isVisThrObj)
|
||||
local cube = component.glasses.addCube3D()
|
||||
cube.set3DPos(x, y, z)
|
||||
cube.setVisibleThroughObjects(isVisThrObj)
|
||||
cube.setColor(getOpenGLValidColorChannels(color))
|
||||
cube.setColor(getOpenGLValidColorChannels(cykaColor))
|
||||
cube.setAlpha(0.23)
|
||||
return cube
|
||||
end
|
||||
|
||||
local function glassesCreateCube(x, y, z, color, text)
|
||||
local cube = createCube(x, y, z, color, true)
|
||||
local function glassesCreateCube(x, y, z, cykaColor, text)
|
||||
local cube = createCube(x, y, z, cykaColor, true)
|
||||
cube.setVisibleThroughObjects(true)
|
||||
|
||||
local floatingText = component.glasses.addFloatingText()
|
||||
@ -181,7 +181,7 @@ objectY = objectY + 2
|
||||
|
||||
mainContainer:addChild(GUI.button(buffer.width, 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, false)
|
||||
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()
|
||||
@ -193,7 +193,7 @@ mainContainer.scanButton.onTouch = function()
|
||||
local horizontalRange, verticalRange = math.floor(mainContainer.horizontalScanRangeSlider.value), math.floor(mainContainer.verticalScanRangeSlider.value)
|
||||
local total, current = (horizontalRange * 2 + 1) ^ 2, 0
|
||||
|
||||
buffer.clear(0x0, 0x30)
|
||||
buffer.clear(0x0, 0.48)
|
||||
for x = -horizontalRange, horizontalRange do
|
||||
scanResult[x] = {}
|
||||
for z = -horizontalRange, horizontalRange do
|
||||
|
||||
@ -193,7 +193,7 @@ local function getDate()
|
||||
end
|
||||
|
||||
local function flashback()
|
||||
buffer.square(1, 1, buffer.width, buffer.height, 0x000000, 0x000000, " ", 50)
|
||||
buffer.clear(0x0, 0.3)
|
||||
end
|
||||
|
||||
local function drawOnScreen()
|
||||
|
||||
@ -1591,7 +1591,7 @@ local function createMainContainer()
|
||||
end
|
||||
|
||||
mainContainer.errorContainer = mainContainer:addChild(GUI.container(1, 1, 1, 1))
|
||||
mainContainer.errorContainer.backgroundPanel = mainContainer.errorContainer:addChild(GUI.panel(1, 1, 1, 1, 0xFFFFFF, 30))
|
||||
mainContainer.errorContainer.backgroundPanel = mainContainer.errorContainer:addChild(GUI.panel(1, 1, 1, 1, 0xFFFFFF, 0.3))
|
||||
mainContainer.errorContainer.errorTextBox = mainContainer.errorContainer:addChild(GUI.textBox(3, 2, 1, 1, nil, 0x4B4B4B, {}, 1))
|
||||
mainContainer.errorContainer.breakpointExitButton = mainContainer.errorContainer:addChild(GUI.button(1, 1, 1, 1, 0x3C3C3C, 0xCCCCCC, 0x2D2D2D, 0x888888, localization.finishDebug))
|
||||
mainContainer.errorContainer.breakpointContinueButton = mainContainer.errorContainer:addChild(GUI.button(1, 1, 1, 1, 0x444444, 0xCCCCCC, 0x2D2D2D, 0x888888, localization.continueDebug))
|
||||
@ -1600,7 +1600,7 @@ local function createMainContainer()
|
||||
hideErrorContainer()
|
||||
|
||||
mainContainer.settingsContainer = mainContainer:addChild(GUI.container(1, 1, 1, 1))
|
||||
mainContainer.settingsContainer.backgroundPanel = mainContainer.settingsContainer:addChild(GUI.panel(1, 1, mainContainer.settingsContainer.width, mainContainer.settingsContainer.height, 0x0, 30))
|
||||
mainContainer.settingsContainer.backgroundPanel = mainContainer.settingsContainer:addChild(GUI.panel(1, 1, mainContainer.settingsContainer.width, mainContainer.settingsContainer.height, 0x0, 0.3))
|
||||
mainContainer.settingsContainer.backgroundPanel.eventHandler = function(mainContainer, object, eventData)
|
||||
if eventData[1] == "touch" then
|
||||
hideSettingsContainer()
|
||||
|
||||
@ -8,6 +8,7 @@ local fs = require("filesystem")
|
||||
local advancedLua = require("advancedLua")
|
||||
local color = require("color")
|
||||
local image = require("image")
|
||||
local MineOSCore = require("MineOSCore")
|
||||
local buffer = require("doubleBuffering")
|
||||
local GUI = require("GUI")
|
||||
|
||||
@ -16,7 +17,7 @@ local GUI = require("GUI")
|
||||
if not component.isAvailable("printer3d") then GUI.error("This program requires at least one 3D-printer"); return end
|
||||
local args, options = require("shell").parse(...)
|
||||
local startImagePath = args[1] == "open" and args[2] or "/MineOS/System/Icons/Steve.pic"
|
||||
local configPath = "/MineOS/System/PrintImage/Config.cfg"
|
||||
local configPath = MineOSCore.paths.system .. "PrintImage/Config.cfg"
|
||||
local panelWidth = 34
|
||||
local mainContainer
|
||||
local mainImage
|
||||
@ -189,27 +190,22 @@ local function createWindow()
|
||||
local textBoxesWidth = math.floor(panelWidth * 0.55)
|
||||
|
||||
mainContainer.shadeContainer = mainContainer:addChild(GUI.container(mainContainer.width - panelWidth + 1, 1, panelWidth, mainContainer.height))
|
||||
mainContainer.shadeContainer:addChild(GUI.panel(1, 1, mainContainer.shadeContainer.width, mainContainer.shadeContainer.height, 0x0000000, 40))
|
||||
mainContainer.shadeContainer:addChild(GUI.panel(1, 1, mainContainer.shadeContainer.width, mainContainer.shadeContainer.height, 0x0000000, 0.4))
|
||||
|
||||
local y = 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(1, y, mainContainer.shadeContainer.width, 1, 0xFFFFFF, "Main properties")):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Image path:"))
|
||||
mainContainer.shadeContainer:addChild(GUI.inputField(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, startImagePath, nil, true)).validator = function(text)
|
||||
if text and fs.exists(text) then
|
||||
if unicode.sub(text, -4, -1) == ".pic" then
|
||||
mainImage = image.load(text)
|
||||
getStatus()
|
||||
return true
|
||||
else
|
||||
GUI.error("File \"" .. text .. "\" is not in .pic format")
|
||||
end
|
||||
else
|
||||
GUI.error("File \"" .. text .. "\" doesn't exists")
|
||||
end
|
||||
local filesystemChooser = mainContainer.shadeContainer:addChild(GUI.filesystemChooser(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x262626, 0x444444, 0x999999, startImagePath, MineOSCore.localization.open, MineOSCore.localization.cancel, "Image path", "/"))
|
||||
filesystemChooser:addExtensionFilter(".pic")
|
||||
filesystemChooser.onSubmit = function(path)
|
||||
mainImage = image.load(path)
|
||||
getStatus()
|
||||
mainContainer:draw()
|
||||
buffer.draw()
|
||||
end
|
||||
|
||||
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Material:"))
|
||||
local mainMaterialTextBox = mainContainer.shadeContainer:addChild(GUI.inputField(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.mainMaterial, nil, false))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
package.loaded.rayEngine, package.loaded.GUI, _G.rayEngine, _G.GUI = nil, nil, nil, nil, nil, nil
|
||||
package.loaded.rayEngine = nil
|
||||
|
||||
local fs = require("filesystem")
|
||||
local component = require("component")
|
||||
@ -21,7 +21,7 @@ local rayWalkVersion = "RayWalk Tech Demo v3.5"
|
||||
|
||||
local function menuBackground()
|
||||
rayEngine.drawWorld()
|
||||
buffer.clear(0x000000, 50)
|
||||
buffer.clear(0x000000, 0.5)
|
||||
end
|
||||
|
||||
local function settings()
|
||||
|
||||
@ -181,7 +181,7 @@ local function drawWeather()
|
||||
--Рисуем обоинку или просто говнофон ССАНЫЙ
|
||||
if fs.exists(MineOSCore.OSSettings.wallpaper or "---aefaefaefaefae") then
|
||||
buffer.image(1, 1, image.load(MineOSCore.OSSettings.wallpaper))
|
||||
buffer.square(1, 1, buffer.width, buffer.height, 0x0, 0x0, " ", 60)
|
||||
buffer.square(1, 1, buffer.width, buffer.height, 0x0, 0x0, " ", 0.6)
|
||||
else
|
||||
buffer.clear(0x262626)
|
||||
end
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
|
||||
-- package.loaded.web = nil
|
||||
-- package.loaded.GUI = nil
|
||||
|
||||
local fs = require("filesystem")
|
||||
local component = require("component")
|
||||
local computer = require("computer")
|
||||
@ -11,6 +8,8 @@ local serialization = require("serialization")
|
||||
local gpu = component.gpu
|
||||
local screen = component.screen
|
||||
|
||||
local args, options = shell.parse(...)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local reasons = {}
|
||||
@ -35,7 +34,7 @@ if computer.totalMemory() < 2097152 then
|
||||
table.insert(reasons, "Not enough RAM: MineOS requires at least 2MB (2x Tier 3.5 RAM modules) to work properly.")
|
||||
end
|
||||
|
||||
if #reasons > 0 then
|
||||
if #reasons > 0 and not options.skiphardwarecheck and not options.s then
|
||||
print(" ")
|
||||
for i = 1, #reasons do
|
||||
print(reasons[i])
|
||||
|
||||
@ -37,8 +37,8 @@ local MineOSCore = require("MineOSCore")
|
||||
|
||||
---------------------------------------------- Всякая константная залупа ------------------------------------------------------------------------
|
||||
|
||||
local menuTransparency = 20
|
||||
local dockTransparency = 50
|
||||
local menuTransparency = 0.2
|
||||
local dockTransparency = 0.5
|
||||
|
||||
local computerUptimeOnBoot = computer.uptime()
|
||||
local computerDateUptime = computerUptimeOnBoot
|
||||
@ -498,9 +498,9 @@ local function createOSWindow()
|
||||
buffer.square(xPos + 1, yPos, currentDockWidth - 2, 1, color, 0xFFFFFF, " ", MineOSCore.OSSettings.transparencyEnabled and currentDockTransparency)
|
||||
buffer.text(xPos + currentDockWidth - 1, yPos, color, "◣", MineOSCore.OSSettings.transparencyEnabled and currentDockTransparency)
|
||||
|
||||
currentDockTransparency, currentDockWidth, xPos, yPos = currentDockTransparency + 8, currentDockWidth - 2, xPos + 1, yPos - 1
|
||||
if currentDockTransparency > 100 then
|
||||
currentDockTransparency = 100
|
||||
currentDockTransparency, currentDockWidth, xPos, yPos = currentDockTransparency + 0.08, currentDockWidth - 2, xPos + 1, yPos - 1
|
||||
if currentDockTransparency > 1 then
|
||||
currentDockTransparency = 1
|
||||
end
|
||||
end
|
||||
|
||||
@ -586,9 +586,9 @@ local function createOSWindow()
|
||||
menu:addItem(MineOSCore.localization.wallpaper).onTouch = function()
|
||||
local container = MineOSCore.addUniversalContainer(MineOSCore.OSMainContainer, MineOSCore.localization.wallpaper)
|
||||
|
||||
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x444444, 0x999999, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.wallpaperPath, GUI.filesystemModes.file, "/", MineOSCore.OSSettings.wallpaper))
|
||||
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x444444, 0x999999, MineOSCore.OSSettings.wallpaper, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.wallpaperPath, "/"))
|
||||
filesystemChooser:addExtensionFilter(".pic")
|
||||
filesystemChooser.onItemSelected = function(path)
|
||||
filesystemChooser.onSubmit = function(path)
|
||||
MineOSCore.OSSettings.wallpaper = path
|
||||
MineOSCore.saveOSSettings()
|
||||
changeWallpaper()
|
||||
|
||||
71
lib/GUI.lua
71
lib/GUI.lua
@ -68,8 +68,8 @@ GUI.colors = {
|
||||
text = 0xFFFFFF
|
||||
},
|
||||
transparency = {
|
||||
background = 30,
|
||||
shadow = 40
|
||||
background = 0.3,
|
||||
shadow = 0.4
|
||||
}
|
||||
},
|
||||
windows = {
|
||||
@ -87,8 +87,8 @@ GUI.colors = {
|
||||
background = 0xCCCCCC,
|
||||
text = 0x3C3C3C
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
----------------------------------------- Interface objects -----------------------------------------
|
||||
@ -97,12 +97,13 @@ local function callMethod(method, ...)
|
||||
if method then method(...) end
|
||||
end
|
||||
|
||||
function GUI.point(x, y)
|
||||
return { x = x, y = y }
|
||||
end
|
||||
|
||||
function GUI.rectangle(x, y, width, height)
|
||||
return { x = x, y = y, width = width, height = height}
|
||||
return {
|
||||
x = x,
|
||||
y = y,
|
||||
width = width,
|
||||
height = height
|
||||
}
|
||||
end
|
||||
|
||||
local function isObjectClicked(object, x, y)
|
||||
@ -134,6 +135,7 @@ function GUI.setAlignment(object, horizontalAlignment, verticalAlignment)
|
||||
horizontal = horizontalAlignment,
|
||||
vertical = verticalAlignment
|
||||
}
|
||||
|
||||
return object
|
||||
end
|
||||
|
||||
@ -701,7 +703,10 @@ end
|
||||
function GUI.panel(x, y, width, height, color, transparency)
|
||||
local object = GUI.object(x, y, width, height)
|
||||
|
||||
object.colors = {background = color, transparency = transparency}
|
||||
object.colors = {
|
||||
background = color,
|
||||
transparency = transparency
|
||||
}
|
||||
object.draw = drawPanel
|
||||
|
||||
return object
|
||||
@ -808,8 +813,8 @@ local function drawProgressBar(object)
|
||||
buffer.text(object.x, object.y, object.colors.passive, string.rep("━", object.width))
|
||||
buffer.text(object.x, object.y, object.colors.active, string.rep("━", activeWidth))
|
||||
else
|
||||
buffer.square(object.x, object.y, object.width, object.height, object.colors.passive)
|
||||
buffer.square(object.x, object.y, activeWidth, object.height, object.colors.active)
|
||||
buffer.square(object.x, object.y, object.width, object.height, object.colors.passive, 0x0, " ")
|
||||
buffer.square(object.x, object.y, activeWidth, object.height, object.colors.active, 0x0, " ")
|
||||
end
|
||||
|
||||
if object.showValue then
|
||||
@ -1033,7 +1038,7 @@ local function codeViewDraw(codeView)
|
||||
if codeView.lines[line] then
|
||||
local text = tostring(line)
|
||||
if codeView.highlights[line] then
|
||||
buffer.square(codeView.x, y, codeView.lineNumbersWidth, 1, codeView.highlights[line], require("syntax").colorScheme.text, " ", 30)
|
||||
buffer.square(codeView.x, y, codeView.lineNumbersWidth, 1, codeView.highlights[line], require("syntax").colorScheme.text, " ", 0.3)
|
||||
buffer.square(codeView.codeAreaPosition, y, codeView.codeAreaWidth, 1, codeView.highlights[line], require("syntax").colorScheme.text, " ")
|
||||
end
|
||||
buffer.text(codeView.codeAreaPosition - unicode.len(text) - 1, y, require("syntax").colorScheme.lineNumbersText, text)
|
||||
@ -1086,6 +1091,7 @@ local function codeViewDraw(codeView)
|
||||
for i = 1, dy - 1 do
|
||||
buffer.square(codeView.codeAreaPosition, y + codeView.selections[selectionIndex].from.line - codeView.fromLine, codeView.codeAreaWidth, 1, codeView.selections[selectionIndex].color or require("syntax").colorScheme.selection, require("syntax").colorScheme.text, " "); y = y + 1
|
||||
end
|
||||
|
||||
drawLowerSelection(y, selectionIndex)
|
||||
end
|
||||
end
|
||||
@ -1161,10 +1167,10 @@ local function colorSelectorDraw(colorSelector)
|
||||
local overlayColor = colorSelector.color < 0x7FFFFF and 0xFFFFFF or 0x000000
|
||||
buffer.square(colorSelector.x, colorSelector.y, colorSelector.width, colorSelector.height, colorSelector.color, overlayColor, " ")
|
||||
if colorSelector.pressed then
|
||||
buffer.square(colorSelector.x, colorSelector.y, colorSelector.width, colorSelector.height, overlayColor, overlayColor, " ", 80)
|
||||
buffer.square(colorSelector.x, colorSelector.y, colorSelector.width, colorSelector.height, overlayColor, overlayColor, " ", 0.8)
|
||||
end
|
||||
if colorSelector.height > 1 then
|
||||
buffer.text(colorSelector.x, colorSelector.y + colorSelector.height - 1, overlayColor, string.rep("▄", colorSelector.width), 80)
|
||||
buffer.text(colorSelector.x, colorSelector.y + colorSelector.height - 1, overlayColor, string.rep("▄", colorSelector.width), 0.8)
|
||||
end
|
||||
buffer.text(colorSelector.x + 1, colorSelector.y + math.floor(colorSelector.height / 2), overlayColor, string.limit(colorSelector.text, colorSelector.width - 2))
|
||||
return colorSelector
|
||||
@ -1889,7 +1895,7 @@ end
|
||||
----------------------------------------- Combo Box Object -----------------------------------------
|
||||
|
||||
local function drawComboBox(object)
|
||||
buffer.square(object.x, object.y, object.width, object.height, object.colors.default.background)
|
||||
buffer.square(object.x, object.y, object.width, object.height, object.colors.default.background, object.colors.default.text, " ")
|
||||
local x, y, limit, arrowSize = object.x + 1, math.floor(object.y + object.height / 2), object.width - 3, object.height
|
||||
if object.dropDownMenu.itemsContainer.children[object.selectedItem] then
|
||||
buffer.text(x, y, object.colors.default.text, string.limit(object.dropDownMenu.itemsContainer.children[object.selectedItem].text, limit, "right"))
|
||||
@ -1967,7 +1973,16 @@ 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.colors.default.background, object.colors.default.text, object.colors.pressed.background, object.colors.pressed.text, GUI.colors.contextMenu.disabled, GUI.colors.contextMenu.separator, GUI.colors.contextMenu.transparency.background, GUI.colors.contextMenu.transparency.shadow)
|
||||
object.dropDownMenu = GUI.dropDownMenu(1, 1, 1, math.ceil(buffer.height * 0.5), elementHeight,
|
||||
object.colors.default.background,
|
||||
object.colors.default.text,
|
||||
object.colors.pressed.background,
|
||||
object.colors.pressed.text,
|
||||
GUI.colors.contextMenu.disabled,
|
||||
GUI.colors.contextMenu.separator,
|
||||
GUI.colors.contextMenu.transparency.background,
|
||||
GUI.colors.contextMenu.transparency.shadow
|
||||
)
|
||||
object.selectedItem = 1
|
||||
object.addItem = comboBoxAddItem
|
||||
object.addSeparator = comboBoxAddSeparator
|
||||
@ -2725,7 +2740,7 @@ local function treeViewDraw(treeView)
|
||||
local textLimit = treeView.width - (showScrollBar and 2 or 1)
|
||||
|
||||
if treeView.colors.default.background then
|
||||
buffer.square(treeView.x, treeView.y, treeView.width, treeView.height, treeView.colors.default.background, treeView.colors.default.text, " ")
|
||||
buffer.square(treeView.x, treeView.y, treeView.width, treeView.height, treeView.colors.default.background, treeView.colors.default.directory, " ")
|
||||
end
|
||||
|
||||
for fileIndex = treeView.fromFile, #treeView.fileList do
|
||||
@ -3028,10 +3043,13 @@ local function filesystemChooserDraw(object)
|
||||
end
|
||||
|
||||
local function filesystemChooserAddExtensionFilter(object, extension)
|
||||
object.extensionFilters = object.extensionFilters or {}
|
||||
object.extensionFilters[unicode.lower(extension)] = true
|
||||
end
|
||||
|
||||
local function filesystemChooserSetMode(object, filesystemMode)
|
||||
object.filesystemMode = filesystemMode
|
||||
end
|
||||
|
||||
local function filesystemChooserEventHandler(mainContainer, object, eventData)
|
||||
if eventData[1] == "touch" then
|
||||
object.pressed = true
|
||||
@ -3058,14 +3076,14 @@ local function filesystemChooserEventHandler(mainContainer, object, eventData)
|
||||
|
||||
mainContainer:draw()
|
||||
buffer.draw()
|
||||
callMethod(object.onItemSelected, object.path)
|
||||
callMethod(object.onSubmit, object.path)
|
||||
end
|
||||
|
||||
filesystemDialog:show()
|
||||
end
|
||||
end
|
||||
|
||||
function GUI.filesystemChooser(x, y, width, height, backgroundColor, textColor, tipBackgroundColor, tipTextColor, path, submitButtonText, cancelButtonText, placeholderText, filesystemMode, filesystemDialogPath)
|
||||
function GUI.filesystemChooser(x, y, width, height, backgroundColor, textColor, tipBackgroundColor, tipTextColor, path, submitButtonText, cancelButtonText, placeholderText, filesystemDialogPath)
|
||||
local object = GUI.object(x, y, width, height)
|
||||
|
||||
object.eventHandler = comboBoxEventHandler
|
||||
@ -3082,10 +3100,13 @@ function GUI.filesystemChooser(x, y, width, height, backgroundColor, textColor,
|
||||
object.pressed = false
|
||||
object.path = path
|
||||
object.filesystemDialogPath = filesystemDialogPath
|
||||
object.filesystemMode = GUI.filesystemModes.file
|
||||
object.extensionFilters = {}
|
||||
|
||||
object.draw = filesystemChooserDraw
|
||||
object.eventHandler = filesystemChooserEventHandler
|
||||
object.filesystemMode = filesystemMode
|
||||
object.addExtensionFilter = filesystemChooserAddExtensionFilter
|
||||
object.setMode = filesystemChooserSetMode
|
||||
|
||||
return object
|
||||
end
|
||||
@ -3098,7 +3119,7 @@ end
|
||||
-- local mainContainer = GUI.fullScreenContainer()
|
||||
-- mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x262626))
|
||||
|
||||
-- local dialog = GUI.showFilesystemDialog(mainContainer, "Save", "Cancel", "File name", "/")
|
||||
-- local dialog = GUI.addFilesystemDialogToContainer(mainContainer, "Save", "Cancel", "File name", "/")
|
||||
|
||||
-- dialog:setMode(GUI.filesystemModes.open, GUI.filesystemModes.file)
|
||||
-- dialog:addExtensionFilter(".pic")
|
||||
@ -3108,9 +3129,9 @@ end
|
||||
-- GUI.error(path)
|
||||
-- end
|
||||
|
||||
-- local filesystemChooser = mainContainer:addChild(GUI.filesystemChooser(2, 2, 30, 3, 0xE1E1E1, 0x888888, 0x3C3C3C, 0x888888, nil, "Open", "Cancel", "Choose file", GUI.filesystemModes.file, "/"))
|
||||
-- local filesystemChooser = mainContainer:addChild(GUI.filesystemChooser(2, 2, 30, 3, 0xE1E1E1, 0x888888, 0x3C3C3C, 0x888888, nil, "Open", "Cancel", "Choose file", "/"))
|
||||
-- filesystemChooser:addExtensionFilter(".cfg")
|
||||
-- filesystemChooser.onItemSelected = function(path)
|
||||
-- filesystemChooser.onSubmit = function(path)
|
||||
-- GUI.error("File \"" .. path .. "\" was selected")
|
||||
-- end
|
||||
|
||||
|
||||
@ -490,7 +490,7 @@ function meowEngine.intro(vector3Position, size)
|
||||
scene:addObject(meowEngine.newFloatingText(vector.newVector3(vector3Position[1] + 2, vector3Position[2] - size, vector3Position[3] + size * 0.1), 0xBBBBBB, "Powered by MeowEngine™"))
|
||||
|
||||
local from, to, speed = -30, 20, 4
|
||||
local transparency, transparencyStep = 0, 100 / math.abs(to - from) * speed
|
||||
local transparency, transparencyStep = 0, 1 / math.abs(to - from) * speed
|
||||
|
||||
scene.camera:setPosition(from, 0, -32)
|
||||
while scene.camera.position[1] < to do
|
||||
@ -507,7 +507,7 @@ function meowEngine.intro(vector3Position, size)
|
||||
|
||||
os.sleep(2)
|
||||
|
||||
for i = 100, 0, -20 do
|
||||
for i = 1, 0, -0.2 do
|
||||
scene:render()
|
||||
buffer.clear(0x0, i)
|
||||
buffer.draw()
|
||||
|
||||
@ -328,7 +328,7 @@ function MineOSCore.icon(x, y, path, textColor, selectionColor, showExtension)
|
||||
icon.colors = {
|
||||
text = textColor,
|
||||
selection = selectionColor,
|
||||
selectionTransparency = 60
|
||||
selectionTransparency = 0.6
|
||||
}
|
||||
icon.path = path
|
||||
icon.isDirectory = fs.isDirectory(icon.path)
|
||||
@ -393,6 +393,11 @@ local function iconFieldSaveIconConfig(iconField)
|
||||
table.toFile(iconField.workpath .. MineOSCore.iconConfigFileName, iconField.iconConfig)
|
||||
end
|
||||
|
||||
local function iconFieldDeleteIconConfig(iconField)
|
||||
iconField.iconConfig = {}
|
||||
fs.remove(iconField.workpath .. MineOSCore.iconConfigFileName, iconField.iconConfig)
|
||||
end
|
||||
|
||||
local function iconFieldUpdateFileList(iconField)
|
||||
-- Обновление файлового списка
|
||||
iconField.fileList = fs.sortedList(iconField.workpath, iconField.sortingMethod, iconField.showHiddenFiles)
|
||||
@ -405,6 +410,7 @@ local function iconFieldUpdateFileList(iconField)
|
||||
local xPos, yPos, horizontalIconCounter = 1, 1, 1
|
||||
for i = iconField.fromFile, iconField.fromFile + iconField.iconCount.total - 1 do
|
||||
if iconField.fileList[i] then
|
||||
-- Выставление позиций иконок на основании конфига
|
||||
local xIcon, yIcon = xPos, yPos
|
||||
if iconField.iconConfig[iconField.fileList[i]] then
|
||||
xIcon, yIcon = iconField.iconConfig[iconField.fileList[i]].x, iconField.iconConfig[iconField.fileList[i]].y
|
||||
@ -483,20 +489,20 @@ local function iconFieldBackgroundObjectEventHandler(mainContainer, object, even
|
||||
end
|
||||
|
||||
local subMenu = menu:addSubMenu(MineOSCore.localization.sortBy)
|
||||
|
||||
subMenu:addItem(MineOSCore.localization.sortByName).onTouch = function()
|
||||
object.parent:deleteIconConfig()
|
||||
|
||||
MineOSCore.OSSettings.sortingMethod = "name"
|
||||
MineOSCore.saveOSSettings()
|
||||
MineOSCore.OSMainContainer.iconField.sortingMethod = MineOSCore.OSSettings.sortingMethod
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
menu:addItem(MineOSCore.localization.sortAutomatically).onTouch = function()
|
||||
object.parent.iconConfig = {}
|
||||
object.parent:saveIconConfig()
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
|
||||
subMenu:addItem(MineOSCore.localization.sortByDate).onTouch = function()
|
||||
object.parent:deleteIconConfig()
|
||||
|
||||
MineOSCore.OSSettings.sortingMethod = "date"
|
||||
MineOSCore.saveOSSettings()
|
||||
MineOSCore.OSMainContainer.iconField.sortingMethod = MineOSCore.OSSettings.sortingMethod
|
||||
@ -504,12 +510,19 @@ local function iconFieldBackgroundObjectEventHandler(mainContainer, object, even
|
||||
end
|
||||
|
||||
subMenu:addItem(MineOSCore.localization.sortByType).onTouch = function()
|
||||
object.parent:deleteIconConfig()
|
||||
|
||||
MineOSCore.OSSettings.sortingMethod = "type"
|
||||
MineOSCore.saveOSSettings()
|
||||
MineOSCore.OSMainContainer.iconField.sortingMethod = MineOSCore.OSSettings.sortingMethod
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
menu:addItem(MineOSCore.localization.sortAutomatically).onTouch = function()
|
||||
object.parent:deleteIconConfig()
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
|
||||
menu:addItem(MineOSCore.localization.paste, not MineOSCore.clipboard).onTouch = function()
|
||||
@ -565,7 +578,7 @@ local function iconFieldForegroundObjectDraw(object)
|
||||
y1, y2 = y2, y1
|
||||
end
|
||||
|
||||
buffer.square(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 0xFFFFFF, 0x0, " ", 60)
|
||||
buffer.square(x1, y1, x2 - x1 + 1, y2 - y1 + 1, 0xFFFFFF, 0x0, " ", 0.6)
|
||||
|
||||
local partialWidth, partialHeight = MineOSCore.iconWidth * MineOSCore.selectionIconPart, MineOSCore.iconHeight * MineOSCore.selectionIconPart
|
||||
for i = 1, #object.parent.iconsContainer.children do
|
||||
@ -635,6 +648,7 @@ function MineOSCore.iconField(x, y, width, height, xSpaceBetweenIcons, ySpaceBet
|
||||
iconField.deselectAll = iconFieldDeselectAll
|
||||
iconField.loadIconConfig = iconFieldLoadIconConfig
|
||||
iconField.saveIconConfig = iconFieldSaveIconConfig
|
||||
iconField.deleteIconConfig = iconFieldDeleteIconConfig
|
||||
iconField.getSelectedIcons = iconFieldGetSelectedIcons
|
||||
|
||||
return iconField
|
||||
@ -669,7 +683,7 @@ function MineOSCore.parseErrorMessage(error, indentationWidth)
|
||||
end
|
||||
|
||||
function MineOSCore.showErrorWindow(path, errorLine, reason)
|
||||
buffer.clear(0x0, 50)
|
||||
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)
|
||||
@ -926,7 +940,7 @@ function MineOSCore.iconRightClick(icon, eventData)
|
||||
for i = 1, #selectedIcons do
|
||||
if not selectedIcons[i].isShortcut then
|
||||
MineOSCore.createShortcut(
|
||||
fs.path(MineOSCore.paths.desktop) .. "/" .. fs.hideExtension(fs.name(selectedIcons[i].path)) .. ".lnk",
|
||||
MineOSCore.paths.desktop .. "/" .. fs.hideExtension(fs.name(selectedIcons[i].path)) .. ".lnk",
|
||||
selectedIcons[i].path
|
||||
)
|
||||
end
|
||||
@ -986,7 +1000,7 @@ end
|
||||
function MineOSCore.addUniversalContainer(parentContainer, title)
|
||||
local container = parentContainer:addChild(GUI.container(1, 1, parentContainer.width, parentContainer.height))
|
||||
|
||||
container.panel = container:addChild(GUI.panel(1, 1, container.width, container.height, MineOSCore.OSSettings.transparencyEnabled and 0x0 or (MineOSCore.OSSettings.backgroundColor or 0x0F0F0F), MineOSCore.OSSettings.transparencyEnabled and 20))
|
||||
container.panel = container:addChild(GUI.panel(1, 1, container.width, container.height, MineOSCore.OSSettings.transparencyEnabled and 0x0 or (MineOSCore.OSSettings.backgroundColor or 0x0F0F0F), MineOSCore.OSSettings.transparencyEnabled and 0.2))
|
||||
container.layout = container:addChild(GUI.layout(1, 1, container.width, container.height, 1, 1))
|
||||
|
||||
if title then
|
||||
@ -1327,7 +1341,7 @@ end
|
||||
function MineOSCore.propertiesWindow(x, y, width, icon)
|
||||
local mainContainer, window = MineOSCore.addWindow(GUI.titledWindow(x, y, width, 1, package.loaded.MineOSCore.localization.properties))
|
||||
|
||||
-- window.backgroundPanel.colors.transparency = 25
|
||||
-- window.backgroundPanel.colors.transparency = 0.25
|
||||
window:addChild(GUI.image(2, 3, icon.image))
|
||||
|
||||
local x, y = 11, 3
|
||||
|
||||
120
lib/color.lua
120
lib/color.lua
@ -5,7 +5,7 @@ local color = {}
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- Yoba-fix for PIDORS
|
||||
-- Optimized Lua 5.3 bitwise support
|
||||
if computer.getArchitecture and computer.getArchitecture() == "Lua 5.3" then
|
||||
color.RGBToHEX = load([[
|
||||
return function(r, g, b)
|
||||
@ -24,76 +24,55 @@ function color.HEXToRGB(HEXColor)
|
||||
return bit32.rshift(HEXColor, 16), bit32.band(bit32.rshift(HEXColor, 8), 0xFF), bit32.band(HEXColor, 0xFF)
|
||||
end
|
||||
|
||||
function color.RGBToHSB(rr, gg, bb)
|
||||
local max = math.max(rr, math.max(gg, bb))
|
||||
local min = math.min(rr, math.min(gg, bb))
|
||||
local delta = max - min
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local h = 0
|
||||
if ( max == rr and gg >= bb) then h = 60 * (gg - bb) / delta end
|
||||
if ( max == rr and gg <= bb ) then h = 60 * (gg - bb) / delta + 360 end
|
||||
if ( max == gg ) then h = 60 * (bb - rr) / delta + 120 end
|
||||
if ( max == bb ) then h = 60 * (rr - gg) / delta + 240 end
|
||||
function color.RGBToHSB(r, g, b)
|
||||
local max, min = math.max(r, g, b), math.min(r, g, b)
|
||||
|
||||
local s = 0
|
||||
if ( max ~= 0 ) then s = 1 - (min / max) end
|
||||
|
||||
local b = max * 100 / 255
|
||||
|
||||
if delta == 0 then h = 0 end
|
||||
|
||||
return h, s * 100, b
|
||||
if max == min then
|
||||
return 0, max == 0 and 0 or (1 - min / max) * 100, max / 255 * 100
|
||||
elseif max == r and g >= b then
|
||||
return 60 * (g - b) / (max - min), max == 0 and 0 or (1 - min / max) * 100, max / 255 * 100
|
||||
elseif max == r and g < b then
|
||||
return 60 * (g - b) / (max - min) + 360, max == 0 and 0 or (1 - min / max) * 100, max / 255 * 100
|
||||
elseif max == g then
|
||||
return 60 * (b - r) / (max - min) + 120, max == 0 and 0 or (1 - min / max) * 100, max / 255 * 100
|
||||
elseif max == b then
|
||||
return 60 * (r - g) / (max - min) + 240, max == 0 and 0 or (1 - min / max) * 100, max / 255 * 100
|
||||
else
|
||||
return 0, max == 0 and 0 or (1 - min / max) * 100, max / 255 * 100
|
||||
end
|
||||
end
|
||||
|
||||
function color.HSBToRGB(h, s, v)
|
||||
if h > 359 then h = 0 end
|
||||
local rr, gg, bb = 0, 0, 0
|
||||
local const = 255
|
||||
function color.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)
|
||||
|
||||
s = s / 100
|
||||
v = v / 100
|
||||
|
||||
local i = math.floor(h / 60)
|
||||
local f = h / 60 - i
|
||||
|
||||
local p = v * (1 - s)
|
||||
local q = v * (1 - s * f)
|
||||
local t = v * (1 - (1 - f) * s)
|
||||
|
||||
if ( i == 0 ) then rr, gg, bb = v, t, p end
|
||||
if ( i == 1 ) then rr, gg, bb = q, v, p end
|
||||
if ( i == 2 ) then rr, gg, bb = p, v, t end
|
||||
if ( i == 3 ) then rr, gg, bb = p, q, v end
|
||||
if ( i == 4 ) then rr, gg, bb = t, p, v end
|
||||
if ( i == 5 ) then rr, gg, bb = v, p, q end
|
||||
|
||||
return math.floor(rr * const), math.floor(gg * const), math.floor(bb * const)
|
||||
if integer == 0 then
|
||||
return math.floor(b * 255), math.floor(t * 255), math.floor(p * 255)
|
||||
elseif integer == 1 then
|
||||
return math.floor(q * 255), math.floor(b * 255), math.floor(p * 255)
|
||||
elseif integer == 2 then
|
||||
return math.floor(p * 255), math.floor(b * 255), math.floor(t * 255)
|
||||
elseif integer == 3 then
|
||||
return math.floor(p * 255), math.floor(q * 255), math.floor(b * 255)
|
||||
elseif integer == 4 then
|
||||
return math.floor(t * 255), math.floor(p * 255), math.floor(b * 255)
|
||||
else
|
||||
return math.floor(b * 255), math.floor(p * 255), math.floor(q * 255)
|
||||
end
|
||||
end
|
||||
|
||||
function color.HEXToHSB(HEXColor)
|
||||
local rr, gg, bb = color.HEXToRGB(HEXColor)
|
||||
local h, s, b = color.RGBToHSB( rr, gg, bb )
|
||||
|
||||
return h, s, b
|
||||
return color.RGBToHSB(color.HEXToRGB(HEXColor))
|
||||
end
|
||||
|
||||
function color.HSBToHEX(h, s, b)
|
||||
local rr, gg, bb = color.HSBToRGB(h, s, b)
|
||||
local color = color.RGBToHEX(rr, gg, bb)
|
||||
|
||||
return color
|
||||
return color.RGBToHEX(color.HSBToRGB(h, s, b))
|
||||
end
|
||||
|
||||
function color.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])
|
||||
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))
|
||||
end
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function color.blend(firstColor, secondColor, secondColorTransparency)
|
||||
local invertedTransparency, firstColorR, firstColorG, firstColorB = 1 - secondColorTransparency, color.HEXToRGB(firstColor)
|
||||
@ -106,6 +85,13 @@ function color.blend(firstColor, secondColor, secondColorTransparency)
|
||||
)
|
||||
end
|
||||
|
||||
function color.blendRGBA(c1, c2, a1, a2)
|
||||
local oneMinusA1, oneMinusA2 = 1 - a1, 1 - a2
|
||||
return
|
||||
color.blend(c1, c2, a2),
|
||||
1 - (oneMinusA1 + a1 * oneMinusA2)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function color.difference(r1, g1, b1, r2, g2, b2)
|
||||
@ -125,6 +111,17 @@ function color.multiply(r, g, b, multiplyer)
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
function color.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])
|
||||
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))
|
||||
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 }
|
||||
@ -156,13 +153,6 @@ function color.optimize(color24Bit)
|
||||
return color.to24Bit(color.to8Bit(color24Bit))
|
||||
end
|
||||
|
||||
function color.blendRGBA(c1, c2, a1, a2)
|
||||
local oneMinusA1, oneMinusA2 = 1 - a1, 1 - a2
|
||||
return
|
||||
color.blend(c1, c2, a2),
|
||||
1 - (oneMinusA1 + a1 * oneMinusA2)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- local c, a = color.blendRGBA(0x0000FF, 0xFF0000, 0.5, 0.5)
|
||||
|
||||
@ -106,38 +106,31 @@ function buffer.set(x, y, background, foreground, symbol)
|
||||
end
|
||||
|
||||
function buffer.square(x, y, width, height, background, foreground, symbol, transparency)
|
||||
if transparency then
|
||||
if transparency == 0 then
|
||||
transparency = nil
|
||||
else
|
||||
transparency = transparency / 100
|
||||
end
|
||||
end
|
||||
if not foreground then foreground = 0x000000 end
|
||||
if not symbol then symbol = " " end
|
||||
|
||||
local index, indexStepForward, indexPlus1 = buffer.getIndexByCoordinates(x, y), (buffer.width - width) * 3
|
||||
|
||||
for j = y, (y + height - 1) do
|
||||
for i = x, (x + width - 1) do
|
||||
if i >= buffer.drawLimit.x1 and j >= buffer.drawLimit.y1 and i <= buffer.drawLimit.x2 and j <= buffer.drawLimit.y2 then
|
||||
indexPlus1 = index + 1
|
||||
|
||||
if transparency then
|
||||
buffer.newFrame[index] = color.blend(buffer.newFrame[index], background, transparency)
|
||||
buffer.newFrame[indexPlus1] = color.blend(buffer.newFrame[indexPlus1], background, transparency)
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1] =
|
||||
color.blend(buffer.newFrame[index], background, transparency),
|
||||
color.blend(buffer.newFrame[indexPlus1], background, transparency)
|
||||
else
|
||||
buffer.newFrame[index] = background
|
||||
buffer.newFrame[indexPlus1] = foreground
|
||||
buffer.newFrame[index + 2] = symbol
|
||||
buffer.newFrame[index], buffer.newFrame[indexPlus1], buffer.newFrame[index + 2] = background, foreground, symbol
|
||||
end
|
||||
end
|
||||
|
||||
index = index + 3
|
||||
end
|
||||
|
||||
index = index + indexStepForward
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.clear(color, transparency)
|
||||
buffer.square(1, 1, buffer.width, buffer.height, color or 0x262626, 0x000000, " ", transparency)
|
||||
buffer.square(1, 1, buffer.width, buffer.height, color or 0x0, 0x000000, " ", transparency)
|
||||
end
|
||||
|
||||
function buffer.copy(x, y, width, height)
|
||||
@ -211,22 +204,20 @@ function buffer.line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
end
|
||||
|
||||
function buffer.text(x, y, textColor, text, transparency)
|
||||
if transparency then
|
||||
if transparency == 0 then
|
||||
transparency = nil
|
||||
else
|
||||
transparency = transparency / 100
|
||||
end
|
||||
end
|
||||
|
||||
local index, sText = buffer.getIndexByCoordinates(x, y), unicode.len(text)
|
||||
|
||||
for i = 1, sText do
|
||||
if x >= buffer.drawLimit.x1 and y >= buffer.drawLimit.y1 and x <= buffer.drawLimit.x2 and y <= buffer.drawLimit.y2 then
|
||||
buffer.newFrame[index + 1] = not transparency and textColor or color.blend(buffer.newFrame[index], textColor, transparency)
|
||||
if transparency then
|
||||
buffer.newFrame[index + 1] = color.blend(buffer.newFrame[index], textColor, transparency)
|
||||
else
|
||||
buffer.newFrame[index + 1] = textColor
|
||||
end
|
||||
|
||||
buffer.newFrame[index + 2] = unicode.sub(text, i, i)
|
||||
end
|
||||
index = index + 3
|
||||
x = x + 1
|
||||
|
||||
x, index = x + 1, index + 3
|
||||
end
|
||||
end
|
||||
|
||||
@ -239,10 +230,10 @@ function buffer.image(x, y, picture, blendForeground)
|
||||
if xPos >= buffer.drawLimit.x1 and y >= buffer.drawLimit.y1 and xPos <= buffer.drawLimit.x2 and y <= buffer.drawLimit.y2 then
|
||||
bufferIndexPlus1, imageIndexPlus1, imageIndexPlus2, imageIndexPlus3 = bufferIndex + 1, imageIndex + 1, imageIndex + 2, imageIndex + 3
|
||||
|
||||
if picture[imageIndexPlus2] == 0x00 then
|
||||
if picture[imageIndexPlus2] == 0 then
|
||||
buffer.newFrame[bufferIndex] = picture[imageIndex]
|
||||
buffer.newFrame[bufferIndex + 1] = picture[imageIndex + 1]
|
||||
elseif picture[imageIndexPlus2] > 0x00 and picture[imageIndexPlus2] < 0xFF then
|
||||
elseif picture[imageIndexPlus2] > 0 and picture[imageIndexPlus2] < 1 then
|
||||
buffer.newFrame[bufferIndex] = color.blend(buffer.newFrame[bufferIndex], picture[imageIndex], picture[imageIndexPlus2])
|
||||
|
||||
if blendForeground then
|
||||
@ -250,7 +241,7 @@ function buffer.image(x, y, picture, blendForeground)
|
||||
else
|
||||
buffer.newFrame[bufferIndex + 1] = picture[imageIndex + 1]
|
||||
end
|
||||
elseif picture[imageIndexPlus2] == 0xFF and picture[imageIndexPlus3] ~= " " then
|
||||
elseif picture[imageIndexPlus2] == 1 and picture[imageIndexPlus3] ~= " " then
|
||||
buffer.newFrame[bufferIndex + 1] = picture[imageIndex + 1]
|
||||
end
|
||||
|
||||
@ -272,74 +263,10 @@ function buffer.frame(x, y, width, height, color)
|
||||
buffer.text(x2, y, color, "│")
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
buffer.text(x, y, color, stringDown)
|
||||
end
|
||||
|
||||
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 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)
|
||||
|
||||
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 height = yOffset * 2 + 1
|
||||
|
||||
buffer.square(x, y, width, height, background, 0xFFFFFF, " ")
|
||||
buffer.text(x + xOffset, y + yOffset, foreground, text)
|
||||
|
||||
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)
|
||||
|
||||
x = math.floor(x + width / 2 - unicode.len(text) / 2)
|
||||
y = math.floor(y + height / 2)
|
||||
|
||||
buffer.text(x, y, buttonColor, text)
|
||||
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))
|
||||
|
||||
buffer.square(x, y, width, height, backColor, 0xFFFFFF, " ")
|
||||
buffer.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))
|
||||
|
||||
buffer.text(x, y, background, string.rep("▄", width))
|
||||
buffer.text(displayBarFrom, y, foreground, string.rep("▄", pipeSize))
|
||||
end
|
||||
|
||||
function buffer.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])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return (x + 1), (y + 1), (x + #pixels[1]), (y + #pixels)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function buffer.semiPixelRawSet(index, color, yPercentTwoEqualsZero)
|
||||
@ -496,6 +423,73 @@ end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
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 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)
|
||||
|
||||
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 height = yOffset * 2 + 1
|
||||
|
||||
buffer.square(x, y, width, height, background, 0xFFFFFF, " ")
|
||||
buffer.text(x + xOffset, y + yOffset, foreground, text)
|
||||
|
||||
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)
|
||||
|
||||
x = math.floor(x + width / 2 - unicode.len(text) / 2)
|
||||
y = math.floor(y + height / 2)
|
||||
|
||||
buffer.text(x, y, buttonColor, text)
|
||||
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))
|
||||
|
||||
buffer.square(x, y, width, height, backColor, 0xFFFFFF, " ")
|
||||
buffer.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))
|
||||
|
||||
buffer.text(x, y, background, string.rep("▄", width))
|
||||
buffer.text(displayBarFrom, y, foreground, string.rep("▄", pipeSize))
|
||||
end
|
||||
|
||||
function buffer.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])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return (x + 1), (y + 1), (x + #pixels[1]), (y + #pixels)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function info(...)
|
||||
local args = {...}
|
||||
local text = {}
|
||||
|
||||
@ -196,7 +196,7 @@ function image.toString(picture)
|
||||
for i = 3, #picture, 4 do
|
||||
table.insert(charArray, string.format("%02X", color.to8Bit(picture[i])))
|
||||
table.insert(charArray, string.format("%02X", color.to8Bit(picture[i + 1])))
|
||||
table.insert(charArray, string.format("%02X", picture[i + 2]))
|
||||
table.insert(charArray, string.format("%02X", math.floor(picture[i + 2] * 255)))
|
||||
table.insert(charArray, picture[i + 3])
|
||||
|
||||
image.iterationYield(i)
|
||||
@ -214,7 +214,7 @@ function image.fromString(pictureString)
|
||||
for i = 5, unicode.len(pictureString), 7 do
|
||||
table.insert(picture, color.to24Bit(tonumber("0x" .. unicode.sub(pictureString, i, i + 1))))
|
||||
table.insert(picture, color.to24Bit(tonumber("0x" .. unicode.sub(pictureString, i + 2, i + 3))))
|
||||
table.insert(picture, tonumber("0x" .. unicode.sub(pictureString, i + 4, i + 5)))
|
||||
table.insert(picture, tonumber("0x" .. unicode.sub(pictureString, i + 4, i + 5)) / 255)
|
||||
table.insert(picture, unicode.sub(pictureString, i + 6, i + 6))
|
||||
end
|
||||
|
||||
@ -335,8 +335,8 @@ function image.blend(picture, blendColor, transparency)
|
||||
local newPicture = {picture[1], picture[2]}
|
||||
|
||||
for i = 3, #picture, 4 do
|
||||
table.insert(newPicture, color.blend(picture[i], blendColor, transparency / 100))
|
||||
table.insert(newPicture, color.blend(picture[i + 1], blendColor, transparency / 100))
|
||||
table.insert(newPicture, color.blend(picture[i], blendColor, transparency))
|
||||
table.insert(newPicture, color.blend(picture[i + 1], blendColor, transparency))
|
||||
table.insert(newPicture, picture[i + 2])
|
||||
table.insert(newPicture, picture[i + 3])
|
||||
end
|
||||
|
||||
@ -4,6 +4,7 @@ local computer = require("computer")
|
||||
local advancedLua = require("advancedLua")
|
||||
local color = require("color")
|
||||
local image = require("image")
|
||||
local unicode = require("unicode")
|
||||
local buffer = require("doubleBuffering")
|
||||
local GUI = require("GUI")
|
||||
local event = require("event")
|
||||
@ -84,7 +85,7 @@ end
|
||||
local function getTileColor(basecolor, distance)
|
||||
local limitedDistance = math.floor(distance * rayEngine.properties.shadingCascades / rayEngine.properties.shadingDistance)
|
||||
local transparency = rayEngine.currentShadingTransparencyMapValue - limitedDistance / rayEngine.properties.shadingCascades
|
||||
transparency = (transparency >= rayEngine.properties.shadingTransparencyMap[1] and transparency <= 1) and transparency or rayEngine.properties.shadingTransparencyMap[1]
|
||||
transparency = (transparency >= rayEngine.properties.shadingTransparencyMap[1] and transparency <= 1) and transparency or rayEngine.properties.shadingTransparencyMap[1]
|
||||
return color.blend(basecolor, 0x000000, transparency)
|
||||
end
|
||||
|
||||
@ -347,8 +348,8 @@ end
|
||||
|
||||
function rayEngine.chat(transparency)
|
||||
local x, y = 1, buffer.height - rayEngine.chatPanelHeight - 3
|
||||
buffer.square(x, y, rayEngine.chatPanelWidth, rayEngine.chatPanelHeight, 0x000000, 0xFFFFFF, " ", transparency or 50)
|
||||
buffer.setDrawLimit(x, y, rayEngine.chatPanelWidth, rayEngine.chatPanelHeight)
|
||||
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
|
||||
x = x + 1
|
||||
|
||||
@ -374,8 +375,9 @@ function rayEngine.commandLine(transparency)
|
||||
buffer.square(x, y, buffer.width, inputPanelHeight, 0x000000, 0xFFFFFF, " ", transparency)
|
||||
|
||||
--Ввод данных
|
||||
local text = GUI.input(x + 2, y + 1, buffer.width - 4, 0xFFFFFF, "")
|
||||
local words = {}; for word in string.gmatch(text, "[^%s]+") do table.insert(words, unicode.lower(word)) end
|
||||
local input = GUI.input(x + 2, y + 1, buffer.width - 4, 0xFFFFFF, "")
|
||||
input:startInput()
|
||||
local words = {}; for word in string.gmatch(input.text, "[^%s]+") do table.insert(words, unicode.lower(word)) end
|
||||
if #words > 0 then
|
||||
if unicode.sub(words[1], 1, 1) == "/" then
|
||||
words[1] = unicode.sub(words[1], 2, -1)
|
||||
@ -421,7 +423,7 @@ function rayEngine.commandLine(transparency)
|
||||
addItemToChatHistory("Неизвестная команда. Введите /help для получения списка команд", 0xFF8888)
|
||||
end
|
||||
else
|
||||
addItemToChatHistory("> " .. text, 0xFFFFFF)
|
||||
addItemToChatHistory("> " .. input.text, 0xFFFFFF)
|
||||
end
|
||||
end
|
||||
|
||||
@ -459,7 +461,7 @@ function rayEngine.drawStats()
|
||||
local width = math.floor(buffer.width * 0.3)
|
||||
local height = 5
|
||||
local x, y = buffer.width - width - 1, 2
|
||||
buffer.square(x, y, width, height, 0x000000, 0xFFFFFF, " ", 50)
|
||||
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)
|
||||
end
|
||||
@ -489,7 +491,7 @@ function rayEngine.drawWorld()
|
||||
--Земля
|
||||
buffer.clear(rayEngine.world.colors.groundByTime)
|
||||
--Небо
|
||||
buffer.square(1, 1, buffer.width, rayEngine.horizonPosition, rayEngine.world.colors.sky.current)
|
||||
buffer.square(1, 1, buffer.width, 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
|
||||
@ -526,7 +528,7 @@ function rayEngine.update()
|
||||
|
||||
rayEngine.drawWorld()
|
||||
if rayEngine.currentWeapon then rayEngine.drawWeapon() end
|
||||
if rayEngine.minimapEnabled then rayEngine.drawMap(3, 2, 24, 24, 50) end
|
||||
if rayEngine.minimapEnabled then rayEngine.drawMap(3, 2, 24, 24, 0.5) end
|
||||
-- rayEngine.drawStats()
|
||||
local xTools, yTools = 3, buffer.height - 25
|
||||
if rayEngine.compassEnabled then rayEngine.compass(xTools, yTools); xTools = xTools + 30 end
|
||||
@ -535,7 +537,7 @@ function rayEngine.update()
|
||||
doDayNightCycle()
|
||||
|
||||
if rayEngine.debugInformationEnabled then
|
||||
rayEngine.drawDebugInformation(3, 2 + (rayEngine.minimapEnabled and 12 or 0), 24, 60,
|
||||
rayEngine.drawDebugInformation(3, 2 + (rayEngine.minimapEnabled and 12 or 0), 24, 0.6,
|
||||
"renderTime: " .. math.doubleToString((os.clock() - frameRenderClock) * 1000, 2) .. " ms",
|
||||
"freeRAM: " .. math.doubleToString(computer.freeMemory() / 1024, 2) .. " KB",
|
||||
"pos: " .. math.doubleToString(rayEngine.player.position.x) .. " x " .. math.doubleToString(rayEngine.player.position.y)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user