milo wip
This commit is contained in:
35
milo/plugins/brewingStandView.lua
Normal file
35
milo/plugins/brewingStandView.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local Ansi = require('ansi')
|
||||
local UI = require('ui')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
|
||||
local template =
|
||||
[[%sBrewing stands have the ability to automatically learn recipes.%s
|
||||
|
||||
Simply craft potions in the brewing stand as normal except for these conditions.
|
||||
1. Place item in top slot first.
|
||||
2. At least 1 bottle must be placed in the first slot.
|
||||
|
||||
When finished brewing, the recipe will be available upon refreshing.
|
||||
|
||||
Note that you do not need to import items from the brewing stand, this will be done automatically.]]
|
||||
|
||||
local brewingStandView = UI.Window {
|
||||
title = 'Storage Options',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||
},
|
||||
}
|
||||
|
||||
function brewingStandView:isValidFor(machine)
|
||||
if machine.mtype == 'machine' then
|
||||
local m = device[machine.name]
|
||||
return m and m.type == 'minecraft:brewing_stand'
|
||||
end
|
||||
end
|
||||
|
||||
UI:getPage('machineWizard').wizard:add({ brewingStand = brewingStandView })
|
||||
@@ -51,7 +51,6 @@ function exportView:setMachine(machine)
|
||||
{ name = 'All', value = '*' }
|
||||
}
|
||||
|
||||
-- TODO: what if device is dettached ?
|
||||
local m = device[machine.name]
|
||||
for k = 1, m.size() do
|
||||
table.insert(self.slots.choices, { name = k, value = k })
|
||||
|
||||
@@ -51,7 +51,6 @@ function importView:setMachine(machine)
|
||||
{ name = 'All', value = '*' }
|
||||
}
|
||||
|
||||
-- TODO: what if device is dettached ?
|
||||
local m = device[machine.name]
|
||||
for k = 1, m.size() do
|
||||
table.insert(self.slots.choices, { name = k, value = k })
|
||||
|
||||
@@ -46,14 +46,12 @@ local itemPage = UI.Page {
|
||||
formLabel = 'Ignore NBT', formKey = 'ignoreNbtHash',
|
||||
help = 'Ignore NBT of item'
|
||||
},
|
||||
--[[
|
||||
[6] = UI.Button {
|
||||
x = 2, y = -2, width = 10,
|
||||
formLabel = 'Redstone',
|
||||
event = 'show_rs',
|
||||
formLabel = 'Machine',
|
||||
event = 'select_machine',
|
||||
text = 'Configure',
|
||||
},
|
||||
]]
|
||||
infoButton = UI.Button {
|
||||
x = 2, y = -2,
|
||||
event = 'show_info',
|
||||
@@ -99,6 +97,30 @@ local itemPage = UI.Page {
|
||||
},
|
||||
},
|
||||
},
|
||||
machines = UI.SlideOut {
|
||||
backgroundColor = colors.cyan,
|
||||
titleBar = UI.TitleBar {
|
||||
title = 'Select Machine',
|
||||
previousPage = true,
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2, ey = -4,
|
||||
disableHeader = true,
|
||||
values = context.config.remoteDefaults,
|
||||
columns = {
|
||||
{ heading = 'Name', key = 'displayName'},
|
||||
},
|
||||
sortColumn = 'displayName',
|
||||
},
|
||||
button1 = UI.Button {
|
||||
x = -14, y = -2,
|
||||
text = 'Ok', event = 'set_machine',
|
||||
},
|
||||
button2 = UI.Button {
|
||||
x = -9, y = -2,
|
||||
text = 'Cancel', event = 'cancel_machine',
|
||||
},
|
||||
},
|
||||
info = UI.SlideOut {
|
||||
titleBar = UI.TitleBar {
|
||||
title = "Information",
|
||||
@@ -126,6 +148,16 @@ function itemPage:enable(item)
|
||||
self:focusFirst()
|
||||
end
|
||||
|
||||
function itemPage.machines.grid:isRowValid(_, value)
|
||||
return value.mtype == 'machine'
|
||||
end
|
||||
|
||||
function itemPage.machines.grid:getDisplayValues(row)
|
||||
row = Util.shallowCopy(row)
|
||||
row.displayName = row.displayName or row.name
|
||||
return row
|
||||
end
|
||||
|
||||
function itemPage.rsControl:enable()
|
||||
local devices = self.form[1].choices
|
||||
Util.clear(devices)
|
||||
@@ -160,6 +192,18 @@ function itemPage:eventHandler(event)
|
||||
elseif event.type == 'show_rs' then
|
||||
self.rsControl:show()
|
||||
|
||||
elseif event.type == 'select_machine' then
|
||||
self.machines.grid:update()
|
||||
self.machines.grid:setIndex(1)
|
||||
self.machines:show()
|
||||
|
||||
elseif event.type == 'set_machine' then
|
||||
--TODO save machine
|
||||
self.machines:hide()
|
||||
|
||||
elseif event.type == 'cancel_machine' then
|
||||
self.machines:hide()
|
||||
|
||||
elseif event.type == 'show_info' then
|
||||
local value =
|
||||
string.format('%s%s%s\n%s\n',
|
||||
|
||||
@@ -172,7 +172,7 @@ function listingPage:eventHandler(event)
|
||||
end
|
||||
|
||||
elseif event.type == 'refresh' then
|
||||
self:refresh()
|
||||
self:refresh(true)
|
||||
self.grid:draw()
|
||||
self.statusBar.filter:focus()
|
||||
|
||||
@@ -257,8 +257,12 @@ function listingPage:disable()
|
||||
UI.Page.disable(self)
|
||||
end
|
||||
|
||||
function listingPage:refresh()
|
||||
self.allItems = Milo:refreshItems()
|
||||
function listingPage:refresh(force)
|
||||
if force then
|
||||
self.allItems = Milo:refreshItems()
|
||||
else
|
||||
self.allItems = Milo:listItems()
|
||||
end
|
||||
Milo:mergeResources(self.allItems)
|
||||
self:applyFilter()
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ local machineLearnWizard = UI.Page {
|
||||
wizard = UI.Wizard {
|
||||
y = 2, ey = -2,
|
||||
pages = {
|
||||
machine = UI.Window {
|
||||
machines = UI.Window {
|
||||
index = 1,
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2, ey = -2,
|
||||
@@ -46,15 +46,23 @@ Example: Slot 1 is the top slot in a furnace.]],
|
||||
local pages = machineLearnWizard.wizard.pages
|
||||
local machine
|
||||
|
||||
function pages.machine.grid:getDisplayValues(row)
|
||||
function pages.machines.grid:isRowValid(_, value)
|
||||
return value.mtype == 'machine' and value.adapter and value.adapter.online
|
||||
end
|
||||
|
||||
function pages.machines.grid:getDisplayValues(row)
|
||||
row = Util.shallowCopy(row)
|
||||
row.displayName = row.displayName or row.name
|
||||
return row
|
||||
end
|
||||
|
||||
function pages.machine:validate()
|
||||
function pages.machines:enable()
|
||||
self.grid:update()
|
||||
UI.Window.enable(self)
|
||||
end
|
||||
|
||||
function pages.machines:validate()
|
||||
|
||||
-- TODO: validation should only be invoked when moving forward (i think)
|
||||
-- TODO: index number validation in wizard
|
||||
|
||||
local selected = self.grid:getSelected()
|
||||
|
||||
@@ -24,7 +24,7 @@ local storageView = UI.Window {
|
||||
},
|
||||
[3] = UI.Text {
|
||||
x = 16, ex = -2, y = 3,
|
||||
value = 'minecraft:xxxxx:0'
|
||||
value = '',
|
||||
},
|
||||
[4] = UI.Checkbox {
|
||||
formLabel = 'Void', formKey = 'voidExcess',
|
||||
@@ -32,7 +32,7 @@ local storageView = UI.Window {
|
||||
pruneEmpty = true,
|
||||
},
|
||||
[5] = UI.Checkbox {
|
||||
formLabel = 'Partition', formKey = 'voidExcess',
|
||||
formLabel = 'Partition', formKey = 'partition',
|
||||
help = 'TODO',
|
||||
pruneEmpty = true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user