milo: UI cleanup

This commit is contained in:
kepler155c
2018-11-13 21:31:27 -05:00
parent 38777041d1
commit 8e9ca385d9
11 changed files with 77 additions and 30 deletions

View File

@@ -49,13 +49,30 @@ for _, node in pairs(config.nodes) do
end
end
local function Syntax(msg)
print([[
Turtle must be equipped with:
* Introspection module
* Workbench
Turtle must be connected to:
* Wired modem
]])
error(msg)
end
local modem = Peripheral.get('wired_modem')
if not modem or not modem.getNameLocal then
error('Wired modem is not connected')
Syntax('Wired modem missing')
end
local introspection = Peripheral.get('plethora:introspection') or
error('Introspection module not found')
Syntax('Introspection module missing')
if not device.workbench then
Syntax('Workbench missing')
end
local context = {
config = config,

View File

@@ -114,11 +114,24 @@ local page = UI.Page {
shadowText = 'Inventory slot #',
limit = 5,
validate = 'numeric',
required = true,
required = false,
},
[4] = UI.Checkbox {
formLabel = 'Shield Slot', formKey = 'useShield',
help = 'or use the shield slot for sending'
help = 'Or, use the shield slot for sending'
},
info = UI.TextArea {
x = 1, ex = -1, y = 7, ey = -3,
textColor = colors.yellow,
marginLeft = 0,
marginRight = 0,
value = [[The Milo turtle must connect to a manipulator with a ]] ..
[[bound introspection module. The neural interface must ]] ..
[[also have an introspection module.]],
},
[5] = UI.Button {
x = 1, y = -2,
text = 'Force scan', event = 'rescan', help = 'Force a scan of all inventories',
},
},
statusBar = UI.StatusBar {
@@ -252,12 +265,13 @@ function page:eventHandler(event)
UI:exitPullEvents()
elseif event.type == 'setup' then
self.setup.form:setValues(config)
self.setup:show()
elseif event.type == 'form_complete' then
Config.update('miloRemote', config)
self.setup:hide()
self:refresh()
self:refresh('list')
self.grid:draw()
elseif event.type == 'form_cancel' then
@@ -299,10 +313,16 @@ function page:eventHandler(event)
self:setStatus('nope ...')
end
elseif event.type == 'rescan' then
self:setFocus(self.statusBar.filter)
self:setStatus('rescanning ...')
self:refresh('scan')
self.grid:draw()
elseif event.type == 'refresh' then
self:setFocus(self.statusBar.filter)
self:setStatus('updating ...')
self:refresh()
self:refresh('list')
self.grid:draw()
elseif event.type == 'toggle_display' then
@@ -339,14 +359,14 @@ function page:enable()
self.setup:show()
end
Event.onTimeout(.1, function()
self:refresh()
self:refresh('list')
self.grid:draw()
self:sync()
end)
end
function page:refresh()
local items = self:sendRequest({ request = 'list' })
function page:refresh(requestType)
local items = self:sendRequest({ request = requestType })
if items then
self.items = items
@@ -366,7 +386,7 @@ Event.addRoutine(function()
local inv = config.useShield and 'getEquipment' or 'getInventory'
if not neural or not neural[inv] then
_G._debug('missing Introspection module')
elseif config.server then
elseif config.server and (config.useShield or config.slot) then
local method = neural[inv]
local item = method and method().getItemMeta(config.useShield and SHIELD_SLOT or config.slot)
if item then

View File

@@ -183,7 +183,7 @@ nodeWizard = UI.Page {
index = 1,
backgroundColor = colors.cyan,
form = UI.Form {
x = 1, y = 1, ex = -1, ey = 3,
x = 2, ex = -2, y = 1, ey = 3,
manualControls = true,
[1] = UI.TextEntry {
formLabel = 'Name', formKey = 'displayName',

View File

@@ -11,12 +11,11 @@ local monitor = context.storage:getSingleNode('activity')
--[[ Configuration Page ]]--
local template =
[[%sDisplays the amount of items entering or leaving storage%s
[[%sDisplays the amount of items entering or leaving storage.%s
Right-clicking on the activity monitor will reset the totals.
%sMilo must be restarted to activate diplay.
]]
%sMilo must be restarted to activate diplay.]]
local activityWizardPage = UI.Window {
title = 'Activity Monitor',
@@ -24,6 +23,7 @@ local activityWizardPage = UI.Window {
backgroundColor = colors.cyan,
[1] = UI.TextArea {
x = 2, ex = -2, y = 2, ey = -2,
marginRight = 0,
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
},
}

View File

@@ -2,6 +2,7 @@ local itemDB = require('itemDB')
local UI = require('ui')
local Util = require('util')
local colors = _G.colors
local device = _G.device
local exportView = UI.Window {
@@ -20,17 +21,18 @@ local exportView = UI.Window {
},
},
text = UI.Text {
x = 2, y = -2,
x = 3, y = -2,
value = 'Slot',
textColor = colors.black,
},
slots = UI.Chooser {
x = 7, y = -2,
x = 8, y = -2,
width = 7,
nochoice = 'All',
help = 'Export to this slot',
},
add = UI.Button {
x = 15, y = -2,
x = 16, y = -2,
text = '+', event = 'add_entry', help = 'Add',
},
remove = UI.Button {

View File

@@ -2,6 +2,7 @@ local itemDB = require('itemDB')
local UI = require('ui')
local Util = require('util')
local colors = _G.colors
local device = _G.device
local importView = UI.Window {
@@ -20,17 +21,18 @@ local importView = UI.Window {
},
},
text = UI.Text {
x = 2, y = -2,
x = 3, y = -2,
value = 'Slot',
textColor = colors.black,
},
slots = UI.Chooser {
x = 7, y = -2,
x = 8, y = -2,
width = 7,
nochoice = 'All',
help = 'Import from this slot',
},
add = UI.Button {
x = 15, y = -2,
x = 16, y = -2,
text = '+', event = 'add_entry', help = 'Add',
},
remove = UI.Button {

View File

@@ -14,8 +14,7 @@ local monitor = context.storage:getSingleNode('jobs')
local template =
[[%sDisplays the crafting progress%s
%sMilo must be restarted to activate diplay.
]]
%sMilo must be restarted to activate diplay.]]
local jobsWizardPage = UI.Window {
title = 'Crafting Monitor',
@@ -23,6 +22,7 @@ local jobsWizardPage = UI.Window {
backgroundColor = colors.cyan,
[1] = UI.TextArea {
x = 2, ex = -2, y = 2, ey = -2,
marginRight = 0,
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
},
}

View File

@@ -13,7 +13,7 @@ local wizardPage = UI.Window {
index = 2,
backgroundColor = colors.cyan,
form = UI.Form {
x = 1, y = 3, ex = -1, ey = -2,
x = 2, ex = -2, y = 3, ey = -2,
manualControls = true,
[1] = UI.Checkbox {
formLabel = 'Import', formKey = 'importEnder',
@@ -26,7 +26,7 @@ local wizardPage = UI.Window {
},
},
userInfo = UI.TextArea {
x = 2, ex = -2, y = 2, height = 1,
x = 3, ex = -2, y = 2, height = 2,
},
}

View File

@@ -48,7 +48,11 @@ local function client(socket)
break
end
if data.request == 'list' then
if data.request == 'scan' then -- full scan of all inventories
local items = Milo:mergeResources(Milo:listItems(true))
socket:write(items)
elseif data.request == 'list' then
local items = Milo:mergeResources(Milo:listItems())
socket:write(items)

View File

@@ -9,7 +9,7 @@ local storageView = UI.Window {
index = 2,
backgroundColor = colors.cyan,
form = UI.Form {
x = 1, y = 1, ex = -1, ey = -2,
x = 2, ex = -2, y = 1, ey = -2,
manualControls = true,
[1] = UI.TextEntry {
formLabel = 'Priority', formKey = 'priority',
@@ -28,6 +28,7 @@ local storageView = UI.Window {
[3] = UI.TextArea {
x = 12, ex = -2, y = 4,
textColor = colors.yellow,
marginRight = 0,
value = 'Only specify if you are manually taking items out of this inventory. Value should be > 10',
},
},
@@ -67,7 +68,7 @@ local lockView = UI.Window {
index = 3,
backgroundColor = colors.cyan,
form = UI.Form {
x = 1, y = 1, ex = -1, ey = 3,
x = 2, ex = -2, y = 1, ey = 3,
manualControls = true,
[1] = UI.Checkbox {
formLabel = 'Locked', formKey = 'lockWith',
@@ -79,11 +80,12 @@ local lockView = UI.Window {
},
},
grid = UI.ScrollingGrid {
x = 2, ex = -2, y = 4, ey = -2,
x = 2, ex = -2, y = 5, ey = -2,
columns = {
{ heading = 'Name', key = 'displayName' },
},
sortColumn = 'displayName',
disableHeader = true,
},
}

View File

@@ -17,7 +17,7 @@ local wizardPage = UI.Window {
value = [[ Items can be automatically dropped from this storage.]],
},
form = UI.Form {
x = 1, y = 4, ex = -1, ey = -2,
x = 2, ex = -2, y = 4, ey = -2,
manualControls = true,
[1] = UI.Checkbox {
formLabel = 'Drop', formKey = 'drop',
@@ -25,7 +25,7 @@ local wizardPage = UI.Window {
},
[2] = UI.Chooser {
width = 9,
formLabel = 'Drop direction', formKey = 'dropDirection',
formLabel = 'Direction', formKey = 'dropDirection',
nochoice = 'Down',
choices = {
{ name = 'Down', value = 'down' },