mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Wallpapers rework is finished
This commit is contained in:
parent
51b5ebb6c2
commit
96d2748ace
@ -17,9 +17,10 @@ local function configure()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add new controls if needed
|
-- Add new controls if needed
|
||||||
if system.wallpaper and system.wallpaper.configure then
|
local wallpaper = system.getWallpaper()
|
||||||
|
if wallpaper.configure then
|
||||||
configureFrom = #window.contentLayout.children + 1
|
configureFrom = #window.contentLayout.children + 1
|
||||||
system.wallpaper.configure(window.contentLayout)
|
wallpaper.configure(window.contentLayout)
|
||||||
configureTo = #window.contentLayout.children
|
configureTo = #window.contentLayout.children
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,9 +35,7 @@ local dockContainer
|
|||||||
local desktopMenu
|
local desktopMenu
|
||||||
local desktopMenuLayout
|
local desktopMenuLayout
|
||||||
local desktopIconField
|
local desktopIconField
|
||||||
local desktopBackground
|
local wallpaper
|
||||||
local desktopBackgroundWallpaperX
|
|
||||||
local desktopBackgroundWallpaperY
|
|
||||||
|
|
||||||
-- Caching commonly used icons
|
-- Caching commonly used icons
|
||||||
local iconCache = {
|
local iconCache = {
|
||||||
@ -485,7 +483,7 @@ function system.addSetAsWallpaperMenuItem(menu, path)
|
|||||||
system.updateWallpaper()
|
system.updateWallpaper()
|
||||||
end
|
end
|
||||||
|
|
||||||
system.wallpaper.setPicture(path)
|
wallpaper.setPicture(path)
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
system.saveUserSettings()
|
system.saveUserSettings()
|
||||||
@ -2414,43 +2412,45 @@ function system.execute(path, ...)
|
|||||||
return success, errorPath, line, traceback
|
return success, errorPath, line, traceback
|
||||||
end
|
end
|
||||||
|
|
||||||
local function desktopBackgroundAmbientDraw()
|
local function wallpaperDraw()
|
||||||
screen.drawRectangle(1, desktopBackground.y, desktopBackground.width, desktopBackground.height, 0x1E1E1E, 0, " ")
|
screen.drawRectangle(1, wallpaper.y, wallpaper.width, wallpaper.height, 0x1E1E1E, 0, " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
function system.getWallpaper()
|
||||||
|
return wallpaper
|
||||||
end
|
end
|
||||||
|
|
||||||
function system.updateWallpaper()
|
function system.updateWallpaper()
|
||||||
desktopBackground.draw = desktopBackgroundAmbientDraw
|
local function reset()
|
||||||
|
wallpaper.draw = wallpaperDraw
|
||||||
|
wallpaper.eventHandler = nil
|
||||||
|
wallpaper.configure = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function alert(...)
|
||||||
|
GUI.alert(...)
|
||||||
|
reset()
|
||||||
|
end
|
||||||
|
|
||||||
interfaceDrawInterval = 1
|
interfaceDrawInterval = 1
|
||||||
|
reset()
|
||||||
|
|
||||||
if not userSettings.interfaceWallpaperPath then
|
if not userSettings.interfaceWallpaperPath then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local executable, reason = loadfile(userSettings.interfaceWallpaperPath .. "Main.lua")
|
local result, reason = loadfile(userSettings.interfaceWallpaperPath .. "Main.lua")
|
||||||
if not executable then
|
if not result then
|
||||||
GUI.alert(reason)
|
alert(reason)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local success, wallpaperOrError = xpcall(executable, debug.traceback)
|
result, reason = xpcall(result, debug.traceback, workspace, wallpaper)
|
||||||
if not success then
|
if not result then
|
||||||
GUI.alert(wallpaperOrError)
|
alert()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(wallpaperOrError) ~= "table" then
|
|
||||||
GUI.alert("Wallpaper script didn't return table")
|
|
||||||
return
|
|
||||||
elseif type(wallpaperOrError.draw) ~= "function" then
|
|
||||||
GUI.alert("Wallpaper does not contain proper draw function")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
desktopBackground.draw = wallpaperOrError.draw
|
|
||||||
desktopBackground.eventHandler = wallpaperOrError.eventHandler
|
|
||||||
|
|
||||||
system.wallpaper = wallpaperOrError
|
|
||||||
|
|
||||||
interfaceDrawInterval = 0.01
|
interfaceDrawInterval = 0.01
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2475,7 +2475,7 @@ function system.updateResolution()
|
|||||||
|
|
||||||
desktopMenu.width = workspace.width
|
desktopMenu.width = workspace.width
|
||||||
desktopMenuLayout.width = workspace.width
|
desktopMenuLayout.width = workspace.width
|
||||||
desktopBackground.localY, desktopBackground.width, desktopBackground.height = 2, workspace.width, workspace.height - 1
|
wallpaper.localY, wallpaper.width, wallpaper.height = 2, workspace.width, workspace.height - 1
|
||||||
|
|
||||||
desktopWindowsContainer.width, desktopWindowsContainer.height = workspace.width, workspace.height - 1
|
desktopWindowsContainer.width, desktopWindowsContainer.height = workspace.width, workspace.height - 1
|
||||||
|
|
||||||
@ -2963,11 +2963,12 @@ function system.updateWorkspace()
|
|||||||
workspace.ignoresCapturedObject = true
|
workspace.ignoresCapturedObject = true
|
||||||
|
|
||||||
-- Creating desktop background object
|
-- Creating desktop background object
|
||||||
desktopBackground = workspace:addChild(GUI.object(1, 1, workspace.width, workspace.height))
|
wallpaper = workspace:addChild(GUI.object(1, 1, workspace.width, workspace.height))
|
||||||
desktopBackground.ignoresCapturedObject = true
|
-- wallpaper.ignoresCapturedObject = true
|
||||||
|
wallpaper.blockScreenEvents = false
|
||||||
|
|
||||||
local oldDraw = desktopBackground and desktopBackground.draw
|
local oldDraw = wallpaper and wallpaper.draw
|
||||||
desktopBackground.draw = oldDraw or desktopBackgroundAmbientDraw
|
wallpaper.draw = oldDraw or wallpaperDraw
|
||||||
end
|
end
|
||||||
|
|
||||||
function system.createUser(name, language, password, wallpaper)
|
function system.createUser(name, language, password, wallpaper)
|
||||||
@ -3038,7 +3039,7 @@ function system.authorize()
|
|||||||
local container = workspace:addChild(GUI.container(1, 1, workspace.width, workspace.height))
|
local container = workspace:addChild(GUI.container(1, 1, workspace.width, workspace.height))
|
||||||
|
|
||||||
-- If we've loaded wallpaper(from user logout or above) then add a panel to make it darker
|
-- If we've loaded wallpaper(from user logout or above) then add a panel to make it darker
|
||||||
if desktopBackground.draw ~= desktopBackgroundAmbientDraw then
|
if wallpaper.draw ~= wallpaperDraw then
|
||||||
container:addChild(GUI.panel(1, 1, container.width, container.height, 0x0, 0.5))
|
container:addChild(GUI.panel(1, 1, container.width, container.height, 0x0, 0.5))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,8 @@ local GUI = require("GUI")
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, wallpaper = select(1, ...), select(2, ...)
|
||||||
|
|
||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
@ -46,75 +48,71 @@ end
|
|||||||
|
|
||||||
reset(object)
|
reset(object)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
wallpaper.draw = function(object)
|
||||||
|
screen.drawRectangle(object.x, object.y, object.width, object.height, config.backgroundColor, 0, " ")
|
||||||
|
|
||||||
return {
|
local point1, point2
|
||||||
draw = function(object)
|
|
||||||
screen.drawRectangle(object.x, object.y, object.width, object.height, config.backgroundColor, 0, " ")
|
|
||||||
|
|
||||||
local point1, point2
|
for i = 1, config.lineCount - 1 do
|
||||||
|
point1, point2 = points[i], points[i + 1]
|
||||||
|
|
||||||
for i = 1, config.lineCount - 1 do
|
screen.drawSemiPixelLine(
|
||||||
point1, point2 = points[i], points[i + 1]
|
math.floor(object.x + point1.x),
|
||||||
|
math.floor(object.y * 2 - 1 + point1.y),
|
||||||
|
|
||||||
screen.drawSemiPixelLine(
|
math.floor(object.x + point2.x),
|
||||||
math.floor(object.x + point1.x),
|
math.floor(object.y * 2 - 1 + point2.y),
|
||||||
math.floor(object.y * 2 - 1 + point1.y),
|
|
||||||
|
config.lineColor
|
||||||
math.floor(object.x + point2.x),
|
|
||||||
math.floor(object.y * 2 - 1 + point2.y),
|
|
||||||
|
|
||||||
config.lineColor
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
local uptime = computer.uptime()
|
|
||||||
local deltaTime = uptime - lastUptime
|
|
||||||
lastUptime = uptime
|
|
||||||
|
|
||||||
for i = 1, config.lineCount do
|
|
||||||
point1 = points[i]
|
|
||||||
|
|
||||||
point1.x = point1.x + point1.vx * deltaTime
|
|
||||||
point1.y = point1.y + point1.vy * deltaTime
|
|
||||||
|
|
||||||
if point1.x < 0 or point1.x >= object.width then point1.vx = -point1.vx end
|
|
||||||
if point1.y < 0 or point1.y >= object.height * 2 then point1.vy = -point1.vy end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
configure = function(layout)
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
|
||||||
config.backgroundColor = object.color
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.lineColor, "Line color")).onColorSelected = function(_, object)
|
|
||||||
config.lineColor = object.color
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
local slider = layout:addChild(
|
|
||||||
GUI.slider(
|
|
||||||
1, 1,
|
|
||||||
36,
|
|
||||||
0x66DB80,
|
|
||||||
0xE1E1E1,
|
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
1, 10,
|
|
||||||
config.lineCount,
|
|
||||||
false,
|
|
||||||
"Line count: "
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
slider.roundValues = true
|
|
||||||
|
|
||||||
slider.onValueChanged = function(workspace, object)
|
|
||||||
config.lineCount = math.floor(object.value)
|
|
||||||
saveConfig()
|
|
||||||
reset()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
|
||||||
|
local uptime = computer.uptime()
|
||||||
|
local deltaTime = uptime - lastUptime
|
||||||
|
lastUptime = uptime
|
||||||
|
|
||||||
|
for i = 1, config.lineCount do
|
||||||
|
point1 = points[i]
|
||||||
|
|
||||||
|
point1.x = point1.x + point1.vx * deltaTime
|
||||||
|
point1.y = point1.y + point1.vy * deltaTime
|
||||||
|
|
||||||
|
if point1.x < 0 or point1.x >= object.width then point1.vx = -point1.vx end
|
||||||
|
if point1.y < 0 or point1.y >= object.height * 2 then point1.vy = -point1.vy end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
wallpaper.configure = function(layout)
|
||||||
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||||
|
config.backgroundColor = object.color
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.lineColor, "Line color")).onColorSelected = function(_, object)
|
||||||
|
config.lineColor = object.color
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
local slider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
1, 10,
|
||||||
|
config.lineCount,
|
||||||
|
false,
|
||||||
|
"Line count: "
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
slider.roundValues = true
|
||||||
|
|
||||||
|
slider.onValueChanged = function(workspace, object)
|
||||||
|
config.lineCount = math.floor(object.value)
|
||||||
|
saveConfig()
|
||||||
|
reset()
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -6,6 +6,8 @@ local GUI = require("GUI")
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, wallpaper = select(1, ...), select(2, ...)
|
||||||
|
|
||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
@ -30,121 +32,119 @@ end
|
|||||||
local drops = {}
|
local drops = {}
|
||||||
local lastUpdateTime = computer.uptime()
|
local lastUpdateTime = computer.uptime()
|
||||||
|
|
||||||
return {
|
wallpaper.draw = function(wallpaper)
|
||||||
draw = function(wallpaper)
|
-- Spawning drops
|
||||||
-- Spawning drops
|
local distance
|
||||||
local distance
|
|
||||||
|
|
||||||
for i = 1, config.dropAmount - #drops do
|
for i = 1, config.dropAmount - #drops do
|
||||||
distance = math.random()
|
distance = math.random()
|
||||||
|
|
||||||
table.insert(drops, {
|
table.insert(drops, {
|
||||||
x = math.random(wallpaper.width) - 1,
|
x = math.random(wallpaper.width) - 1,
|
||||||
y = 0,
|
y = 0,
|
||||||
speed = 50 - 40 * distance,
|
speed = 50 - 40 * distance,
|
||||||
color = color.transition(config.dropColor, config.backgroundColor, 0.2 + 0.8 * distance)
|
color = color.transition(config.dropColor, config.backgroundColor, 0.2 + 0.8 * distance)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clear the area
|
-- Clear the area
|
||||||
screen.drawRectangle(wallpaper.x, wallpaper.y, wallpaper.width, wallpaper.height, config.backgroundColor, 0, " ")
|
screen.drawRectangle(wallpaper.x, wallpaper.y, wallpaper.width, wallpaper.height, config.backgroundColor, 0, " ")
|
||||||
|
|
||||||
-- Rendering drops
|
-- Rendering drops
|
||||||
local drop, x, y
|
local drop, x, y
|
||||||
|
|
||||||
for i = 1, #drops do
|
for i = 1, #drops do
|
||||||
drop = drops[i]
|
drop = drops[i]
|
||||||
|
|
||||||
x, y = math.floor(drop.x), math.floor(drop.y)
|
|
||||||
|
|
||||||
screen.set(
|
|
||||||
wallpaper.x + x,
|
|
||||||
wallpaper.y + y,
|
|
||||||
config.backgroundColor,
|
|
||||||
drop.color,
|
|
||||||
(x == wallpaper.width - 1 or y == wallpaper.height - 1) and '*' or '\\'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Updating drops
|
|
||||||
local updateTime = computer.uptime()
|
|
||||||
local deltaTime = updateTime - lastUpdateTime
|
|
||||||
|
|
||||||
local i = 1
|
x, y = math.floor(drop.x), math.floor(drop.y)
|
||||||
while i <= #drops do
|
|
||||||
drop = drops[i]
|
|
||||||
|
|
||||||
drop.x = drop.x + drop.speed * config.speed * deltaTime
|
screen.set(
|
||||||
drop.y = drop.y + drop.speed * config.speed * deltaTime
|
wallpaper.x + x,
|
||||||
|
wallpaper.y + y,
|
||||||
if drop.x < 0 then
|
config.backgroundColor,
|
||||||
drop.x = wallpaper.width - drop.x
|
drop.color,
|
||||||
elseif drop.x >= wallpaper.width then
|
(x == wallpaper.width - 1 or y == wallpaper.height - 1) and '*' or '\\'
|
||||||
drop.x = wallpaper.width - drop.x
|
|
||||||
end
|
|
||||||
|
|
||||||
if drop.y >= wallpaper.height then
|
|
||||||
table.remove(drops, i)
|
|
||||||
else
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
lastUpdateTime = updateTime
|
|
||||||
end,
|
|
||||||
|
|
||||||
configure = function(layout)
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
|
||||||
config.backgroundColor = object.color
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.dropColor, "Drop color")).onColorSelected = function(_, object)
|
|
||||||
config.dropColor = object.color
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
local dropAmountSlider = layout:addChild(
|
|
||||||
GUI.slider(
|
|
||||||
1, 1,
|
|
||||||
36,
|
|
||||||
0x66DB80,
|
|
||||||
0xE1E1E1,
|
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
10, 500,
|
|
||||||
config.dropAmount,
|
|
||||||
false,
|
|
||||||
"Drop amount: "
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
end
|
||||||
dropAmountSlider.roundValues = true
|
|
||||||
dropAmountSlider.onValueChanged = function()
|
-- Updating drops
|
||||||
config.dropAmount = math.floor(dropAmountSlider.value)
|
local updateTime = computer.uptime()
|
||||||
saveConfig()
|
local deltaTime = updateTime - lastUpdateTime
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
while i <= #drops do
|
||||||
|
drop = drops[i]
|
||||||
|
|
||||||
|
drop.x = drop.x + drop.speed * config.speed * deltaTime
|
||||||
|
drop.y = drop.y + drop.speed * config.speed * deltaTime
|
||||||
|
|
||||||
|
if drop.x < 0 then
|
||||||
|
drop.x = wallpaper.width - drop.x
|
||||||
|
elseif drop.x >= wallpaper.width then
|
||||||
|
drop.x = wallpaper.width - drop.x
|
||||||
end
|
end
|
||||||
|
|
||||||
local speedSlider = layout:addChild(
|
if drop.y >= wallpaper.height then
|
||||||
GUI.slider(
|
table.remove(drops, i)
|
||||||
1, 1,
|
else
|
||||||
36,
|
i = i + 1
|
||||||
0x66DB80,
|
|
||||||
0xE1E1E1,
|
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
20, 200,
|
|
||||||
config.speed * 100,
|
|
||||||
false,
|
|
||||||
"Speed: ",
|
|
||||||
"%"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
speedSlider.roundValues = true
|
|
||||||
speedSlider.onValueChanged = function()
|
|
||||||
config.speed = speedSlider.value / 100
|
|
||||||
saveConfig()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
|
||||||
|
lastUpdateTime = updateTime
|
||||||
|
end
|
||||||
|
|
||||||
|
wallpaper.configure = function(layout)
|
||||||
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||||
|
config.backgroundColor = object.color
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.dropColor, "Drop color")).onColorSelected = function(_, object)
|
||||||
|
config.dropColor = object.color
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
local dropAmountSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
10, 500,
|
||||||
|
config.dropAmount,
|
||||||
|
false,
|
||||||
|
"Drop amount: "
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
dropAmountSlider.roundValues = true
|
||||||
|
dropAmountSlider.onValueChanged = function()
|
||||||
|
config.dropAmount = math.floor(dropAmountSlider.value)
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
local speedSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
20, 200,
|
||||||
|
config.speed * 100,
|
||||||
|
false,
|
||||||
|
"Speed: ",
|
||||||
|
"%"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
speedSlider.roundValues = true
|
||||||
|
speedSlider.onValueChanged = function()
|
||||||
|
config.speed = speedSlider.value / 100
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -6,6 +6,8 @@ local GUI = require("GUI")
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, wallpaper = select(1, ...), select(2, ...)
|
||||||
|
|
||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
@ -53,166 +55,164 @@ local wind = 0
|
|||||||
|
|
||||||
local lastUpdateTime = computer.uptime()
|
local lastUpdateTime = computer.uptime()
|
||||||
|
|
||||||
return {
|
wallpaper.draw = function(wallpaper)
|
||||||
draw = function(wallpaper)
|
-- Spawning snowflakes
|
||||||
-- Spawning snowflakes
|
local distance
|
||||||
local distance
|
|
||||||
|
|
||||||
for i = 1, config.snowflakeAmount - #snowflakes do
|
for i = 1, config.snowflakeAmount - #snowflakes do
|
||||||
distance = math.random()
|
distance = math.random()
|
||||||
|
|
||||||
tableInsert(snowflakes, {
|
tableInsert(snowflakes, {
|
||||||
x = mathRandom(1, wallpaper.width) - 1,
|
x = mathRandom(1, wallpaper.width) - 1,
|
||||||
y = 0,
|
y = 0,
|
||||||
color = colorTransition(config.snowflakeColor, config.backgroundColor, .2 + .8 * distance),
|
color = colorTransition(config.snowflakeColor, config.backgroundColor, .2 + .8 * distance),
|
||||||
speed = 2 - 1.5 * distance,
|
speed = 2 - 1.5 * distance,
|
||||||
vx = 0
|
vx = 0
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clearing the area
|
-- Clearing the area
|
||||||
screenDrawRectangle(wallpaper.x, wallpaper.y, wallpaper.width, wallpaper.height, config.backgroundColor, 0, " ")
|
screenDrawRectangle(wallpaper.x, wallpaper.y, wallpaper.width, wallpaper.height, config.backgroundColor, 0, " ")
|
||||||
|
|
||||||
-- Rendering snowflakes
|
-- Rendering snowflakes
|
||||||
local snowflake
|
local snowflake
|
||||||
|
|
||||||
for i = 1, #snowflakes do
|
for i = 1, #snowflakes do
|
||||||
snowflake = snowflakes[i]
|
snowflake = snowflakes[i]
|
||||||
|
|
||||||
screenSemiPixelSet(
|
screenSemiPixelSet(
|
||||||
mathFloor(wallpaper.x + snowflake.x),
|
mathFloor(wallpaper.x + snowflake.x),
|
||||||
mathFloor(wallpaper.y + snowflake.y),
|
mathFloor(wallpaper.y + snowflake.y),
|
||||||
snowflake.color
|
snowflake.color
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Rendering stacks
|
|
||||||
local stackHeight
|
|
||||||
|
|
||||||
for x, stackHeight in pairs(stacks) do
|
|
||||||
screenDrawSemiPixelRectangle(wallpaper.x + x, wallpaper.y + wallpaper.height * 2 - stackHeight + 1, 1, stackHeight, config.snowflakeColor)
|
|
||||||
|
|
||||||
if stackHeight > config.maxStackHeight then
|
|
||||||
stacks[x] = stackHeight - 2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Updating snowflakes
|
|
||||||
local currentTime = computer.uptime()
|
|
||||||
local deltaTime = (currentTime - lastUpdateTime) * 20
|
|
||||||
|
|
||||||
wind = wind + .1 * (2 * mathRandom() - 1) * deltaTime
|
|
||||||
if wind > config.maxWind then wind = config.maxWind end
|
|
||||||
if wind < -config.maxWind then wind = -config.maxWind end
|
|
||||||
|
|
||||||
local doubleHeight = wallpaper.height * 2
|
|
||||||
local x, y
|
|
||||||
|
|
||||||
local i = 1
|
|
||||||
while i <= #snowflakes do
|
|
||||||
snowflake = snowflakes[i]
|
|
||||||
|
|
||||||
snowflake.y = snowflake.y + deltaTime * snowflake.speed
|
|
||||||
snowflake.x = snowflake.x + deltaTime * (wind * snowflake.speed + snowflake.vx)
|
|
||||||
|
|
||||||
snowflake.vx = snowflake.vx + (mathRandom() * 2 - 1) * 0.1 * deltaTime
|
|
||||||
|
|
||||||
if snowflake.vx > 1 then
|
|
||||||
snowflake.vx = 1
|
|
||||||
elseif snowflake.vx < -1 then
|
|
||||||
snowflake.vx = -1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- When snowflake moves out of wallpaper bounds - teleporting
|
|
||||||
-- it to the opposite side
|
|
||||||
if snowflake.x < 0 then
|
|
||||||
snowflake.x = wallpaper.width - snowflake.x
|
|
||||||
elseif snowflake.x >= wallpaper.width then
|
|
||||||
snowflake.x = snowflake.x - wallpaper.width
|
|
||||||
end
|
|
||||||
|
|
||||||
x, y = mathFloor(snowflake.x), mathFloor(snowflake.y)
|
|
||||||
stackHeight = stacks[x] or 0
|
|
||||||
|
|
||||||
if y >= doubleHeight - stackHeight then
|
|
||||||
stacks[x] = stackHeight + 1
|
|
||||||
|
|
||||||
if x > 0 then
|
|
||||||
local leftStackHeight = stacks[x-1] or 0
|
|
||||||
if stacks[x] - leftStackHeight > 2 then
|
|
||||||
stacks[x-1] = leftStackHeight + 1
|
|
||||||
stacks[x] = stackHeight
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if x < wallpaper.width-1 then
|
|
||||||
local rightStackHeight = stacks[x+1] or 0
|
|
||||||
if stacks[x] - rightStackHeight > 2 then
|
|
||||||
stacks[x+1] = rightStackHeight + 1
|
|
||||||
stacks[x] = stackHeight
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
tableRemove(snowflakes, i)
|
|
||||||
else
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
lastUpdateTime = currentTime
|
|
||||||
end,
|
|
||||||
|
|
||||||
configure = function(layout)
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
|
||||||
config.backgroundColor = object.color
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.snowflakeColor, "Snowflake color")).onColorSelected = function(_, object)
|
|
||||||
config.snowflakeColor = object.color
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
local snowflakeAmountSlider = layout:addChild(
|
|
||||||
GUI.slider(
|
|
||||||
1, 1,
|
|
||||||
36,
|
|
||||||
0x66DB80,
|
|
||||||
0xE1E1E1,
|
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
5, 50,
|
|
||||||
config.snowflakeAmount,
|
|
||||||
false,
|
|
||||||
"Snowflake amount: "
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
end
|
||||||
snowflakeAmountSlider.roundValues = true
|
|
||||||
snowflakeAmountSlider.onValueChanged = function()
|
-- Rendering stacks
|
||||||
config.snowflakeAmount = math.floor(snowflakeAmountSlider.value)
|
local stackHeight
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
local maxStackHeightSlider = layout:addChild(
|
for x, stackHeight in pairs(stacks) do
|
||||||
GUI.slider(
|
screenDrawSemiPixelRectangle(wallpaper.x + x, wallpaper.y + wallpaper.height * 2 - stackHeight + 1, 1, stackHeight, config.snowflakeColor)
|
||||||
1, 1,
|
|
||||||
36,
|
|
||||||
0x66DB80,
|
|
||||||
0xE1E1E1,
|
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
0, 50,
|
|
||||||
config.maxStackHeight,
|
|
||||||
false,
|
|
||||||
"Stack height limit: "
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
maxStackHeightSlider.roundValues = true
|
if stackHeight > config.maxStackHeight then
|
||||||
maxStackHeightSlider.onValueChanged = function()
|
stacks[x] = stackHeight - 2
|
||||||
config.maxStackHeight = math.floor(maxStackHeightSlider.value)
|
|
||||||
saveConfig()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
|
||||||
|
-- Updating snowflakes
|
||||||
|
local currentTime = computer.uptime()
|
||||||
|
local deltaTime = (currentTime - lastUpdateTime) * 20
|
||||||
|
|
||||||
|
wind = wind + .1 * (2 * mathRandom() - 1) * deltaTime
|
||||||
|
if wind > config.maxWind then wind = config.maxWind end
|
||||||
|
if wind < -config.maxWind then wind = -config.maxWind end
|
||||||
|
|
||||||
|
local doubleHeight = wallpaper.height * 2
|
||||||
|
local x, y
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
while i <= #snowflakes do
|
||||||
|
snowflake = snowflakes[i]
|
||||||
|
|
||||||
|
snowflake.y = snowflake.y + deltaTime * snowflake.speed
|
||||||
|
snowflake.x = snowflake.x + deltaTime * (wind * snowflake.speed + snowflake.vx)
|
||||||
|
|
||||||
|
snowflake.vx = snowflake.vx + (mathRandom() * 2 - 1) * 0.1 * deltaTime
|
||||||
|
|
||||||
|
if snowflake.vx > 1 then
|
||||||
|
snowflake.vx = 1
|
||||||
|
elseif snowflake.vx < -1 then
|
||||||
|
snowflake.vx = -1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- When snowflake moves out of wallpaper bounds - teleporting
|
||||||
|
-- it to the opposite side
|
||||||
|
if snowflake.x < 0 then
|
||||||
|
snowflake.x = wallpaper.width - snowflake.x
|
||||||
|
elseif snowflake.x >= wallpaper.width then
|
||||||
|
snowflake.x = snowflake.x - wallpaper.width
|
||||||
|
end
|
||||||
|
|
||||||
|
x, y = mathFloor(snowflake.x), mathFloor(snowflake.y)
|
||||||
|
stackHeight = stacks[x] or 0
|
||||||
|
|
||||||
|
if y >= doubleHeight - stackHeight then
|
||||||
|
stacks[x] = stackHeight + 1
|
||||||
|
|
||||||
|
if x > 0 then
|
||||||
|
local leftStackHeight = stacks[x-1] or 0
|
||||||
|
if stacks[x] - leftStackHeight > 2 then
|
||||||
|
stacks[x-1] = leftStackHeight + 1
|
||||||
|
stacks[x] = stackHeight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if x < wallpaper.width-1 then
|
||||||
|
local rightStackHeight = stacks[x+1] or 0
|
||||||
|
if stacks[x] - rightStackHeight > 2 then
|
||||||
|
stacks[x+1] = rightStackHeight + 1
|
||||||
|
stacks[x] = stackHeight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tableRemove(snowflakes, i)
|
||||||
|
else
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lastUpdateTime = currentTime
|
||||||
|
end
|
||||||
|
|
||||||
|
wallpaper.configure = function(layout)
|
||||||
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||||
|
config.backgroundColor = object.color
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.snowflakeColor, "Snowflake color")).onColorSelected = function(_, object)
|
||||||
|
config.snowflakeColor = object.color
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
local snowflakeAmountSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
5, 50,
|
||||||
|
config.snowflakeAmount,
|
||||||
|
false,
|
||||||
|
"Snowflake amount: "
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
snowflakeAmountSlider.roundValues = true
|
||||||
|
snowflakeAmountSlider.onValueChanged = function()
|
||||||
|
config.snowflakeAmount = math.floor(snowflakeAmountSlider.value)
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
local maxStackHeightSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
0, 50,
|
||||||
|
config.maxStackHeight,
|
||||||
|
false,
|
||||||
|
"Stack height limit: "
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
maxStackHeightSlider.roundValues = true
|
||||||
|
maxStackHeightSlider.onValueChanged = function()
|
||||||
|
config.maxStackHeight = math.floor(maxStackHeightSlider.value)
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -5,6 +5,8 @@ local GUI = require("GUI")
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, wallpaper = select(1, ...), select(2, ...)
|
||||||
|
|
||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
@ -23,15 +25,13 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
return {
|
wallpaper.draw = function(object)
|
||||||
draw = function(object)
|
screen.drawRectangle(object.x, object.y, object.width, object.height, config.color, 0, ' ')
|
||||||
screen.drawRectangle(object.x, object.y, object.width, object.height, config.color, 0, ' ')
|
end
|
||||||
end,
|
|
||||||
|
|
||||||
configure = function(layout)
|
wallpaper.configure = function(layout)
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.color, "Color")).onColorSelected = function(_, object)
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.color, "Color")).onColorSelected = function(_, object)
|
||||||
config.color = object.color
|
config.color = object.color
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
@ -6,6 +6,8 @@ local color = require("Color")
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, wallpaper = select(1, ...), select(2, ...)
|
||||||
|
|
||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
@ -72,170 +74,166 @@ end
|
|||||||
|
|
||||||
resetColors()
|
resetColors()
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
wallpaper.draw = function(wallpaper)
|
||||||
|
local hitsDeadline = computerUptime() >= deadline
|
||||||
|
|
||||||
return {
|
-- Drawing background
|
||||||
draw = function(wallpaper)
|
screen.drawRectangle(wallpaper.x, wallpaper.y, wallpaper.width, wallpaper.height, config.backgroundColor, 0, " ")
|
||||||
local hitsDeadline = computerUptime() >= deadline
|
|
||||||
|
|
||||||
-- Drawing background
|
-- Spawning missing stars
|
||||||
screen.drawRectangle(wallpaper.x, wallpaper.y, wallpaper.width, wallpaper.height, config.backgroundColor, 0, " ")
|
local rotationAngle, targetX, targetY
|
||||||
|
|
||||||
-- Spawning missing stars
|
while #stars < config.starAmount do
|
||||||
local rotationAngle, targetX, targetY
|
rotationAngle = mathRandom(6265) / 1000
|
||||||
|
targetX = mathCos(rotationAngle) * wallpaper.width * 0.75 + wallpaper.width / 2
|
||||||
|
targetY = mathSin(rotationAngle) * wallpaper.width * 0.375 + wallpaper.height / 2
|
||||||
|
|
||||||
while #stars < config.starAmount do
|
table.insert(stars, {
|
||||||
rotationAngle = mathRandom(6265) / 1000
|
targetX = targetX,
|
||||||
targetX = mathCos(rotationAngle) * wallpaper.width * 0.75 + wallpaper.width / 2
|
targetY = targetY,
|
||||||
targetY = mathSin(rotationAngle) * wallpaper.width * 0.375 + wallpaper.height / 2
|
startX = (targetX - wallpaper.width / 2) * config.starOffset + wallpaper.width / 2,
|
||||||
|
startY = (targetY - wallpaper.height / 2) * config.starOffset + wallpaper.height / 2,
|
||||||
|
speed = mathRandom(25, 75) / 1000 + 1,
|
||||||
|
|
||||||
table.insert(stars, {
|
-- Defines the star lifetime in range (0.0; 1.0]
|
||||||
targetX = targetX,
|
-- Shouldn't be zero, because it will be mutiplied to
|
||||||
targetY = targetY,
|
-- simulate "speed up" effect on sides of screen
|
||||||
startX = (targetX - wallpaper.width / 2) * config.starOffset + wallpaper.width / 2,
|
age = 0.01
|
||||||
startY = (targetY - wallpaper.height / 2) * config.starOffset + wallpaper.height / 2,
|
})
|
||||||
speed = mathRandom(25, 75) / 1000 + 1,
|
end
|
||||||
|
|
||||||
-- Defines the star lifetime in range (0.0; 1.0]
|
-- Drawing stars
|
||||||
-- Shouldn't be zero, because it will be mutiplied to
|
local star, x, y, xmod, ymod, color
|
||||||
-- simulate "speed up" effect on sides of screen
|
|
||||||
age = 0.01
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Drawing stars
|
local i = 1
|
||||||
local star, x, y, xmod, ymod, color
|
while i <= #stars do
|
||||||
|
star = stars[i]
|
||||||
|
|
||||||
local i = 1
|
x = star.startX + (star.targetX - star.startX) * star.age
|
||||||
while i <= #stars do
|
y = star.startY + (star.targetY - star.startY) * star.age
|
||||||
star = stars[i]
|
|
||||||
|
|
||||||
x = star.startX + (star.targetX - star.startX) * star.age
|
if x > wallpaper.width + 1 or x < 1 or y > wallpaper.height + 1 or y < 1 then
|
||||||
y = star.startY + (star.targetY - star.startY) * star.age
|
tableRemove(stars, i)
|
||||||
|
else
|
||||||
|
xmod = x * 2;
|
||||||
|
xmod = (xmod - xmod % 1) % 2
|
||||||
|
|
||||||
|
ymod = y * 4; ymod = (ymod - ymod % 1) % 4
|
||||||
|
|
||||||
if x > wallpaper.width + 1 or x < 1 or y > wallpaper.height + 1 or y < 1 then
|
color = star.age * #colors * config.starBrightness
|
||||||
tableRemove(stars, i)
|
color = colors[color - color % 1 + 1] or colors[#colors]
|
||||||
else
|
|
||||||
xmod = x * 2;
|
|
||||||
xmod = (xmod - xmod % 1) % 2
|
|
||||||
|
|
||||||
ymod = y * 4; ymod = (ymod - ymod % 1) % 4
|
|
||||||
|
|
||||||
color = star.age * #colors * config.starBrightness
|
-- Small stars
|
||||||
color = colors[color - color % 1 + 1] or colors[#colors]
|
if star.age < 0.3 then
|
||||||
|
if xmod == 0 then
|
||||||
-- Small stars
|
if ymod == 0 then char = braille1
|
||||||
if star.age < 0.3 then
|
elseif ymod == 1 then char = braille3
|
||||||
if xmod == 0 then
|
elseif ymod == 2 then char = braille5
|
||||||
if ymod == 0 then char = braille1
|
else char = braille7
|
||||||
elseif ymod == 1 then char = braille3
|
|
||||||
elseif ymod == 2 then char = braille5
|
|
||||||
else char = braille7
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if ymod == 0 then char = braille2
|
|
||||||
elseif ymod == 1 then char = braille4
|
|
||||||
elseif ymod == 2 then char = braille6
|
|
||||||
else char = braille8
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- Big stars
|
|
||||||
else
|
else
|
||||||
if ymod < 2 then
|
if ymod == 0 then char = braille2
|
||||||
char = braille9
|
elseif ymod == 1 then char = braille4
|
||||||
else
|
elseif ymod == 2 then char = braille6
|
||||||
char = braille10
|
else char = braille8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Big stars
|
||||||
screen.set(x - x % 1, y - y % 1, config.backgroundColor, color, char)
|
else
|
||||||
i = i + 1
|
if ymod < 2 then
|
||||||
|
char = braille9
|
||||||
if hitsDeadline then
|
else
|
||||||
star.age = star.age * star.speed
|
char = braille10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if hitsDeadline then
|
screen.set(x - x % 1, y - y % 1, config.backgroundColor, color, char)
|
||||||
deadline = computerUptime() + 0.05
|
i = i + 1
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
configure = function(layout)
|
if hitsDeadline then
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
star.age = star.age * star.speed
|
||||||
config.backgroundColor = object.color
|
end
|
||||||
resetColors()
|
|
||||||
saveConfig()
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.starColor, "Star color")).onColorSelected = function(_, object)
|
if hitsDeadline then
|
||||||
config.starColor = object.color
|
deadline = computerUptime() + 0.05
|
||||||
resetColors()
|
end
|
||||||
saveConfig()
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local starAmountSlider = layout:addChild(
|
wallpaper.configure = function(layout)
|
||||||
GUI.slider(
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||||
1, 1,
|
config.backgroundColor = object.color
|
||||||
36,
|
resetColors()
|
||||||
0x66DB80,
|
saveConfig()
|
||||||
0xE1E1E1,
|
end
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
10, 500,
|
|
||||||
config.starAmount,
|
|
||||||
false,
|
|
||||||
"Star amount: "
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
starAmountSlider.roundValues = true
|
|
||||||
starAmountSlider.onValueChanged = function()
|
|
||||||
config.starAmount = math.floor(starAmountSlider.value)
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
local starBrightnessSlider = layout:addChild(
|
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.starColor, "Star color")).onColorSelected = function(_, object)
|
||||||
GUI.slider(
|
config.starColor = object.color
|
||||||
1, 1,
|
resetColors()
|
||||||
36,
|
saveConfig()
|
||||||
0x66DB80,
|
end
|
||||||
0xE1E1E1,
|
|
||||||
0xFFFFFF,
|
|
||||||
0xA5A5A5,
|
|
||||||
50, 300,
|
|
||||||
config.starBrightness * 100,
|
|
||||||
false,
|
|
||||||
"Star brightness: ",
|
|
||||||
"%"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
starBrightnessSlider.roundValues = true
|
|
||||||
starBrightnessSlider.onValueChanged = function()
|
|
||||||
config.starBrightness = starBrightnessSlider.value / 100
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
local offsetSlider = layout:addChild(GUI.slider(
|
local starAmountSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
1, 1,
|
1, 1,
|
||||||
36,
|
36,
|
||||||
0x66DB80,
|
0x66DB80,
|
||||||
0xE1E1E1,
|
0xE1E1E1,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xA5A5A5,
|
0xA5A5A5,
|
||||||
0, 100,
|
10, 500,
|
||||||
config.starOffset * 100,
|
config.starAmount,
|
||||||
false,
|
false,
|
||||||
"Offset: ",
|
"Star amount: "
|
||||||
"%"
|
)
|
||||||
))
|
)
|
||||||
|
|
||||||
offsetSlider.roundValues = true
|
starAmountSlider.roundValues = true
|
||||||
offsetSlider.onValueChanged = function()
|
starAmountSlider.onValueChanged = function()
|
||||||
config.starOffset = offsetSlider.value / 100
|
config.starAmount = math.floor(starAmountSlider.value)
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
|
||||||
|
local starBrightnessSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
50, 300,
|
||||||
|
config.starBrightness * 100,
|
||||||
|
false,
|
||||||
|
"Star brightness: ",
|
||||||
|
"%"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
starBrightnessSlider.roundValues = true
|
||||||
|
starBrightnessSlider.onValueChanged = function()
|
||||||
|
config.starBrightness = starBrightnessSlider.value / 100
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
|
local offsetSlider = layout:addChild(GUI.slider(
|
||||||
|
1, 1,
|
||||||
|
36,
|
||||||
|
0x66DB80,
|
||||||
|
0xE1E1E1,
|
||||||
|
0xFFFFFF,
|
||||||
|
0xA5A5A5,
|
||||||
|
0, 100,
|
||||||
|
config.starOffset * 100,
|
||||||
|
false,
|
||||||
|
"Offset: ",
|
||||||
|
"%"
|
||||||
|
))
|
||||||
|
|
||||||
|
offsetSlider.roundValues = true
|
||||||
|
offsetSlider.onValueChanged = function()
|
||||||
|
config.starOffset = offsetSlider.value / 100
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -6,6 +6,8 @@ local image = require("Image")
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, wallpaper = select(1, ...), select(2, ...)
|
||||||
|
|
||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
@ -40,24 +42,22 @@ loadPicture()
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
return {
|
wallpaper.draw = function(object)
|
||||||
draw = function(object)
|
if picture then
|
||||||
if picture then
|
screen.drawImage(object.x, object.y, picture)
|
||||||
screen.drawImage(object.x, object.y, picture)
|
else
|
||||||
else
|
screen.drawRectangle(object.x, object.y, object.width, object.height, 0x161616, 0x000000, " ")
|
||||||
screen.drawRectangle(object.x, object.y, object.width, object.height, 0x161616, 0x000000, " ")
|
|
||||||
|
|
||||||
local text = reason or "Unknown reason"
|
local text = reason or "Unknown reason"
|
||||||
screen.drawText(math.floor(object.x + object.width / 2 - unicode.len(text) / 2), math.floor(object.y + object.height / 2), 0x646464, text)
|
screen.drawText(math.floor(object.x + object.width / 2 - unicode.len(text) / 2), math.floor(object.y + object.height / 2), 0x646464, text)
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
|
|
||||||
configure = function(layout)
|
wallpaper.configure = function(layout)
|
||||||
local chooser = layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5, config.path, "Open", "Cancel", "Wallpaper path", "/"))
|
local chooser = layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5, config.path, "Open", "Cancel", "Wallpaper path", "/"))
|
||||||
chooser:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
|
chooser:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
|
||||||
chooser:addExtensionFilter(".pic")
|
chooser:addExtensionFilter(".pic")
|
||||||
chooser.onSubmit = setPicture
|
chooser.onSubmit = setPicture
|
||||||
end,
|
end
|
||||||
|
|
||||||
setPicture = setPicture
|
wallpaper.setPicture = setPicture
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user