diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index 2d303c1..666ddac 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -2425,6 +2425,7 @@ function UI.Wizard:eventHandler(event) end -- a new current view current:enable() + current:emit({ type = 'view_enabled', view = current }) self:draw() end end diff --git a/sys/apps/Help.lua b/sys/apps/Help.lua index c4b0c9f..cdb5de7 100644 --- a/sys/apps/Help.lua +++ b/sys/apps/Help.lua @@ -1,5 +1,3 @@ -_G.requireInjector(_ENV) - local UI = require('ui') local Util = require('util') diff --git a/sys/apps/Welcome.lua b/sys/apps/Welcome.lua new file mode 100644 index 0000000..737a999 --- /dev/null +++ b/sys/apps/Welcome.lua @@ -0,0 +1,127 @@ +local Ansi = require('ansi') +local Security = require('security') +local SHA1 = require('sha1') +local UI = require('ui') + +local colors = _G.colors +local os = _G.os +local shell = _ENV.shell + +local splashIntro = [[First Time Setup + +%sThanks for installing Opus OS. The next screens will prompt you for basic settings for this computer.]] +local labelIntro = [[Set a friendly name for this computer. + +%sNo spaces recommended.]] +local passwordIntro = [[A password is required for wireless access. + +%sLeave blank to skip.]] +local packagesIntro = [[Setup Complete + +%sOpen the package manager to add software to this computer.]] + +local page = UI.Page { + wizard = UI.Wizard { + ey = -2, + pages = { + splash = UI.Window { + index = 1, + intro = UI.TextArea { + textColor = colors.yellow, + inactive = true, + x = 3, ex = -3, y = 2, ey = -2, + value = string.format(splashIntro, Ansi.white), + }, + }, + label = UI.Window { + index = 2, + labelText = UI.Text { + x = 3, y = 2, + value = 'Label' + }, + label = UI.TextEntry { + x = 9, y = 2, ex = -3, + limit = 32, + value = os.getComputerLabel(), + }, + intro = UI.TextArea { + textColor = colors.yellow, + inactive = true, + x = 3, ex = -3, y = 4, ey = -3, + value = string.format(labelIntro, Ansi.white), + }, + }, + password = UI.Window { + index = 3, + labelText = UI.Text { + x = 3, y = 2, + value = 'Password' + }, + newPass = UI.TextEntry { + x = 12, ex = -3, y = 2, + limit = 32, + mask = true, + shadowText = 'password', + accelerators = { + enter = 'new_password', + }, + }, + intro = UI.TextArea { + textColor = colors.yellow, + inactive = true, + x = 3, ex = -3, y = 4, ey = -3, + value = string.format(passwordIntro, Ansi.white), + }, + }, + packages = UI.Window { + index = 4, + button = UI.Button { + x = 3, y = -3, + text = 'Open Package Manager', + event = 'packages', + }, + intro = UI.TextArea { + textColor = colors.yellow, + inactive = true, + x = 3, ex = -3, y = 2, ey = -3, + value = string.format(packagesIntro, Ansi.white), + }, + }, + }, + }, + notification = UI.Notification { }, +} + +function page.wizard.pages.label:validate() + os.setComputerLabel(self.label.value) + return true +end + +function page.wizard.pages.password:validate() + if #self.newPass.value > 0 then + Security.updatePassword(SHA1.sha1(self.newPass.value)) + end + return true +end + +function page:eventHandler(event) + if event.type == 'skip' then + self.wizard:emit({ type = 'nextView' }) + + elseif event.type == 'view_enabled' then + event.view:focusFirst() + + elseif event.type == 'packages' then + shell.openForegroundTab('PackageManager') + + elseif event.type == 'wizard_complete' or event.type == 'cancel' then + UI.exitPullEvents() + + else + return UI.Page.eventHandler(self, event) + end + return true +end + +UI:setPage(page) +UI:pullEvents() diff --git a/sys/autorun/welcome.lua b/sys/autorun/welcome.lua new file mode 100644 index 0000000..c94e177 --- /dev/null +++ b/sys/autorun/welcome.lua @@ -0,0 +1,11 @@ +local Config = require('config') + +local shell = _ENV.shell + +local config = Config.load('os') +if not config.welcomed then + config.welcomed = true + Config.update('os', config) + + shell.openForegroundTab('Welcome') +end diff --git a/sys/boot/kiosk.boot b/sys/boot/kiosk.boot index ce76342..ea36162 100644 --- a/sys/boot/kiosk.boot +++ b/sys/boot/kiosk.boot @@ -4,9 +4,15 @@ local peripheral = _G.peripheral local settings = _G.settings local term = _G.term -local preferred = settings.get('kiosk.monitor') -local mon = preferred and peripheral.wrap(preferred) or - peripheral.find('monitor') +local name = settings.get('kiosk.monitor') + +if not name then + peripheral.find('monitor', function(s) + name = s + end) +end + +local mon = name and peripheral.wrap(name) if mon then term.redirect(mon) @@ -19,9 +25,9 @@ if mon then function() while true do - local event, _, x, y = os.pullEventRaw('monitor_touch') + local event, side, x, y = os.pullEventRaw('monitor_touch') - if event == 'monitor_touch' then + if event == 'monitor_touch' and side == name then os.queueEvent('mouse_click', 1, x, y) os.queueEvent('mouse_up', 1, x, y) end diff --git a/sys/extensions/6.tl3.lua b/sys/extensions/6.tl3.lua index 7660732..a134e78 100644 --- a/sys/extensions/6.tl3.lua +++ b/sys/extensions/6.tl3.lua @@ -218,7 +218,6 @@ function turtle.setAttackPolicy(policy) state.attackPolicy = policy end -- [[ Place ]] -- local function _place(action, indexOrId) - local slot if indexOrId then @@ -356,7 +355,7 @@ end if type(turtle.getFuelLevel()) ~= 'number' then -- Support unlimited fuel function turtle.getFuelLevel() - return 10000000 + return 100000 end end