diff --git a/Applications/Calculator.app/Main.lua b/Applications/Calculator.app/Main.lua index e819ea86..0f93ddf7 100644 --- a/Applications/Calculator.app/Main.lua +++ b/Applications/Calculator.app/Main.lua @@ -29,7 +29,7 @@ local workspace, window, menu = system.addWindow(GUI.window(1, 1, buttonWidth * local displayContainer = window:addChild(GUI.container(1, 1, window.width, displayHeight + binaryHeight)) -local displayPanel = displayContainer:addChild(GUI.panel(1, 1, window.width, displayHeight, 0x2D2D2D, 0.1)) +local displayPanel = displayContainer:addChild(GUI.panel(1, 1, window.width, displayHeight, 0x1E1E1E, 0.1)) local actionButtons = window:addChild(GUI.actionButtons(3, 3, true)) @@ -41,7 +41,7 @@ actionButtons.minimize.onTouch = function() window:minimize() end -local binaryPanel = displayContainer:addChild(GUI.panel(1, displayHeight + 1, window.width, binaryHeight, 0x3C3C3C)) +local binaryPanel = displayContainer:addChild(GUI.panel(1, displayHeight + 1, window.width, binaryHeight, 0x2D2D2D)) local binaryLayout = displayContainer:addChild(GUI.layout(1, displayHeight + 2, window.width, binaryHeight, 1, 1)) binaryLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) @@ -230,8 +230,10 @@ end local function addBinaryButtonsContainer(row, leftText, rightText) local container = row:addChild(GUI.container(1, 1, 15, 2)) local x = 1 + for i = 1, 8 do - local button = container:addChild(GUI.button(x, 1, 1, 1, nil, 0x969696, nil, 0xFFFFFF, "0")) + local button = container:addChild(GUI.button(x, 1, 1, 1, nil, 0x696969, nil, 0xFFFFFF, "0")) + button.onTouch = function() button.text = button.text == "0" and "1" or "0" binaryToNumber() diff --git a/Libraries/System.lua b/Libraries/System.lua index 22384358..301e98fd 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -16,6 +16,9 @@ local system = {} local iconImageWidth = 8 local iconImageHeight = 4 +local interfaceUpdateInterval = 1 +local interfaceDrawInterval = 1 + local bootUptime = computer.uptime() local user @@ -83,7 +86,6 @@ function system.getDefaultUserSettings() networkFTPConnections = {}, interfaceScreenAddress = nil, - interfaceScreenUpdateInterval = 1, interfaceWallpaperEnabled = false, interfaceWallpaperPath = paths.system.pictures .. "Flight.lua", interfaceWallpaperMode = 1, @@ -2300,6 +2302,7 @@ end function system.updateWallpaper() desktopBackground.draw = desktopBackgroundAmbientDraw + interfaceDrawInterval = 1 if userSettings.interfaceWallpaperEnabled and userSettings.interfaceWallpaperPath then local extension = filesystem.extension(userSettings.interfaceWallpaperPath) @@ -2346,37 +2349,33 @@ function system.updateWallpaper() desktopBackground.draw = function(...) desktopBackgroundAmbientDraw(...) + screen.drawImage(desktopBackgroundWallpaperX, desktopBackgroundWallpaperY, result) end else GUI.alert(reason or "image file is corrupted") end - - userSettings.interfaceScreenUpdateInterval = 1 elseif extension == ".lua" then - local result, reason = loadfile(userSettings.interfaceWallpaperPath) + local result, data = loadfile(userSettings.interfaceWallpaperPath) if result then - result, functionOrReason = xpcall(result, debug.traceback) + result, data = xpcall(result, debug.traceback) if result then - if type(functionOrReason) == "function" then - desktopBackground.draw = functionOrReason + if type(data) == "function" then + desktopBackground.draw = data + interfaceDrawInterval = 0.01 else GUI.alert("Wallpaper script didn't return drawing function") end else - GUI.alert(functionOrReason) + GUI.alert(data) end else - GUI.alert(reason) + GUI.alert(data) end - - userSettings.interfaceScreenUpdateInterval = 0.01 end - else - userSettings.interfaceScreenUpdateInterval = 1 end end @@ -2801,7 +2800,8 @@ function system.updateDesktop() end local lastWindowHandled - local dateDeadline = bootUptime + 1 + local interfaceUpdateDeadline = bootUptime + interfaceDrawInterval + local interfaceDrawDeadline = bootUptime + interfaceDrawInterval local screensaverUptime = bootUptime workspace.eventHandler = function(workspace, object, e1, e2, e3, e4) @@ -2832,30 +2832,35 @@ function system.updateDesktop() elseif e1 == "network" then if e2 == "accessDenied" then GUI.alert(localization.networkAccessDenied) + elseif e2 == "timeout" then GUI.alert(localization.networkTimeout) end end - if computer.uptime() >= dateDeadline then + uptime = computer.uptime() + + if uptime >= interfaceUpdateDeadline then system.updateMenuWidgets() + + interfaceUpdateDeadline = uptime + interfaceUpdateInterval + end + + if uptime >= interfaceDrawDeadline then workspace:draw() - dateDeadline = computer.uptime() + userSettings.interfaceScreenUpdateInterval + uptime = computer.uptime() + interfaceDrawDeadline = uptime + interfaceDrawInterval end if userSettings.interfaceScreensaverEnabled then - if e1 then - screensaverUptime = computer.uptime() - else - if computer.uptime() >= screensaverUptime + userSettings.interfaceScreensaverDelay then - if filesystem.exists(userSettings.interfaceScreensaverPath) then - system.execute(userSettings.interfaceScreensaverPath) - workspace:draw() - end - - screensaverUptime = computer.uptime() + if not e1 and uptime >= screensaverUptime + userSettings.interfaceScreensaverDelay then + if filesystem.exists(userSettings.interfaceScreensaverPath) then + system.execute(userSettings.interfaceScreensaverPath) + workspace:draw() end + + screensaverUptime = computer.uptime() end end end