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
|
||||
|
||||
-- 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
|
||||
system.wallpaper.configure(window.contentLayout)
|
||||
wallpaper.configure(window.contentLayout)
|
||||
configureTo = #window.contentLayout.children
|
||||
end
|
||||
end
|
||||
|
||||
@ -35,9 +35,7 @@ local dockContainer
|
||||
local desktopMenu
|
||||
local desktopMenuLayout
|
||||
local desktopIconField
|
||||
local desktopBackground
|
||||
local desktopBackgroundWallpaperX
|
||||
local desktopBackgroundWallpaperY
|
||||
local wallpaper
|
||||
|
||||
-- Caching commonly used icons
|
||||
local iconCache = {
|
||||
@ -485,7 +483,7 @@ function system.addSetAsWallpaperMenuItem(menu, path)
|
||||
system.updateWallpaper()
|
||||
end
|
||||
|
||||
system.wallpaper.setPicture(path)
|
||||
wallpaper.setPicture(path)
|
||||
|
||||
workspace:draw()
|
||||
system.saveUserSettings()
|
||||
@ -2414,43 +2412,45 @@ function system.execute(path, ...)
|
||||
return success, errorPath, line, traceback
|
||||
end
|
||||
|
||||
local function desktopBackgroundAmbientDraw()
|
||||
screen.drawRectangle(1, desktopBackground.y, desktopBackground.width, desktopBackground.height, 0x1E1E1E, 0, " ")
|
||||
local function wallpaperDraw()
|
||||
screen.drawRectangle(1, wallpaper.y, wallpaper.width, wallpaper.height, 0x1E1E1E, 0, " ")
|
||||
end
|
||||
|
||||
function system.getWallpaper()
|
||||
return wallpaper
|
||||
end
|
||||
|
||||
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
|
||||
reset()
|
||||
|
||||
if not userSettings.interfaceWallpaperPath then
|
||||
return
|
||||
end
|
||||
|
||||
local executable, reason = loadfile(userSettings.interfaceWallpaperPath .. "Main.lua")
|
||||
if not executable then
|
||||
GUI.alert(reason)
|
||||
local result, reason = loadfile(userSettings.interfaceWallpaperPath .. "Main.lua")
|
||||
if not result then
|
||||
alert(reason)
|
||||
return
|
||||
end
|
||||
|
||||
local success, wallpaperOrError = xpcall(executable, debug.traceback)
|
||||
if not success then
|
||||
GUI.alert(wallpaperOrError)
|
||||
result, reason = xpcall(result, debug.traceback, workspace, wallpaper)
|
||||
if not result then
|
||||
alert()
|
||||
return
|
||||
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
|
||||
end
|
||||
|
||||
@ -2475,7 +2475,7 @@ function system.updateResolution()
|
||||
|
||||
desktopMenu.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
|
||||
|
||||
@ -2963,11 +2963,12 @@ function system.updateWorkspace()
|
||||
workspace.ignoresCapturedObject = true
|
||||
|
||||
-- Creating desktop background object
|
||||
desktopBackground = workspace:addChild(GUI.object(1, 1, workspace.width, workspace.height))
|
||||
desktopBackground.ignoresCapturedObject = true
|
||||
wallpaper = workspace:addChild(GUI.object(1, 1, workspace.width, workspace.height))
|
||||
-- wallpaper.ignoresCapturedObject = true
|
||||
wallpaper.blockScreenEvents = false
|
||||
|
||||
local oldDraw = desktopBackground and desktopBackground.draw
|
||||
desktopBackground.draw = oldDraw or desktopBackgroundAmbientDraw
|
||||
local oldDraw = wallpaper and wallpaper.draw
|
||||
wallpaper.draw = oldDraw or wallpaperDraw
|
||||
end
|
||||
|
||||
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))
|
||||
|
||||
-- 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))
|
||||
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 config = {
|
||||
@ -46,10 +48,7 @@ end
|
||||
|
||||
reset(object)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
draw = function(object)
|
||||
wallpaper.draw = function(object)
|
||||
screen.drawRectangle(object.x, object.y, object.width, object.height, config.backgroundColor, 0, " ")
|
||||
|
||||
local point1, point2
|
||||
@ -81,9 +80,9 @@ return {
|
||||
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,
|
||||
end
|
||||
|
||||
configure = function(layout)
|
||||
wallpaper.configure = function(layout)
|
||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||
config.backgroundColor = object.color
|
||||
saveConfig()
|
||||
@ -117,4 +116,3 @@ return {
|
||||
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 config = {
|
||||
@ -30,8 +32,7 @@ end
|
||||
local drops = {}
|
||||
local lastUpdateTime = computer.uptime()
|
||||
|
||||
return {
|
||||
draw = function(wallpaper)
|
||||
wallpaper.draw = function(wallpaper)
|
||||
-- Spawning drops
|
||||
local distance
|
||||
|
||||
@ -91,9 +92,9 @@ return {
|
||||
end
|
||||
|
||||
lastUpdateTime = updateTime
|
||||
end,
|
||||
end
|
||||
|
||||
configure = function(layout)
|
||||
wallpaper.configure = function(layout)
|
||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||
config.backgroundColor = object.color
|
||||
saveConfig()
|
||||
@ -147,4 +148,3 @@ return {
|
||||
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 config = {
|
||||
@ -53,8 +55,7 @@ local wind = 0
|
||||
|
||||
local lastUpdateTime = computer.uptime()
|
||||
|
||||
return {
|
||||
draw = function(wallpaper)
|
||||
wallpaper.draw = function(wallpaper)
|
||||
-- Spawning snowflakes
|
||||
local distance
|
||||
|
||||
@ -160,9 +161,9 @@ return {
|
||||
end
|
||||
|
||||
lastUpdateTime = currentTime
|
||||
end,
|
||||
end
|
||||
|
||||
configure = function(layout)
|
||||
wallpaper.configure = function(layout)
|
||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||
config.backgroundColor = object.color
|
||||
saveConfig()
|
||||
@ -215,4 +216,3 @@ return {
|
||||
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 config = {
|
||||
@ -23,15 +25,13 @@ end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
draw = function(object)
|
||||
wallpaper.draw = function(object)
|
||||
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)
|
||||
config.color = object.color
|
||||
saveConfig()
|
||||
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 config = {
|
||||
@ -72,10 +74,7 @@ end
|
||||
|
||||
resetColors()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
draw = function(wallpaper)
|
||||
wallpaper.draw = function(wallpaper)
|
||||
local hitsDeadline = computerUptime() >= deadline
|
||||
|
||||
-- Drawing background
|
||||
@ -160,9 +159,9 @@ return {
|
||||
if hitsDeadline then
|
||||
deadline = computerUptime() + 0.05
|
||||
end
|
||||
end,
|
||||
end
|
||||
|
||||
configure = function(layout)
|
||||
wallpaper.configure = function(layout)
|
||||
layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.backgroundColor, "Background color")).onColorSelected = function(_, object)
|
||||
config.backgroundColor = object.color
|
||||
resetColors()
|
||||
@ -238,4 +237,3 @@ return {
|
||||
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 config = {
|
||||
@ -40,8 +42,7 @@ loadPicture()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
draw = function(object)
|
||||
wallpaper.draw = function(object)
|
||||
if picture then
|
||||
screen.drawImage(object.x, object.y, picture)
|
||||
else
|
||||
@ -50,14 +51,13 @@ return {
|
||||
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)
|
||||
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", "/"))
|
||||
chooser:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
|
||||
chooser:addExtensionFilter(".pic")
|
||||
chooser.onSubmit = setPicture
|
||||
end,
|
||||
end
|
||||
|
||||
setPicture = setPicture
|
||||
}
|
||||
wallpaper.setPicture = setPicture
|
||||
Loading…
x
Reference in New Issue
Block a user