milo: UI cleanup
This commit is contained in:
@@ -49,13 +49,30 @@ for _, node in pairs(config.nodes) do
|
|||||||
end
|
end
|
||||||
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')
|
local modem = Peripheral.get('wired_modem')
|
||||||
if not modem or not modem.getNameLocal then
|
if not modem or not modem.getNameLocal then
|
||||||
error('Wired modem is not connected')
|
Syntax('Wired modem missing')
|
||||||
end
|
end
|
||||||
|
|
||||||
local introspection = Peripheral.get('plethora:introspection') or
|
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 = {
|
local context = {
|
||||||
config = config,
|
config = config,
|
||||||
|
|||||||
@@ -114,11 +114,24 @@ local page = UI.Page {
|
|||||||
shadowText = 'Inventory slot #',
|
shadowText = 'Inventory slot #',
|
||||||
limit = 5,
|
limit = 5,
|
||||||
validate = 'numeric',
|
validate = 'numeric',
|
||||||
required = true,
|
required = false,
|
||||||
},
|
},
|
||||||
[4] = UI.Checkbox {
|
[4] = UI.Checkbox {
|
||||||
formLabel = 'Shield Slot', formKey = 'useShield',
|
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 {
|
statusBar = UI.StatusBar {
|
||||||
@@ -252,12 +265,13 @@ function page:eventHandler(event)
|
|||||||
UI:exitPullEvents()
|
UI:exitPullEvents()
|
||||||
|
|
||||||
elseif event.type == 'setup' then
|
elseif event.type == 'setup' then
|
||||||
|
self.setup.form:setValues(config)
|
||||||
self.setup:show()
|
self.setup:show()
|
||||||
|
|
||||||
elseif event.type == 'form_complete' then
|
elseif event.type == 'form_complete' then
|
||||||
Config.update('miloRemote', config)
|
Config.update('miloRemote', config)
|
||||||
self.setup:hide()
|
self.setup:hide()
|
||||||
self:refresh()
|
self:refresh('list')
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
|
|
||||||
elseif event.type == 'form_cancel' then
|
elseif event.type == 'form_cancel' then
|
||||||
@@ -299,10 +313,16 @@ function page:eventHandler(event)
|
|||||||
self:setStatus('nope ...')
|
self:setStatus('nope ...')
|
||||||
end
|
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
|
elseif event.type == 'refresh' then
|
||||||
self:setFocus(self.statusBar.filter)
|
self:setFocus(self.statusBar.filter)
|
||||||
self:setStatus('updating ...')
|
self:setStatus('updating ...')
|
||||||
self:refresh()
|
self:refresh('list')
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
|
|
||||||
elseif event.type == 'toggle_display' then
|
elseif event.type == 'toggle_display' then
|
||||||
@@ -339,14 +359,14 @@ function page:enable()
|
|||||||
self.setup:show()
|
self.setup:show()
|
||||||
end
|
end
|
||||||
Event.onTimeout(.1, function()
|
Event.onTimeout(.1, function()
|
||||||
self:refresh()
|
self:refresh('list')
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
self:sync()
|
self:sync()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function page:refresh()
|
function page:refresh(requestType)
|
||||||
local items = self:sendRequest({ request = 'list' })
|
local items = self:sendRequest({ request = requestType })
|
||||||
|
|
||||||
if items then
|
if items then
|
||||||
self.items = items
|
self.items = items
|
||||||
@@ -366,7 +386,7 @@ Event.addRoutine(function()
|
|||||||
local inv = config.useShield and 'getEquipment' or 'getInventory'
|
local inv = config.useShield and 'getEquipment' or 'getInventory'
|
||||||
if not neural or not neural[inv] then
|
if not neural or not neural[inv] then
|
||||||
_G._debug('missing Introspection module')
|
_G._debug('missing Introspection module')
|
||||||
elseif config.server then
|
elseif config.server and (config.useShield or config.slot) then
|
||||||
local method = neural[inv]
|
local method = neural[inv]
|
||||||
local item = method and method().getItemMeta(config.useShield and SHIELD_SLOT or config.slot)
|
local item = method and method().getItemMeta(config.useShield and SHIELD_SLOT or config.slot)
|
||||||
if item then
|
if item then
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ nodeWizard = UI.Page {
|
|||||||
index = 1,
|
index = 1,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, y = 1, ex = -1, ey = 3,
|
x = 2, ex = -2, y = 1, ey = 3,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.TextEntry {
|
[1] = UI.TextEntry {
|
||||||
formLabel = 'Name', formKey = 'displayName',
|
formLabel = 'Name', formKey = 'displayName',
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ local monitor = context.storage:getSingleNode('activity')
|
|||||||
|
|
||||||
--[[ Configuration Page ]]--
|
--[[ Configuration Page ]]--
|
||||||
local template =
|
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.
|
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 {
|
local activityWizardPage = UI.Window {
|
||||||
title = 'Activity Monitor',
|
title = 'Activity Monitor',
|
||||||
@@ -24,6 +23,7 @@ local activityWizardPage = UI.Window {
|
|||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
marginRight = 0,
|
||||||
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
|
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local itemDB = require('itemDB')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
|
|
||||||
local exportView = UI.Window {
|
local exportView = UI.Window {
|
||||||
@@ -20,17 +21,18 @@ local exportView = UI.Window {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
text = UI.Text {
|
text = UI.Text {
|
||||||
x = 2, y = -2,
|
x = 3, y = -2,
|
||||||
value = 'Slot',
|
value = 'Slot',
|
||||||
|
textColor = colors.black,
|
||||||
},
|
},
|
||||||
slots = UI.Chooser {
|
slots = UI.Chooser {
|
||||||
x = 7, y = -2,
|
x = 8, y = -2,
|
||||||
width = 7,
|
width = 7,
|
||||||
nochoice = 'All',
|
nochoice = 'All',
|
||||||
help = 'Export to this slot',
|
help = 'Export to this slot',
|
||||||
},
|
},
|
||||||
add = UI.Button {
|
add = UI.Button {
|
||||||
x = 15, y = -2,
|
x = 16, y = -2,
|
||||||
text = '+', event = 'add_entry', help = 'Add',
|
text = '+', event = 'add_entry', help = 'Add',
|
||||||
},
|
},
|
||||||
remove = UI.Button {
|
remove = UI.Button {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local itemDB = require('itemDB')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
|
|
||||||
local importView = UI.Window {
|
local importView = UI.Window {
|
||||||
@@ -20,17 +21,18 @@ local importView = UI.Window {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
text = UI.Text {
|
text = UI.Text {
|
||||||
x = 2, y = -2,
|
x = 3, y = -2,
|
||||||
value = 'Slot',
|
value = 'Slot',
|
||||||
|
textColor = colors.black,
|
||||||
},
|
},
|
||||||
slots = UI.Chooser {
|
slots = UI.Chooser {
|
||||||
x = 7, y = -2,
|
x = 8, y = -2,
|
||||||
width = 7,
|
width = 7,
|
||||||
nochoice = 'All',
|
nochoice = 'All',
|
||||||
help = 'Import from this slot',
|
help = 'Import from this slot',
|
||||||
},
|
},
|
||||||
add = UI.Button {
|
add = UI.Button {
|
||||||
x = 15, y = -2,
|
x = 16, y = -2,
|
||||||
text = '+', event = 'add_entry', help = 'Add',
|
text = '+', event = 'add_entry', help = 'Add',
|
||||||
},
|
},
|
||||||
remove = UI.Button {
|
remove = UI.Button {
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ local monitor = context.storage:getSingleNode('jobs')
|
|||||||
local template =
|
local template =
|
||||||
[[%sDisplays the crafting progress%s
|
[[%sDisplays the crafting progress%s
|
||||||
|
|
||||||
%sMilo must be restarted to activate diplay.
|
%sMilo must be restarted to activate diplay.]]
|
||||||
]]
|
|
||||||
|
|
||||||
local jobsWizardPage = UI.Window {
|
local jobsWizardPage = UI.Window {
|
||||||
title = 'Crafting Monitor',
|
title = 'Crafting Monitor',
|
||||||
@@ -23,6 +22,7 @@ local jobsWizardPage = UI.Window {
|
|||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
[1] = UI.TextArea {
|
[1] = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
marginRight = 0,
|
||||||
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
|
value = string.format(template, Ansi.yellow, Ansi.reset, Ansi.orange),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local wizardPage = UI.Window {
|
|||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, y = 3, ex = -1, ey = -2,
|
x = 2, ex = -2, y = 3, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.Checkbox {
|
[1] = UI.Checkbox {
|
||||||
formLabel = 'Import', formKey = 'importEnder',
|
formLabel = 'Import', formKey = 'importEnder',
|
||||||
@@ -26,7 +26,7 @@ local wizardPage = UI.Window {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
userInfo = UI.TextArea {
|
userInfo = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, height = 1,
|
x = 3, ex = -2, y = 2, height = 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ local function client(socket)
|
|||||||
break
|
break
|
||||||
end
|
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())
|
local items = Milo:mergeResources(Milo:listItems())
|
||||||
socket:write(items)
|
socket:write(items)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ local storageView = UI.Window {
|
|||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, y = 1, ex = -1, ey = -2,
|
x = 2, ex = -2, y = 1, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.TextEntry {
|
[1] = UI.TextEntry {
|
||||||
formLabel = 'Priority', formKey = 'priority',
|
formLabel = 'Priority', formKey = 'priority',
|
||||||
@@ -28,6 +28,7 @@ local storageView = UI.Window {
|
|||||||
[3] = UI.TextArea {
|
[3] = UI.TextArea {
|
||||||
x = 12, ex = -2, y = 4,
|
x = 12, ex = -2, y = 4,
|
||||||
textColor = colors.yellow,
|
textColor = colors.yellow,
|
||||||
|
marginRight = 0,
|
||||||
value = 'Only specify if you are manually taking items out of this inventory. Value should be > 10',
|
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,
|
index = 3,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, y = 1, ex = -1, ey = 3,
|
x = 2, ex = -2, y = 1, ey = 3,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.Checkbox {
|
[1] = UI.Checkbox {
|
||||||
formLabel = 'Locked', formKey = 'lockWith',
|
formLabel = 'Locked', formKey = 'lockWith',
|
||||||
@@ -79,11 +80,12 @@ local lockView = UI.Window {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
x = 2, ex = -2, y = 4, ey = -2,
|
x = 2, ex = -2, y = 5, ey = -2,
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
},
|
},
|
||||||
sortColumn = 'displayName',
|
sortColumn = 'displayName',
|
||||||
|
disableHeader = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ local wizardPage = UI.Window {
|
|||||||
value = [[ Items can be automatically dropped from this storage.]],
|
value = [[ Items can be automatically dropped from this storage.]],
|
||||||
},
|
},
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, y = 4, ex = -1, ey = -2,
|
x = 2, ex = -2, y = 4, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.Checkbox {
|
[1] = UI.Checkbox {
|
||||||
formLabel = 'Drop', formKey = 'drop',
|
formLabel = 'Drop', formKey = 'drop',
|
||||||
@@ -25,7 +25,7 @@ local wizardPage = UI.Window {
|
|||||||
},
|
},
|
||||||
[2] = UI.Chooser {
|
[2] = UI.Chooser {
|
||||||
width = 9,
|
width = 9,
|
||||||
formLabel = 'Drop direction', formKey = 'dropDirection',
|
formLabel = 'Direction', formKey = 'dropDirection',
|
||||||
nochoice = 'Down',
|
nochoice = 'Down',
|
||||||
choices = {
|
choices = {
|
||||||
{ name = 'Down', value = 'down' },
|
{ name = 'Down', value = 'down' },
|
||||||
|
|||||||
Reference in New Issue
Block a user