From 4b229b868ed2dd413fe3aff33b251ff2fbc14d78 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sun, 2 Dec 2018 13:16:00 -0500 Subject: [PATCH] milo: text scaling + manipulator fixes --- milo/apis/storage.lua | 5 +++++ milo/plugins/activityView.lua | 37 +++++++++++++++++++++++++++-------- milo/plugins/jobMonitor.lua | 26 ++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/milo/apis/storage.lua b/milo/apis/storage.lua index 603079f..0d8b8a7 100644 --- a/milo/apis/storage.lua +++ b/milo/apis/storage.lua @@ -21,6 +21,11 @@ function Storage:init(nodes) Event.on({ 'device_attach', 'device_detach' }, function(e, dev) _G._debug('%s: %s', e, tostring(dev)) + if e == 'device_detach' then + if self.nodes[dev] then + self.nodes[dev].adapter = nil + end + end self:initStorage() end) Event.onInterval(15, function() diff --git a/milo/plugins/activityView.lua b/milo/plugins/activityView.lua index 50e6341..31c0f66 100644 --- a/milo/plugins/activityView.lua +++ b/milo/plugins/activityView.lua @@ -11,22 +11,42 @@ local device = _G.device --[[ Configuration Page ]]-- local template = [[%sDisplays the amount of items entering or leaving storage.%s - Right-clicking on the activity monitor will reset the totals.]] -local activityWizardPage = UI.Window { +local wizardPage = UI.Window { title = 'Activity Monitor', index = 2, backgroundColor = colors.cyan, [1] = UI.TextArea { - x = 2, ex = -2, y = 2, ey = -2, + x = 2, ex = -2, y = 2, ey = 6, marginRight = 0, value = string.format(template, Ansi.yellow, Ansi.reset), }, - timestamp = os.clock(), + form = UI.Form { + x = 2, ex = -2, y = 7, ey = -2, + manualControls = true, + [1] = UI.Chooser { + width = 9, + formLabel = 'Font Size', formKey = 'textScale', + nochoice = 'Small', + choices = { + { name = 'Small', value = .5, help = '(requires restart)', }, + { name = 'Large', value = 1, help = '(requires restart)', }, + }, + help = 'Adjust text scaling (requires restart)', + }, + }, } -function activityWizardPage:isValidType(node) +function wizardPage:setNode(node) + self.form:setValues(node) +end + +function wizardPage:validate() + return self.form:save() +end + +function wizardPage:isValidType(node) local m = device[node.name] return m and m.type == 'monitor' and { name = 'Activity Monitor', @@ -36,18 +56,18 @@ function activityWizardPage:isValidType(node) } end -function activityWizardPage:isValidFor(node) +function wizardPage:isValidFor(node) return node.mtype == 'activity' end -UI:getPage('nodeWizard').wizard:add({ activity = activityWizardPage }) +UI:getPage('nodeWizard').wizard:add({ activity = wizardPage }) --[[ Display ]]-- local function createPage(node) local page = UI.Window { parent = UI.Device { device = node.adapter, - textScale = .5, + textScale = node.textScale or .5, }, grid = UI.Grid { columns = { @@ -58,6 +78,7 @@ local function createPage(node) }, sortColumn = 'displayName', }, + timestamp = os.clock(), } function page.grid:getRowTextColor(row, selected) diff --git a/milo/plugins/jobMonitor.lua b/milo/plugins/jobMonitor.lua index 378102a..a73c9c8 100644 --- a/milo/plugins/jobMonitor.lua +++ b/milo/plugins/jobMonitor.lua @@ -15,13 +15,35 @@ local wizardPage = UI.Window { index = 2, backgroundColor = colors.cyan, [1] = UI.TextArea { - x = 2, ex = -2, y = 2, ey = -2, + x = 2, ex = -2, y = 2, ey = 3, marginRight = 0, textColor = colors.yellow, value = 'Displays the crafting progress.' }, + form = UI.Form { + x = 2, ex = -2, y = 4, ey = -2, + manualControls = true, + [1] = UI.Chooser { + width = 9, + formLabel = 'Font Size', formKey = 'textScale', + nochoice = 'Small', + choices = { + { name = 'Small', value = .5, help = '(requires restart)', }, + { name = 'Large', value = 1, help = '(requires restart)', }, + }, + help = 'Adjust text scaling (requires restart)', + }, + }, } +function wizardPage:setNode(node) + self.form:setValues(node) +end + +function wizardPage:validate() + return self.form:save() +end + function wizardPage:isValidType(node) local m = device[node.name] return m and m.type == 'monitor' and { @@ -44,7 +66,7 @@ local function createPage(node) local page = UI.Page { parent = UI.Device { device = node.adapter, - textScale = .5, + textScale = node.textScale or .5, }, grid = UI.Grid { sortColumn = 'index',