wizard and tab rework
This commit is contained in:
@@ -6,7 +6,7 @@ local ccemux = _G.ccemux
|
|||||||
local sides = { 'bottom', 'top', 'back', 'front', 'right', 'left' }
|
local sides = { 'bottom', 'top', 'back', 'front', 'right', 'left' }
|
||||||
|
|
||||||
local tab = UI.Tab {
|
local tab = UI.Tab {
|
||||||
tabTitle = 'CCEmuX',
|
title = 'CCEmuX',
|
||||||
description = 'CCEmuX peripherals',
|
description = 'CCEmuX peripherals',
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 2, ey = 5,
|
x = 2, ex = -2, y = 2, ey = 5,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ local Socket = require('opus.socket')
|
|||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
local Util = require('opus.util')
|
local Util = require('opus.util')
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
local multishell = _ENV.multishell
|
local multishell = _ENV.multishell
|
||||||
local network = _G.network
|
local network = _G.network
|
||||||
@@ -31,7 +30,7 @@ local socket, turtle, page
|
|||||||
|
|
||||||
page = UI.Page {
|
page = UI.Page {
|
||||||
coords = UI.Window {
|
coords = UI.Window {
|
||||||
backgroundColor = colors.black,
|
backgroundColor = 'black',
|
||||||
height = 3,
|
height = 3,
|
||||||
marginTop = 1, marginLeft = 1,
|
marginTop = 1, marginLeft = 1,
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
@@ -50,156 +49,149 @@ page = UI.Page {
|
|||||||
},
|
},
|
||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
x = 1, y = 4, ey = -2,
|
x = 1, y = 4, ey = -2,
|
||||||
scripts = UI.ScrollingGrid {
|
UI.Tab {
|
||||||
tabTitle = 'Run',
|
title = 'Run',
|
||||||
backgroundColor = colors.cyan,
|
scripts = UI.ScrollingGrid {
|
||||||
columns = {
|
backgroundColor = 'primary',
|
||||||
{ heading = '', key = 'label' },
|
columns = {
|
||||||
|
{ heading = '', key = 'label' },
|
||||||
|
},
|
||||||
|
disableHeader = true,
|
||||||
|
sortColumn = 'label',
|
||||||
|
autospace = true,
|
||||||
|
draw = function(self)
|
||||||
|
Util.clear(self.values)
|
||||||
|
local files = fs.list(SCRIPTS_PATH)
|
||||||
|
for _,path in pairs(files) do
|
||||||
|
table.insert(self.values, { label = path, path = fs.combine(SCRIPTS_PATH, path) })
|
||||||
|
end
|
||||||
|
self:update()
|
||||||
|
UI.ScrollingGrid.draw(self)
|
||||||
|
end,
|
||||||
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'grid_select' then
|
||||||
|
page:runScript(event.selected.label)
|
||||||
|
else
|
||||||
|
return UI.ScrollingGrid.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
disableHeader = true,
|
|
||||||
sortColumn = 'label',
|
|
||||||
autospace = true,
|
|
||||||
draw = function(self)
|
|
||||||
Util.clear(self.values)
|
|
||||||
local files = fs.list(SCRIPTS_PATH)
|
|
||||||
for _,path in pairs(files) do
|
|
||||||
table.insert(self.values, { label = path, path = fs.combine(SCRIPTS_PATH, path) })
|
|
||||||
end
|
|
||||||
self:update()
|
|
||||||
UI.ScrollingGrid.draw(self)
|
|
||||||
end,
|
|
||||||
eventHandler = function(self, event)
|
|
||||||
if event.type == 'grid_select' then
|
|
||||||
page:runScript(event.selected.label)
|
|
||||||
else
|
|
||||||
return UI.ScrollingGrid.eventHandler(self, event)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
turtles = UI.ScrollingGrid {
|
UI.Tab {
|
||||||
tabTitle = 'Select',
|
title = 'Select',
|
||||||
backgroundColor = colors.cyan,
|
turtles = UI.ScrollingGrid {
|
||||||
columns = {
|
backgroundColor = 'primary',
|
||||||
{ heading = 'label', key = 'label' },
|
columns = {
|
||||||
{ heading = 'Dist', key = 'distance' },
|
{ heading = 'label', key = 'label' },
|
||||||
{ heading = 'Status', key = 'status' },
|
{ heading = 'Dist', key = 'distance' },
|
||||||
{ heading = 'Fuel', key = 'fuel' },
|
{ heading = 'Status', key = 'status' },
|
||||||
},
|
{ heading = 'Fuel', key = 'fuel' },
|
||||||
disableHeader = true,
|
},
|
||||||
sortColumn = 'label',
|
disableHeader = true,
|
||||||
autospace = true,
|
sortColumn = 'label',
|
||||||
getDisplayValues = function(_, row)
|
autospace = true,
|
||||||
row = Util.shallowCopy(row)
|
getDisplayValues = function(_, row)
|
||||||
if row.fuel then
|
row = Util.shallowCopy(row)
|
||||||
row.fuel = Util.toBytes(row.fuel)
|
if row.fuel then
|
||||||
end
|
row.fuel = Util.toBytes(row.fuel)
|
||||||
if row.distance then
|
|
||||||
row.distance = Util.round(row.distance, 1)
|
|
||||||
end
|
|
||||||
return row
|
|
||||||
end,
|
|
||||||
draw = function(self)
|
|
||||||
Util.clear(self.values)
|
|
||||||
for _,v in pairs(network) do
|
|
||||||
if v.fuel then
|
|
||||||
table.insert(self.values, v)
|
|
||||||
end
|
end
|
||||||
end
|
if row.distance then
|
||||||
self:update()
|
row.distance = Util.round(row.distance, 1)
|
||||||
UI.ScrollingGrid.draw(self)
|
|
||||||
end,
|
|
||||||
eventHandler = function(self, event)
|
|
||||||
if event.type == 'grid_select' then
|
|
||||||
turtle = event.selected
|
|
||||||
config.id = event.selected.id
|
|
||||||
Config.update('Turtles', config)
|
|
||||||
multishell.setTitle(multishell.getCurrent(), turtle.label)
|
|
||||||
if socket then
|
|
||||||
socket:close()
|
|
||||||
socket = nil
|
|
||||||
end
|
end
|
||||||
else
|
return row
|
||||||
return UI.ScrollingGrid.eventHandler(self, event)
|
end,
|
||||||
end
|
draw = function(self)
|
||||||
return true
|
Util.clear(self.values)
|
||||||
end,
|
for _,v in pairs(network) do
|
||||||
},
|
if v.fuel then
|
||||||
inventory = UI.ScrollingGrid {
|
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
tabTitle = 'Inv',
|
|
||||||
columns = {
|
|
||||||
{ heading = '', key = 'index', width = 2 },
|
|
||||||
{ heading = '', key = 'count', width = 2 },
|
|
||||||
{ heading = 'Inventory', key = 'key' },
|
|
||||||
},
|
|
||||||
disableHeader = true,
|
|
||||||
sortColumn = 'index',
|
|
||||||
getRowTextColor = function(self, row, selected)
|
|
||||||
if turtle and row.selected then
|
|
||||||
return colors.yellow
|
|
||||||
end
|
|
||||||
return UI.ScrollingGrid.getRowTextColor(self, row, selected)
|
|
||||||
end,
|
|
||||||
draw = function(self)
|
|
||||||
local t = turtle
|
|
||||||
Util.clear(self.values)
|
|
||||||
if t then
|
|
||||||
for k,v in pairs(t.inv or { }) do -- new method (less data)
|
|
||||||
local index, count = k:match('(%d+),(%d+)')
|
|
||||||
v = {
|
|
||||||
index = tonumber(index),
|
|
||||||
key = v,
|
|
||||||
count = tonumber(count),
|
|
||||||
}
|
|
||||||
table.insert(self.values, v)
|
|
||||||
end
|
|
||||||
|
|
||||||
for _,v in pairs(t.inventory or { }) do
|
|
||||||
if v.count > 0 then
|
|
||||||
table.insert(self.values, v)
|
table.insert(self.values, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:update()
|
||||||
for _,v in pairs(self.values) do
|
UI.ScrollingGrid.draw(self)
|
||||||
if v.index == t.slotIndex then
|
end,
|
||||||
v.selected = true
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'grid_select' then
|
||||||
|
turtle = event.selected
|
||||||
|
config.id = event.selected.id
|
||||||
|
Config.update('Turtles', config)
|
||||||
|
multishell.setTitle(multishell.getCurrent(), turtle.label)
|
||||||
|
if socket then
|
||||||
|
socket:close()
|
||||||
|
socket = nil
|
||||||
end
|
end
|
||||||
if v.key then
|
else
|
||||||
v.key = itemDB:getName(v.key)
|
return UI.ScrollingGrid.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
UI.Tab {
|
||||||
|
title = 'Inv',
|
||||||
|
inventory = UI.ScrollingGrid {
|
||||||
|
backgroundColor = 'primary',
|
||||||
|
columns = {
|
||||||
|
{ heading = '', key = 'index', width = 2 },
|
||||||
|
{ heading = '', key = 'count', width = 2 },
|
||||||
|
{ heading = 'Inventory', key = 'key' },
|
||||||
|
},
|
||||||
|
disableHeader = true,
|
||||||
|
sortColumn = 'index',
|
||||||
|
getRowTextColor = function(self, row, selected)
|
||||||
|
if turtle and row.selected then
|
||||||
|
return 'yellow'
|
||||||
|
end
|
||||||
|
return UI.ScrollingGrid.getRowTextColor(self, row, selected)
|
||||||
|
end,
|
||||||
|
draw = function(self)
|
||||||
|
local t = turtle
|
||||||
|
Util.clear(self.values)
|
||||||
|
if t then
|
||||||
|
for k,v in pairs(t.inv or { }) do -- new method (less data)
|
||||||
|
local index, count = k:match('(%d+),(%d+)')
|
||||||
|
v = {
|
||||||
|
index = tonumber(index),
|
||||||
|
key = v,
|
||||||
|
count = tonumber(count),
|
||||||
|
}
|
||||||
|
table.insert(self.values, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,v in pairs(t.inventory or { }) do
|
||||||
|
if v.count > 0 then
|
||||||
|
table.insert(self.values, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,v in pairs(self.values) do
|
||||||
|
if v.index == t.slotIndex then
|
||||||
|
v.selected = true
|
||||||
|
end
|
||||||
|
if v.key then
|
||||||
|
v.key = itemDB:getName(v.key)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
self:adjustWidth()
|
||||||
self:adjustWidth()
|
self:update()
|
||||||
self:update()
|
UI.ScrollingGrid.draw(self)
|
||||||
UI.ScrollingGrid.draw(self)
|
end,
|
||||||
end,
|
eventHandler = function(self, event)
|
||||||
eventHandler = function(self, event)
|
if event.type == 'grid_select' then
|
||||||
if event.type == 'grid_select' then
|
local fn = string.format('turtle.select(%d)', event.selected.index)
|
||||||
local fn = string.format('turtle.select(%d)', event.selected.index)
|
page:runFunction(fn)
|
||||||
page:runFunction(fn)
|
else
|
||||||
else
|
return UI.ScrollingGrid.eventHandler(self, event)
|
||||||
return UI.ScrollingGrid.eventHandler(self, event)
|
end
|
||||||
end
|
return true
|
||||||
return true
|
end,
|
||||||
end,
|
|
||||||
},
|
|
||||||
--[[
|
|
||||||
policy = UI.ScrollingGrid {
|
|
||||||
tabTitle = 'Mod',
|
|
||||||
backgroundColor = UI.TabBar.defaults.selectedBackgroundColor,
|
|
||||||
columns = {
|
|
||||||
{ heading = 'label', key = 'label' },
|
|
||||||
},
|
},
|
||||||
values = policies,
|
|
||||||
disableHeader = true,
|
|
||||||
sortColumn = 'label',
|
|
||||||
autospace = true,
|
|
||||||
},
|
},
|
||||||
]]
|
UI.Tab {
|
||||||
action = UI.Window {
|
title = 'Action',
|
||||||
tabTitle = 'Action',
|
backgroundColor = 'primary',
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
moveUp = UI.Button {
|
moveUp = UI.Button {
|
||||||
x = 5, y = 2,
|
x = 5, y = 2,
|
||||||
text = 'up',
|
text = 'up',
|
||||||
@@ -233,8 +225,41 @@ page = UI.Page {
|
|||||||
info = UI.TextArea {
|
info = UI.TextArea {
|
||||||
x = 15, y = 2,
|
x = 15, y = 2,
|
||||||
inactive = true,
|
inactive = true,
|
||||||
}
|
},
|
||||||
|
showBlocks = function(self)
|
||||||
|
local script = [[
|
||||||
|
local function inspect(direction)
|
||||||
|
local s,b = turtle['inspect' .. (direction or '')]()
|
||||||
|
if not s then
|
||||||
|
return 'minecraft:air:0'
|
||||||
|
end
|
||||||
|
return string.format('%s:%d', b.name, b.metadata)
|
||||||
|
end
|
||||||
|
|
||||||
|
local bu, bf, bd = inspect('Up'), inspect(), inspect('Down')
|
||||||
|
return string.format('%s\n%s\n%s', bu, bf, bd)
|
||||||
|
]]
|
||||||
|
|
||||||
|
local s, m = self:runFunction(script, true)
|
||||||
|
self.info:setText(s or m)
|
||||||
|
end,
|
||||||
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'button_press' then
|
||||||
|
if event.button.fn then
|
||||||
|
self:runFunction(event.button.fn, event.button.nowrap)
|
||||||
|
self:showBlocks()
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return UI.Tab.eventHandler(self, event)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
|
enable = function(self)
|
||||||
|
if config.tab then
|
||||||
|
self:selectTab(Util.find(self, 'title', config.tab))
|
||||||
|
end
|
||||||
|
UI.Tabs.enable(self)
|
||||||
|
end
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
values = { },
|
values = { },
|
||||||
@@ -331,24 +356,6 @@ function page:runScript(scriptName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function page:showBlocks()
|
|
||||||
local script = [[
|
|
||||||
local function inspect(direction)
|
|
||||||
local s,b = turtle['inspect' .. (direction or '')]()
|
|
||||||
if not s then
|
|
||||||
return 'minecraft:air:0'
|
|
||||||
end
|
|
||||||
return string.format('%s:%d', b.name, b.metadata)
|
|
||||||
end
|
|
||||||
|
|
||||||
local bu, bf, bd = inspect('Up'), inspect(), inspect('Down')
|
|
||||||
return string.format('%s\n%s\n%s', bu, bf, bd)
|
|
||||||
]]
|
|
||||||
|
|
||||||
local s, m = self:runFunction(script, true)
|
|
||||||
self.tabs.action.info:setText(s or m)
|
|
||||||
end
|
|
||||||
|
|
||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
UI:quit()
|
UI:quit()
|
||||||
@@ -357,13 +364,6 @@ function page:eventHandler(event)
|
|||||||
config.tab = event.button.text
|
config.tab = event.button.text
|
||||||
Config.update('Turtles', config)
|
Config.update('Turtles', config)
|
||||||
|
|
||||||
elseif event.type == 'button_press' then
|
|
||||||
if event.button.fn then
|
|
||||||
self:runFunction(event.button.fn, event.button.nowrap)
|
|
||||||
self:showBlocks()
|
|
||||||
elseif event.button.script then
|
|
||||||
self:runScript(event.button.script)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
@@ -393,9 +393,5 @@ Event.onInterval(1, function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if config.tab then
|
|
||||||
page.tabs.tabBar:selectTab(config.tab)
|
|
||||||
end
|
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:start()
|
UI:start()
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
category = "Apps",
|
category = "Apps",
|
||||||
requires = "advancedComputer",
|
requires = "advancedComputer",
|
||||||
iconExt = "\030 \031 \128\030d\159\030 \031d\140\030d\031 \155\030 \0315\140\0305\031 \155\030 \128\010\030 \031d\136\145\0315\136\145\031d\153\031 \128\0315\153\010\030 \031 \128\031d\130\140\134\0315\140\134\031 \128",
|
iconExt = "\030 \031 \128\030d\159\030 \031d\140\030d\031 \155\030 \0315\140\0305\031 \155\030 \128\010\030 \031d\136\145\0315\136\145\031d\153\031 \128\0315\153\010\030 \031 \128\031d\130\140\134\0315\140\134\031 \128",
|
||||||
run = "fileui --exec=hexedit.lua",
|
run = "fileui --exec=hexedit.lua --title=hexedit",
|
||||||
},
|
},
|
||||||
[ "fb1c39e9f4f3c2628ad173ab401a6e4e4baf783d" ] = {
|
[ "fb1c39e9f4f3c2628ad173ab401a6e4e4baf783d" ] = {
|
||||||
title = "Sounds",
|
title = "Sounds",
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ local containerText = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local containTab = UI.Tab {
|
local containTab = UI.Tab {
|
||||||
tabTitle = 'Contain',
|
title = 'Contain',
|
||||||
button = UI.Button {
|
button = UI.Button {
|
||||||
x = 2, y = 2,
|
x = 2, y = 2,
|
||||||
text = 'Set corner',
|
text = 'Set corner',
|
||||||
@@ -321,7 +321,7 @@ local containTab = UI.Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local blocksTab = UI.Tab {
|
local blocksTab = UI.Tab {
|
||||||
tabTitle = 'Blocks',
|
title = 'Blocks',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 1,
|
y = 1,
|
||||||
columns = {
|
columns = {
|
||||||
@@ -333,7 +333,7 @@ local blocksTab = UI.Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local turtlesTab = UI.Tab {
|
local turtlesTab = UI.Tab {
|
||||||
tabTitle = 'Turtles',
|
title = 'Turtles',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 1,
|
y = 1,
|
||||||
values = pool,
|
values = pool,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ local config = Config.load('lzwfs', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
local tab = UI.Tab {
|
local tab = UI.Tab {
|
||||||
tabTitle = 'Compression',
|
title = 'Compression',
|
||||||
description = 'Disk compression',
|
description = 'Disk compression',
|
||||||
[1] = UI.Window {
|
[1] = UI.Window {
|
||||||
x = 2, y = 2, ex = -2, ey = 6,
|
x = 2, y = 2, ex = -2, ey = 6,
|
||||||
|
|||||||
@@ -1,33 +1,29 @@
|
|||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local turtle = _G.turtle
|
|
||||||
|
|
||||||
local learnPage = UI.Page {
|
local learnPage = UI.Page {
|
||||||
titleBar = UI.TitleBar { title = 'Learn Recipe' },
|
titleBar = UI.TitleBar { title = 'Learn Recipe' },
|
||||||
wizard = UI.Wizard {
|
wizard = UI.Wizard {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
pages = {
|
general = UI.WizardPage {
|
||||||
general = UI.WizardPage {
|
index = 1,
|
||||||
index = 1,
|
grid = UI.ScrollingGrid {
|
||||||
grid = UI.ScrollingGrid {
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
disableHeader = true,
|
||||||
disableHeader = true,
|
columns = {
|
||||||
columns = {
|
{ heading = 'Name', key = 'name'},
|
||||||
{ heading = 'Name', key = 'name'},
|
|
||||||
},
|
|
||||||
sortColumn = 'name',
|
|
||||||
},
|
|
||||||
accelerators = {
|
|
||||||
grid_select = 'nextView',
|
|
||||||
},
|
},
|
||||||
|
sortColumn = 'name',
|
||||||
|
},
|
||||||
|
accelerators = {
|
||||||
|
grid_select = 'nextView',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
notification = UI.Notification { },
|
notification = UI.Notification { },
|
||||||
}
|
}
|
||||||
|
|
||||||
local general = learnPage.wizard.pages.general
|
local general = learnPage.wizard.general
|
||||||
|
|
||||||
function general:validate()
|
function general:validate()
|
||||||
Milo:setState('learnType', self.grid:getSelected().value)
|
Milo:setState('learnType', self.grid:getSelected().value)
|
||||||
@@ -37,7 +33,7 @@ end
|
|||||||
function learnPage:enable()
|
function learnPage:enable()
|
||||||
local t = { }
|
local t = { }
|
||||||
|
|
||||||
for _, page in pairs(self.wizard.pages) do
|
for _, page in pairs(self.wizard:getPages()) do
|
||||||
if page.validFor then
|
if page.validFor then
|
||||||
t[page.validFor] = {
|
t[page.validFor] = {
|
||||||
name = page.validFor,
|
name = page.validFor,
|
||||||
@@ -63,7 +59,7 @@ function learnPage.wizard:getPage(index)
|
|||||||
local pages = { }
|
local pages = { }
|
||||||
table.insert(pages, general)
|
table.insert(pages, general)
|
||||||
local selected = general.grid:getSelected()
|
local selected = general.grid:getSelected()
|
||||||
for _, page in pairs(self.pages) do
|
for _, page in pairs(self:getPages()) do
|
||||||
if page.validFor and (not selected or selected.value == page.validFor) then
|
if page.validFor and (not selected or selected.value == page.validFor) then
|
||||||
table.insert(pages, page)
|
table.insert(pages, page)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,6 +35,36 @@ local networkPage = UI.Page {
|
|||||||
},
|
},
|
||||||
sortColumn = 'displayName',
|
sortColumn = 'displayName',
|
||||||
help = 'Select Node',
|
help = 'Select Node',
|
||||||
|
getDisplayValues = function(_, row)
|
||||||
|
row = Util.shallowCopy(row)
|
||||||
|
local t = { row.name:match(':(.+)_(%d+)$') }
|
||||||
|
if #t ~= 2 then
|
||||||
|
t = { row.name:match('(.+)_(%d+)$') }
|
||||||
|
end
|
||||||
|
if t and #t == 2 then
|
||||||
|
row.name, row.suffix = table.unpack(t)
|
||||||
|
row.name = row.name .. '_' .. row.suffix
|
||||||
|
end
|
||||||
|
row.displayName = row.displayName or row.name
|
||||||
|
return row
|
||||||
|
end,
|
||||||
|
getRowTextColor = function(self, row, selected)
|
||||||
|
if not device[row.name] then
|
||||||
|
return colors.red
|
||||||
|
end
|
||||||
|
if row.mtype == 'ignore' then
|
||||||
|
return colors.lightGray
|
||||||
|
end
|
||||||
|
return UI.Grid.getRowTextColor(self, row, selected)
|
||||||
|
end,
|
||||||
|
sortCompare = function(self, a, b)
|
||||||
|
if self.sortColumn == 'displayName' then
|
||||||
|
local an = a.displayName or a.name
|
||||||
|
local bn = b.displayName or b.name
|
||||||
|
return an:lower() < bn:lower()
|
||||||
|
end
|
||||||
|
return UI.Grid.sortCompare(self, a, b)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
remove = UI.Button {
|
remove = UI.Button {
|
||||||
y = -2, x = -4,
|
y = -2, x = -4,
|
||||||
@@ -55,39 +85,6 @@ local networkPage = UI.Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function networkPage.grid:getDisplayValues(row)
|
|
||||||
row = Util.shallowCopy(row)
|
|
||||||
local t = { row.name:match(':(.+)_(%d+)$') }
|
|
||||||
if #t ~= 2 then
|
|
||||||
t = { row.name:match('(.+)_(%d+)$') }
|
|
||||||
end
|
|
||||||
if t and #t == 2 then
|
|
||||||
row.name, row.suffix = table.unpack(t)
|
|
||||||
row.name = row.name .. '_' .. row.suffix
|
|
||||||
end
|
|
||||||
row.displayName = row.displayName or row.name
|
|
||||||
return row
|
|
||||||
end
|
|
||||||
|
|
||||||
function networkPage.grid:getRowTextColor(row, selected)
|
|
||||||
if not device[row.name] then
|
|
||||||
return colors.red
|
|
||||||
end
|
|
||||||
if row.mtype == 'ignore' then
|
|
||||||
return colors.lightGray
|
|
||||||
end
|
|
||||||
return UI.Grid:getRowTextColor(row, selected)
|
|
||||||
end
|
|
||||||
|
|
||||||
function networkPage.grid:sortCompare(a, b)
|
|
||||||
if self.sortColumn == 'displayName' then
|
|
||||||
local an = a.displayName or a.name
|
|
||||||
local bn = b.displayName or b.name
|
|
||||||
return an:lower() < bn:lower()
|
|
||||||
end
|
|
||||||
return UI.Grid.sortCompare(self, a, b)
|
|
||||||
end
|
|
||||||
|
|
||||||
function networkPage:getList()
|
function networkPage:getList()
|
||||||
for _, v in pairs(device) do
|
for _, v in pairs(device) do
|
||||||
if not context.storage.nodes[v.name] then
|
if not context.storage.nodes[v.name] then
|
||||||
@@ -96,7 +93,7 @@ function networkPage:getList()
|
|||||||
mtype = 'ignore',
|
mtype = 'ignore',
|
||||||
category = 'ignore',
|
category = 'ignore',
|
||||||
}
|
}
|
||||||
for _, page in pairs(nodeWizard.wizard.pages) do
|
for _, page in pairs(nodeWizard.wizard:getPages()) do
|
||||||
if page.isValidType and page:isValidType(node) then
|
if page.isValidType and page:isValidType(node) then
|
||||||
context.storage.nodes[v.name] = node
|
context.storage.nodes[v.name] = node
|
||||||
break
|
break
|
||||||
@@ -191,46 +188,91 @@ nodeWizard = UI.Page {
|
|||||||
titleBar = UI.TitleBar { title = 'Configure' },
|
titleBar = UI.TitleBar { title = 'Configure' },
|
||||||
wizard = UI.Wizard {
|
wizard = UI.Wizard {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
pages = {
|
general = UI.WizardPage {
|
||||||
general = UI.WizardPage {
|
index = 1,
|
||||||
index = 1,
|
form = UI.Form {
|
||||||
form = UI.Form {
|
x = 2, ex = -2, y = 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',
|
help = 'Set a friendly name',
|
||||||
help = 'Set a friendly name',
|
limit = 64,
|
||||||
limit = 64,
|
|
||||||
},
|
|
||||||
[2] = UI.Chooser {
|
|
||||||
width = 25,
|
|
||||||
formLabel = 'Type', formKey = 'mtype',
|
|
||||||
--nochoice = 'Storage',
|
|
||||||
help = 'Select type',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
grid = UI.ScrollingGrid {
|
[2] = UI.Chooser {
|
||||||
y = 5, ey = -2, x = 2, ex = -2,
|
width = 25,
|
||||||
columns = {
|
formLabel = 'Type', formKey = 'mtype',
|
||||||
{ heading = 'Slot', key = 'slot', width = 4 },
|
--nochoice = 'Storage',
|
||||||
{ heading = 'Name', key = 'displayName', },
|
help = 'Select type',
|
||||||
{ heading = 'Qty', key = 'count' , width = 3 },
|
|
||||||
},
|
|
||||||
sortColumn = 'slot',
|
|
||||||
help = 'Contents of inventory',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
confirmation = UI.WizardPage {
|
grid = UI.ScrollingGrid {
|
||||||
title = 'Confirm changes',
|
y = 5, ey = -2, x = 2, ex = -2,
|
||||||
index = 2,
|
columns = {
|
||||||
notice = UI.TextArea {
|
{ heading = 'Slot', key = 'slot', width = 4 },
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
{ heading = 'Name', key = 'displayName', },
|
||||||
value =
|
{ heading = 'Qty', key = 'count' , width = 3 },
|
||||||
|
},
|
||||||
|
sortColumn = 'slot',
|
||||||
|
help = 'Contents of inventory',
|
||||||
|
},
|
||||||
|
getDisplayValues = function(_, row)
|
||||||
|
row = Util.shallowCopy(row)
|
||||||
|
row.displayName = itemDB:getName(row)
|
||||||
|
return row
|
||||||
|
end,
|
||||||
|
enable = function(self)
|
||||||
|
UI.WizardPage.enable(self)
|
||||||
|
self:focusFirst()
|
||||||
|
end,
|
||||||
|
isValidFor = function()
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
showInventory = function(self, node)
|
||||||
|
local inventory
|
||||||
|
|
||||||
|
if device[node.name] and device[node.name].list then
|
||||||
|
pcall(function()
|
||||||
|
inventory = device[node.name].list()
|
||||||
|
for k,v in pairs(inventory) do
|
||||||
|
v.slot = k
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.grid:setValues(inventory or { })
|
||||||
|
end,
|
||||||
|
validate = function(self)
|
||||||
|
if self.form:save() then
|
||||||
|
nodeWizard.node.category = Util.find(nodeWizard.choices, 'value', nodeWizard.node.mtype).category
|
||||||
|
|
||||||
|
nodeWizard.nodePages = { }
|
||||||
|
table.insert(nodeWizard.nodePages, nodeWizard.wizard.general)
|
||||||
|
for _, page in pairs(nodeWizard.wizard:getPages()) do
|
||||||
|
if not page.isValidFor or page:isValidFor(nodeWizard.node) then
|
||||||
|
table.insert(nodeWizard.nodePages, page)
|
||||||
|
if page.setNode then
|
||||||
|
page:setNode(nodeWizard.node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(nodeWizard.nodePages, nodeWizard.wizard.confirmation)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
confirmation = UI.WizardPage {
|
||||||
|
title = 'Confirm changes',
|
||||||
|
index = 2,
|
||||||
|
notice = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
value =
|
||||||
[[Press accept to save the changes.
|
[[Press accept to save the changes.
|
||||||
|
|
||||||
The settings will take effect immediately!]],
|
The settings will take effect immediately!]],
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
isValidFor = function()
|
||||||
|
return false
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
@@ -255,6 +297,11 @@ The settings will take effect immediately!]],
|
|||||||
accelerators = {
|
accelerators = {
|
||||||
delete = 'remove_entry',
|
delete = 'remove_entry',
|
||||||
},
|
},
|
||||||
|
getDisplayValues = function(_, row)
|
||||||
|
row = Util.shallowCopy(row)
|
||||||
|
row.displayName = itemDB:getName(row)
|
||||||
|
return row
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
remove = UI.Button {
|
remove = UI.Button {
|
||||||
x = -4, y = 4,
|
x = -4, y = 4,
|
||||||
@@ -291,143 +338,76 @@ The settings will take effect immediately!]],
|
|||||||
statusBar = UI.StatusBar {
|
statusBar = UI.StatusBar {
|
||||||
backgroundColor = 'primary',
|
backgroundColor = 'primary',
|
||||||
},
|
},
|
||||||
|
show = function(self, entry, callback, whitelistOnly)
|
||||||
|
self.entry = entry
|
||||||
|
self.callback = callback
|
||||||
|
|
||||||
|
if not self.entry.filter then
|
||||||
|
self.entry.filter = { }
|
||||||
|
end
|
||||||
|
|
||||||
|
self.form:setValues(entry)
|
||||||
|
self:resetGrid()
|
||||||
|
|
||||||
|
self.form[3].inactive = whitelistOnly
|
||||||
|
|
||||||
|
UI.SlideOut.show(self)
|
||||||
|
self:setFocus(self.form.scan)
|
||||||
|
|
||||||
|
Milo:pauseCrafting({ key = 'gridInUse', msg = 'Crafting paused' })
|
||||||
|
end,
|
||||||
|
hide = function(self)
|
||||||
|
UI.SlideOut.hide(self)
|
||||||
|
Milo:resumeCrafting({ key = 'gridInUse' })
|
||||||
|
end,
|
||||||
|
resetGrid = function(self)
|
||||||
|
local t = { }
|
||||||
|
for k in pairs(self.entry.filter) do
|
||||||
|
table.insert(t, itemDB:splitKey(k))
|
||||||
|
end
|
||||||
|
self.grid:setValues(t)
|
||||||
|
end,
|
||||||
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'focus_change' then
|
||||||
|
self.statusBar:setStatus(event.focused.help)
|
||||||
|
|
||||||
|
elseif event.type == 'scan_turtle' then
|
||||||
|
local inventory = Milo:getTurtleInventory()
|
||||||
|
for _,item in pairs(inventory) do
|
||||||
|
self.entry.filter[itemDB:makeKey(item)] = true
|
||||||
|
end
|
||||||
|
self:resetGrid()
|
||||||
|
self.grid:update()
|
||||||
|
self.grid:draw()
|
||||||
|
Milo:emptyInventory()
|
||||||
|
|
||||||
|
elseif event.type == 'remove_entry' then
|
||||||
|
local row = self.grid:getSelected()
|
||||||
|
if row then
|
||||||
|
Util.removeByValue(self.grid.values, row)
|
||||||
|
self.grid:update()
|
||||||
|
self.grid:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif event.type == 'save' then
|
||||||
|
self.form:save()
|
||||||
|
self.entry.filter = { }
|
||||||
|
for _,v in pairs(self.grid.values) do
|
||||||
|
self.entry.filter[itemDB:makeKey(v)] = true
|
||||||
|
end
|
||||||
|
self:hide()
|
||||||
|
self.callback()
|
||||||
|
|
||||||
|
elseif event.type == 'cancel' then
|
||||||
|
self:hide()
|
||||||
|
else
|
||||||
|
return UI.SlideOut.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[ Filter slide out ]] --
|
|
||||||
function nodeWizard.filter:show(entry, callback, whitelistOnly)
|
|
||||||
self.entry = entry
|
|
||||||
self.callback = callback
|
|
||||||
|
|
||||||
if not self.entry.filter then
|
|
||||||
self.entry.filter = { }
|
|
||||||
end
|
|
||||||
|
|
||||||
self.form:setValues(entry)
|
|
||||||
self:resetGrid()
|
|
||||||
|
|
||||||
self.form[3].inactive = whitelistOnly
|
|
||||||
|
|
||||||
UI.SlideOut.show(self)
|
|
||||||
self:setFocus(self.form.scan)
|
|
||||||
|
|
||||||
Milo:pauseCrafting({ key = 'gridInUse', msg = 'Crafting paused' })
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.filter:hide()
|
|
||||||
UI.SlideOut.hide(self)
|
|
||||||
Milo:resumeCrafting({ key = 'gridInUse' })
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.filter:resetGrid()
|
|
||||||
local t = { }
|
|
||||||
for k in pairs(self.entry.filter) do
|
|
||||||
table.insert(t, itemDB:splitKey(k))
|
|
||||||
end
|
|
||||||
self.grid:setValues(t)
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.filter.grid:getDisplayValues(row)
|
|
||||||
row = Util.shallowCopy(row)
|
|
||||||
row.displayName = itemDB:getName(row)
|
|
||||||
return row
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.filter:eventHandler(event)
|
|
||||||
if event.type == 'focus_change' then
|
|
||||||
self.statusBar:setStatus(event.focused.help)
|
|
||||||
|
|
||||||
elseif event.type == 'scan_turtle' then
|
|
||||||
local inventory = Milo:getTurtleInventory()
|
|
||||||
for _,item in pairs(inventory) do
|
|
||||||
self.entry.filter[itemDB:makeKey(item)] = true
|
|
||||||
end
|
|
||||||
self:resetGrid()
|
|
||||||
self.grid:update()
|
|
||||||
self.grid:draw()
|
|
||||||
Milo:emptyInventory()
|
|
||||||
|
|
||||||
elseif event.type == 'remove_entry' then
|
|
||||||
local row = self.grid:getSelected()
|
|
||||||
if row then
|
|
||||||
Util.removeByValue(self.grid.values, row)
|
|
||||||
self.grid:update()
|
|
||||||
self.grid:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif event.type == 'save' then
|
|
||||||
self.form:save()
|
|
||||||
self.entry.filter = { }
|
|
||||||
for _,v in pairs(self.grid.values) do
|
|
||||||
self.entry.filter[itemDB:makeKey(v)] = true
|
|
||||||
end
|
|
||||||
self:hide()
|
|
||||||
self.callback()
|
|
||||||
|
|
||||||
elseif event.type == 'cancel' then
|
|
||||||
self:hide()
|
|
||||||
|
|
||||||
else
|
|
||||||
return UI.SlideOut.eventHandler(self, event)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[ General Page ]] --
|
|
||||||
function nodeWizard.wizard.pages.general:enable()
|
|
||||||
UI.WizardPage.enable(self)
|
|
||||||
self:focusFirst()
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.wizard.pages.general:isValidFor()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.wizard.pages.general:showInventory(node)
|
|
||||||
local inventory
|
|
||||||
|
|
||||||
if device[node.name] and device[node.name].list then
|
|
||||||
pcall(function()
|
|
||||||
inventory = device[node.name].list()
|
|
||||||
for k,v in pairs(inventory) do
|
|
||||||
v.slot = k
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.grid:setValues(inventory or { })
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.wizard.pages.general.grid:getDisplayValues(row)
|
|
||||||
row = Util.shallowCopy(row)
|
|
||||||
row.displayName = itemDB:getName(row)
|
|
||||||
return row
|
|
||||||
end
|
|
||||||
|
|
||||||
function nodeWizard.wizard.pages.general:validate()
|
|
||||||
if self.form:save() then
|
|
||||||
nodeWizard.node.category = Util.find(nodeWizard.choices, 'value', nodeWizard.node.mtype).category
|
|
||||||
|
|
||||||
nodeWizard.nodePages = { }
|
|
||||||
table.insert(nodeWizard.nodePages, nodeWizard.wizard.pages.general)
|
|
||||||
for _, page in pairs(nodeWizard.wizard.pages) do
|
|
||||||
if not page.isValidFor or page:isValidFor(nodeWizard.node) then
|
|
||||||
table.insert(nodeWizard.nodePages, page)
|
|
||||||
if page.setNode then
|
|
||||||
page:setNode(nodeWizard.node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(nodeWizard.nodePages, nodeWizard.wizard.pages.confirmation)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[ Confirmation ]]--
|
|
||||||
function nodeWizard.wizard.pages.confirmation:isValidFor()
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[ Wizard ]] --
|
--[[ Wizard ]] --
|
||||||
function nodeWizard:enable(node)
|
function nodeWizard:enable(node)
|
||||||
local adapter = node.adapter
|
local adapter = node.adapter
|
||||||
@@ -440,7 +420,7 @@ function nodeWizard:enable(node)
|
|||||||
{ name = 'Ignore', value = 'ignore', category = 'ignore' },
|
{ name = 'Ignore', value = 'ignore', category = 'ignore' },
|
||||||
{ name = 'Hidden', value = 'hidden', category = 'ignore', help = 'Do not show in list' },
|
{ name = 'Hidden', value = 'hidden', category = 'ignore', help = 'Do not show in list' },
|
||||||
}
|
}
|
||||||
for _, page in pairs(self.wizard.pages) do
|
for _, page in pairs(self.wizard:getPages()) do
|
||||||
if page.isValidType then
|
if page.isValidType then
|
||||||
local choice = page:isValidType(self.node)
|
local choice = page:isValidType(self.node)
|
||||||
if choice and not Util.find(self.choices, 'value', choice.value) then
|
if choice and not Util.find(self.choices, 'value', choice.value) then
|
||||||
@@ -448,15 +428,15 @@ function nodeWizard:enable(node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.wizard.pages.general.form[1].shadowText = self.node.name
|
self.wizard.general.form[1].shadowText = self.node.name
|
||||||
self.wizard.pages.general.form[2].choices = self.choices
|
self.wizard.general.form[2].choices = self.choices
|
||||||
self.wizard.pages.general.form:setValues(self.node)
|
self.wizard.general.form:setValues(self.node)
|
||||||
|
|
||||||
self.wizard.pages.general:showInventory(self.node)
|
self.wizard.general:showInventory(self.node)
|
||||||
|
|
||||||
self.nodePages = { }
|
self.nodePages = { }
|
||||||
table.insert(self.nodePages, self.wizard.pages.general)
|
table.insert(self.nodePages, self.wizard.general)
|
||||||
table.insert(self.nodePages, self.wizard.pages.confirmation)
|
table.insert(self.nodePages, self.wizard.confirmation)
|
||||||
|
|
||||||
UI.Page.enable(self)
|
UI.Page.enable(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ local Ansi = require('opus.ansi')
|
|||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local infoTab = UI.Tab {
|
local infoTab = UI.Tab {
|
||||||
tabTitle = 'Info',
|
title = 'Info',
|
||||||
index = 4,
|
index = 4,
|
||||||
textArea = UI.TextArea {
|
textArea = UI.TextArea {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local colors = _G.colors
|
|||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
|
|
||||||
local machinesTab = UI.Tab {
|
local machinesTab = UI.Tab {
|
||||||
tabTitle = 'Machine',
|
title = 'Machine',
|
||||||
index = 3,
|
index = 3,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local Util = require('opus.util')
|
|||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
|
|
||||||
local manageTab = UI.Tab {
|
local manageTab = UI.Tab {
|
||||||
tabTitle = 'Manage',
|
title = 'Manage',
|
||||||
index = 1,
|
index = 1,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, ex = -1, ey = -1,
|
x = 1, ex = -1, ey = -1,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ local Milo = require('milo')
|
|||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
local recipeTab = UI.Tab {
|
local recipeTab = UI.Tab {
|
||||||
tabTitle = 'Recipe',
|
title = 'Recipe',
|
||||||
index = 2,
|
index = 2,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
x = 2, ex = -2, y = 2, ey = -4,
|
x = 2, ex = -2, y = 2, ey = -4,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local colors = _G.colors
|
|||||||
local context = Milo:getContext()
|
local context = Milo:getContext()
|
||||||
|
|
||||||
local resetTab = UI.Tab {
|
local resetTab = UI.Tab {
|
||||||
tabTitle = 'Reset',
|
title = 'Reset',
|
||||||
index = 5,
|
index = 5,
|
||||||
noFill = true,
|
noFill = true,
|
||||||
textArea = UI.TextArea {
|
textArea = UI.TextArea {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ local page = UI.Page {
|
|||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
inventory = UI.Tab {
|
inventory = UI.Tab {
|
||||||
tabTitle = 'Inventory',
|
title = 'Inventory',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
columns = {
|
columns = {
|
||||||
@@ -33,7 +33,7 @@ local page = UI.Page {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
autostore = UI.Tab {
|
autostore = UI.Tab {
|
||||||
tabTitle = 'Deposit',
|
title = 'Deposit',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2, ey = -2,
|
y = 2, ey = -2,
|
||||||
columns = {
|
columns = {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ local function createPage(node)
|
|||||||
parent = monitor,
|
parent = monitor,
|
||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
[1] = UI.Tab {
|
[1] = UI.Tab {
|
||||||
tabTitle = 'Overview',
|
title = 'Overview',
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.black,
|
||||||
noFill = true,
|
noFill = true,
|
||||||
onlineLabel = UI.Text {
|
onlineLabel = UI.Text {
|
||||||
@@ -135,14 +135,14 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
[2] = UI.Tab {
|
[2] = UI.Tab {
|
||||||
tabTitle = 'Stats',
|
title = 'Stats',
|
||||||
noFill = true,
|
noFill = true,
|
||||||
textArea = UI.TextArea {
|
textArea = UI.TextArea {
|
||||||
y = 3,
|
y = 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[3] = UI.Tab {
|
[3] = UI.Tab {
|
||||||
tabTitle = 'Storage',
|
title = 'Storage',
|
||||||
noFill = true,
|
noFill = true,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
@@ -157,7 +157,7 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
[4] = UI.Tab {
|
[4] = UI.Tab {
|
||||||
tabTitle = 'Offline',
|
title = 'Offline',
|
||||||
noFill = true,
|
noFill = true,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
@@ -168,14 +168,14 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
[5] = UI.Tab {
|
[5] = UI.Tab {
|
||||||
tabTitle = 'Activity',
|
title = 'Activity',
|
||||||
noFill = true,
|
noFill = true,
|
||||||
term = UI.Embedded {
|
term = UI.Embedded {
|
||||||
--visible = true,
|
--visible = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[6] = UI.Tab {
|
[6] = UI.Tab {
|
||||||
tabTitle = 'Tasks',
|
title = 'Tasks',
|
||||||
noFill = true,
|
noFill = true,
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
@@ -449,7 +449,7 @@ Unlocked Slots : %d of %d (%d%%)
|
|||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'tab_activate' then
|
if event.type == 'tab_activate' then
|
||||||
local state = Milo:getState('statusState') or { }
|
local state = Milo:getState('statusState') or { }
|
||||||
state[node.name] = event.activated.tabTitle
|
state[node.name] = event.activated.title
|
||||||
Milo:setState('statusState', state)
|
Milo:setState('statusState', state)
|
||||||
end
|
end
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
@@ -472,7 +472,7 @@ Unlocked Slots : %d of %d (%d%%)
|
|||||||
-- restore active tab
|
-- restore active tab
|
||||||
local tabState = Milo:getState('statusState') or { }
|
local tabState = Milo:getState('statusState') or { }
|
||||||
if tabState[node.name] then
|
if tabState[node.name] then
|
||||||
page.tabs:selectTab(Util.find(page.tabs, 'tabTitle', tabState[node.name]))
|
page.tabs:selectTab(Util.find(page.tabs, 'title', tabState[node.name]))
|
||||||
end
|
end
|
||||||
|
|
||||||
return page
|
return page
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ local config = Config.load('Sensor')
|
|||||||
local page = UI.Page {
|
local page = UI.Page {
|
||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
listing = UI.Tab {
|
listing = UI.Tab {
|
||||||
tabTitle = 'Listing',
|
title = 'Listing',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
@@ -35,7 +35,7 @@ local page = UI.Page {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
summary = UI.Tab {
|
summary = UI.Tab {
|
||||||
tabTitle = 'Summary',
|
title = 'Summary',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
@@ -256,7 +256,7 @@ function page:eventHandler(event)
|
|||||||
UI:quit()
|
UI:quit()
|
||||||
|
|
||||||
elseif event.type == 'tab_activate' then
|
elseif event.type == 'tab_activate' then
|
||||||
config.activeTab = event.activated.tabTitle
|
config.activeTab = event.activated.title
|
||||||
Config.update('Sensor', config)
|
Config.update('Sensor', config)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ function page:eventHandler(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if config.activeTab then
|
if config.activeTab then
|
||||||
page.tabs:selectTab(Util.find(page.tabs.children, 'tabTitle', config.activeTab))
|
page.tabs:selectTab(Util.find(page.tabs.children, 'title', config.activeTab))
|
||||||
end
|
end
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local config = Config.load('saver', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return UI.Tab {
|
return UI.Tab {
|
||||||
tabTitle = 'Screen Saver',
|
title = 'Screen Saver',
|
||||||
description = 'Screen saver',
|
description = 'Screen saver',
|
||||||
[1] = UI.Window {
|
[1] = UI.Window {
|
||||||
x = 2, y = 2, ex = -2, ey = 5,
|
x = 2, y = 2, ex = -2, ey = 5,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local config = Config.load('secure', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
local tab = UI.Tab {
|
local tab = UI.Tab {
|
||||||
tabTitle = 'Secure',
|
title = 'Secure',
|
||||||
description = 'Secure options',
|
description = 'Secure options',
|
||||||
[1] = UI.Window {
|
[1] = UI.Window {
|
||||||
x = 2, y = 2, ex = -2, ey = 5,
|
x = 2, y = 2, ex = -2, ey = 5,
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ function lib.recurse(fromPath, toPath, options, origin, top)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if mv then
|
if mv then
|
||||||
if fs.list(toReal)() then -- to is NOT empty
|
if fs.exists(toPath) then -- to is NOT empty
|
||||||
return nil, "cannot move '" .. fromPath .. "' to '" .. toPath .. "': Directory not empty"
|
return nil, "cannot move '" .. fromPath .. "' to '" .. toPath .. "': Directory not empty"
|
||||||
end
|
end
|
||||||
status(verbose, fromPath, toPath)
|
status(verbose, fromPath, toPath)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local os = _G.os
|
|||||||
local config = Config.load('shop')
|
local config = Config.load('shop')
|
||||||
|
|
||||||
local shopTab = UI.Tab {
|
local shopTab = UI.Tab {
|
||||||
tabTitle = 'Store',
|
title = 'Store',
|
||||||
index = 2,
|
index = 2,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 2, ex = -2, y = 2, ey = -2,
|
x = 2, ex = -2, y = 2, ey = -2,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ if turtle then
|
|||||||
local config = Config.load('gps')
|
local config = Config.load('gps')
|
||||||
|
|
||||||
local gpsTab = UI.Tab {
|
local gpsTab = UI.Tab {
|
||||||
tabTitle = 'Home',
|
title = 'Home',
|
||||||
description = 'Turtle home location',
|
description = 'Turtle home location',
|
||||||
labelText = UI.Text {
|
labelText = UI.Text {
|
||||||
x = 3, ex = -3, y = 2,
|
x = 3, ex = -3, y = 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user