farmer autorefuel

This commit is contained in:
kepler155c@gmail.com
2019-01-01 21:15:58 -05:00
parent 96fc44473d
commit 89b6f15785
2 changed files with 41 additions and 18 deletions

View File

@@ -24,7 +24,7 @@ local page = UI.Page {
y = 2,
inventory = UI.Window {
tabTitle = 'Inventory',
grid = UI.Grid {
grid = UI.ScrollingGrid {
y = 2, ey = -2,
columns = {
{ heading = 'Name', key = 'displayName' },
@@ -34,7 +34,7 @@ local page = UI.Page {
},
autostore = UI.Window {
tabTitle = 'Sending',
grid = UI.Grid {
grid = UI.ScrollingGrid {
y = 2, ey = -2,
columns = {
{ heading = 'Name', key = 'displayName' },
@@ -73,21 +73,7 @@ function page.tabs.inventory.grid:getRowTextColor(row)
if context.state.autostore[row.key] then
return colors.yellow
end
return UI.Grid.getRowTextColor(self, row)
end
function page.tabs.autostore:enable()
local list = { }
for key in pairs(context.state.autostore or { }) do
local cItem = itemDB:get(key)
if cItem then
table.insert(list, cItem)
end
end
self.grid:setValues(list)
return UI.Window.enable(self)
return UI.ScrollingGrid.getRowTextColor(self, row)
end
function page.tabs.inventory:eventHandler(event)
@@ -104,6 +90,20 @@ function page.tabs.inventory:eventHandler(event)
end
end
function page.tabs.autostore:enable()
local list = { }
for key in pairs(context.state.autostore or { }) do
local cItem = itemDB:get(key)
if cItem then
table.insert(list, cItem)
end
end
self.grid:setValues(list)
return UI.Window.enable(self)
end
function page.tabs.autostore:eventHandler(event)
if event.type == 'grid_select' then
local key = itemDB:makeKey(event.selected)