fix ui default device via args

This commit is contained in:
kepler155c@gmail.com 2019-07-20 19:29:44 -06:00 committed by xAnavrins
parent 30b7199976
commit ec7fc5bb23
1 changed files with 7 additions and 12 deletions

View File

@ -125,9 +125,9 @@ function Manager:init()
focused = true }) focused = true })
elseif ie and currentPage then elseif ie and currentPage then
--if not self.currentPage.parent.device.side then if not currentPage.parent.device.side then
self:click(currentPage, ie.code, button, x, y) self:click(currentPage, ie.code, button, x, y)
--end end
end end
end, end,
@ -158,21 +158,16 @@ function Manager:init()
end end
function Manager:configure(appName, ...) function Manager:configure(appName, ...)
local options = {
device = { arg = 'd', type = 'string',
desc = 'Device type' },
textScale = { arg = 't', type = 'number',
desc = 'Text scale' },
}
local defaults = Util.loadTable('usr/config/' .. appName) or { } local defaults = Util.loadTable('usr/config/' .. appName) or { }
if not defaults.device then if not defaults.device then
defaults.device = { } defaults.device = { }
end end
Util.getOptions(options, { ... }, true) -- starting a program: gpsServer --display=monitor_3148 --scale=.5 gps
local _, options = Util.parse(...)
local optionValues = { local optionValues = {
name = options.device.value, name = options.display,
textScale = options.textScale.value, textScale = tonumber(options.scale),
} }
Util.merge(defaults.device, optionValues) Util.merge(defaults.device, optionValues)
@ -183,7 +178,7 @@ function Manager:configure(appName, ...)
if defaults.device.name == 'terminal' then if defaults.device.name == 'terminal' then
dev = term.current() dev = term.current()
else else
dev = peripheral.wrap(defaults.device.name) dev = _G.device[defaults.device.name]
end end
if not dev then if not dev then