Ui enhancements 2.0 (#29)
* canvas overhaul * editor 2.0 * more tweaks * more editor work * completions + refactor * cleanup + editor additions * cleanup + undo overhaul * editor recent/peripherals/redo + cleanup * editor path issues * cleanup * changes for deprecated ui methods - recolor milo - make turtle scripts run again - mob rancher improvements * can now use named colors
This commit was merged in pull request #29.
This commit is contained in:
@@ -216,7 +216,7 @@ _G._syslog = function(...)
|
||||
end
|
||||
|
||||
local s, m = pcall(function()
|
||||
UI:pullEvents()
|
||||
UI:start()
|
||||
end)
|
||||
|
||||
turtle.setStatus('idle')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local Config = require('opus.config')
|
||||
local Event = require('opus.event')
|
||||
local fuzzy = require('milo.fuzzyMatch')
|
||||
local fuzzy = require('opus.fuzzy')
|
||||
local Sound = require('opus.sound')
|
||||
local Socket = require('opus.socket')
|
||||
local sync = require('opus.sync').sync
|
||||
@@ -63,8 +63,8 @@ local page = UI.Page {
|
||||
x = 1, ex = -13,
|
||||
limit = 50,
|
||||
shadowText = 'filter',
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundFocusColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
backgroundFocusColor = 'primary',
|
||||
accelerators = {
|
||||
[ 'enter' ] = 'eject',
|
||||
[ 'up' ] = 'grid_up',
|
||||
@@ -169,7 +169,7 @@ end
|
||||
|
||||
function page:eventHandler(event)
|
||||
if event.type == 'quit' then
|
||||
UI:exitPullEvents()
|
||||
UI:quit()
|
||||
|
||||
elseif event.type == 'setup' then
|
||||
self.setup.form:setValues(context.state)
|
||||
@@ -517,14 +517,14 @@ local function loadDirectory(dir)
|
||||
})
|
||||
end
|
||||
end
|
||||
page.menuBar.config:add({ dropmenu = UI.DropMenu { buttons = dropdown } })
|
||||
page.menuBar.config.dropdown = dropdown
|
||||
end
|
||||
|
||||
local programDir = fs.getDir(shell.getRunningProgram())
|
||||
loadDirectory(fs.combine(programDir, 'plugins/remote'))
|
||||
|
||||
UI:setPage(page)
|
||||
UI:pullEvents()
|
||||
UI:start()
|
||||
|
||||
if context.socket then
|
||||
context.socket:close()
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
-- Based on Squid's fuzzy search
|
||||
-- https://github.com/SquidDev-CC/artist/blob/vnext/artist/lib/match.lua
|
||||
--
|
||||
-- not very fuzzy anymore
|
||||
|
||||
local SCORE_WEIGHT = 1000
|
||||
local LEADING_LETTER_PENALTY = -3
|
||||
local LEADING_LETTER_PENALTY_MAX = -9
|
||||
|
||||
local _find = string.find
|
||||
local _max = math.max
|
||||
|
||||
return function(str, pattern)
|
||||
local start = _find(str, pattern, 1, true)
|
||||
if start then
|
||||
-- All letters before the current one are considered leading, so add them to our penalty
|
||||
return SCORE_WEIGHT + _max(LEADING_LETTER_PENALTY * (start - 1), LEADING_LETTER_PENALTY_MAX)
|
||||
end
|
||||
end
|
||||
@@ -1,53 +0,0 @@
|
||||
local class = require('opus.class')
|
||||
local itemDB = require('core.itemDB')
|
||||
local Mini = require('milo.miniAdapter')
|
||||
|
||||
local os = _G.os
|
||||
|
||||
local Adapter = class(Mini)
|
||||
|
||||
function Adapter:init(args)
|
||||
Mini.init(self, args)
|
||||
|
||||
self._rawList = self.list
|
||||
|
||||
function self.list()
|
||||
-- wait for up to 1 sec until any items that have been inserted
|
||||
-- into interface are added to the system
|
||||
for _ = 0, 20 do
|
||||
if #self._rawList() == 0 then
|
||||
break
|
||||
end
|
||||
os.sleep(0)
|
||||
end
|
||||
|
||||
local list = { }
|
||||
for _, v in pairs(self.listAvailableItems()) do
|
||||
list[itemDB:makeKey(v)] = v
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
function self.getItemMeta(key)
|
||||
local item = self.findItem(itemDB:splitKey(key))
|
||||
if item and item.getMetadata then
|
||||
return item.getMetadata()
|
||||
end
|
||||
end
|
||||
|
||||
function self.pushItems(target, key, amount, slot)
|
||||
local item = self.findItem(itemDB:splitKey(key))
|
||||
if item and item.export then
|
||||
return item.export(target, amount, slot)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function self.pullItems(target, key, amount, slot)
|
||||
_G._syslog({target, key, amount, slot })
|
||||
return 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return Adapter
|
||||
@@ -1,6 +1,6 @@
|
||||
local Craft = require('milo.craft2')
|
||||
local Event = require('opus.event')
|
||||
local fuzzy = require('milo.fuzzyMatch')
|
||||
local fuzzy = require('opus.fuzzy')
|
||||
local Milo = require('milo')
|
||||
local Sound = require('opus.sound')
|
||||
local UI = require('opus.ui')
|
||||
@@ -54,8 +54,8 @@ local page = UI.Page {
|
||||
limit = 50,
|
||||
shadowText = 'filter',
|
||||
shadowTextColor = colors.gray,
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundFocusColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
backgroundFocusColor = 'primary',
|
||||
accelerators = {
|
||||
[ 'enter' ] = 'eject',
|
||||
[ 'up' ] = 'grid_up',
|
||||
@@ -66,7 +66,7 @@ local page = UI.Page {
|
||||
storageStatus = UI.Text {
|
||||
x = -17, ex = -10,
|
||||
textColor = colors.lime,
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
value = '',
|
||||
},
|
||||
amount = UI.TextEntry {
|
||||
@@ -208,7 +208,7 @@ end
|
||||
|
||||
function page:eventHandler(event)
|
||||
if event.type == 'quit' then
|
||||
UI:exitPullEvents()
|
||||
UI:quit()
|
||||
|
||||
elseif event.type == 'eject' or event.type == 'grid_select' then
|
||||
self:eject(1)
|
||||
|
||||
@@ -7,7 +7,6 @@ local Util = require('opus.util')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
local turtle = _G.turtle
|
||||
|
||||
local context = Milo:getContext()
|
||||
|
||||
@@ -22,8 +21,8 @@ local networkPage = UI.Page {
|
||||
y = -2, x = 1, ex = -9,
|
||||
limit = 50,
|
||||
shadowText = 'filter',
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundFocusColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
backgroundFocusColor = 'primary',
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2, ey = -3,
|
||||
@@ -195,7 +194,6 @@ nodeWizard = UI.Page {
|
||||
pages = {
|
||||
general = UI.WizardPage {
|
||||
index = 1,
|
||||
backgroundColor = colors.cyan,
|
||||
form = UI.Form {
|
||||
x = 2, ex = -2, y = 1, ey = 3,
|
||||
manualControls = true,
|
||||
@@ -236,11 +234,11 @@ The settings will take effect immediately!]],
|
||||
},
|
||||
},
|
||||
statusBar = UI.StatusBar {
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
},
|
||||
notification = UI.Notification { },
|
||||
filter = UI.SlideOut {
|
||||
backgroundColor = colors.cyan,
|
||||
noFill = true,
|
||||
menuBar = UI.MenuBar {
|
||||
buttons = {
|
||||
{ text = 'Save', event = 'save' },
|
||||
@@ -248,7 +246,8 @@ The settings will take effect immediately!]],
|
||||
},
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
x = 2, ex = -6, y = 2, ey = -6,
|
||||
x = 2, ex = -6, y = 3, ey = -7,
|
||||
disableHeader = true,
|
||||
columns = {
|
||||
{ heading = 'Name', key = 'displayName' },
|
||||
},
|
||||
@@ -262,7 +261,7 @@ The settings will take effect immediately!]],
|
||||
text = '-', event = 'remove_entry', help = 'Remove',
|
||||
},
|
||||
form = UI.Form {
|
||||
x = 2, y = -4, height = 3,
|
||||
x = 2, y = -5, height = 3,
|
||||
margin = 1,
|
||||
manualControls = true,
|
||||
[1] = UI.Checkbox {
|
||||
@@ -290,7 +289,7 @@ The settings will take effect immediately!]],
|
||||
},
|
||||
},
|
||||
statusBar = UI.StatusBar {
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ Right-clicking on the activity monitor will reset the totals.]]
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Activity Monitor',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = 6,
|
||||
marginRight = 0,
|
||||
|
||||
@@ -3,7 +3,6 @@ local Event = require('opus.event')
|
||||
local Milo = require('milo')
|
||||
local UI = require('opus.ui')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
local fs = _G.fs
|
||||
local os = _G.os
|
||||
@@ -23,7 +22,6 @@ Backup configuration files each minecraft day.
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Backup Drive',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||
|
||||
@@ -18,7 +18,6 @@ Note that you do not need to import items from the brewing stand or export blaze
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Brewing Stand',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||
|
||||
@@ -4,12 +4,10 @@ local itemDB = require('core.itemDB')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
local context = Milo:getContext()
|
||||
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Level Emitter',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, y = 1,
|
||||
height = 2,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local Ansi = require('opus.ansi')
|
||||
local UI = require('opus.ui')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
|
||||
--[[ Configuration Screen ]]
|
||||
@@ -14,7 +13,6 @@ Any items placed in this chest will be imported into storage.
|
||||
local inputChestWizardPage = UI.WizardPage {
|
||||
title = 'Input Chest',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
value = string.format(template, Ansi.yellow, Ansi.reset),
|
||||
|
||||
@@ -41,7 +41,6 @@ function page:eventHandler(event)
|
||||
|
||||
elseif event.type == 'focus_change' then
|
||||
self.statusBar:setStatus(event.focused.help)
|
||||
self.statusBar:draw()
|
||||
|
||||
elseif event.type == 'success_message' then
|
||||
self.notification:success(event.message)
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
local Ansi = require('opus.ansi')
|
||||
local UI = require('opus.ui')
|
||||
|
||||
local colors = _G.colors
|
||||
|
||||
local infoTab = UI.Tab {
|
||||
tabTitle = 'Info',
|
||||
index = 4,
|
||||
backgroundColor = colors.cyan,
|
||||
textArea = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2,
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ local context = Milo:getContext()
|
||||
local machinesTab = UI.Tab {
|
||||
tabTitle = 'Machine',
|
||||
index = 3,
|
||||
backgroundColor = colors.cyan,
|
||||
grid = UI.ScrollingGrid {
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
disableHeader = true,
|
||||
|
||||
@@ -3,12 +3,9 @@ local itemDB = require('core.itemDB')
|
||||
local Milo = require('milo')
|
||||
local UI = require('opus.ui')
|
||||
|
||||
local colors = _G.colors
|
||||
|
||||
local recipeTab = UI.Tab {
|
||||
tabTitle = 'Recipe',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
grid = UI.ScrollingGrid {
|
||||
x = 2, ex = -2, y = 2, ey = -4,
|
||||
disableHeader = true,
|
||||
|
||||
@@ -9,7 +9,7 @@ local context = Milo:getContext()
|
||||
local resetTab = UI.Tab {
|
||||
tabTitle = 'Reset',
|
||||
index = 5,
|
||||
backgroundColor = colors.cyan,
|
||||
noFill = true,
|
||||
textArea = UI.TextArea {
|
||||
y = 2, ey = 6,
|
||||
textColor = colors.yellow,
|
||||
|
||||
@@ -15,7 +15,6 @@ local os = _G.os
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Crafting Monitor',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = 3,
|
||||
marginRight = 0,
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
local Ansi = require('opus.ansi')
|
||||
local UI = require('opus.ui')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
|
||||
--[[ Configuration Screen ]]
|
||||
local template =
|
||||
[[%sWarning%s
|
||||
|
||||
Must an interface for Refined Storage / Applied Energistics.
|
||||
|
||||
Add all speed upgrades possible.
|
||||
]]
|
||||
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Mass Storage',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = -2,
|
||||
value = string.format(template, Ansi.red, Ansi.reset),
|
||||
},
|
||||
}
|
||||
|
||||
function wizardPage:isValidFor(node)
|
||||
if node.mtype == 'storage' then
|
||||
local m = device[node.name]
|
||||
return m and m.listAvailableItems
|
||||
end
|
||||
end
|
||||
|
||||
function wizardPage:setNode(node)
|
||||
self.node = node
|
||||
end
|
||||
|
||||
function wizardPage:validate()
|
||||
self.node.adapterType = 'massAdapter'
|
||||
return true
|
||||
end
|
||||
|
||||
-- disable until a way is found to transfer between 2 non-transferrable nodes
|
||||
-- UI:getPage('nodeWizard').wizard:add({ inputChest = wizardPage })
|
||||
@@ -10,12 +10,11 @@ local STARTUP_FILE = 'usr/autorun/miloRemote.lua'
|
||||
local context = ({ ... })[1]
|
||||
|
||||
local setup = UI.SlideOut {
|
||||
backgroundColor = colors.cyan,
|
||||
titleBar = UI.TitleBar {
|
||||
title = 'Remote Setup',
|
||||
},
|
||||
form = UI.Form {
|
||||
x = 2, ex = -2, y = 2, ey = -1,
|
||||
y = 2, ey = -1,
|
||||
[1] = UI.TextEntry {
|
||||
formLabel = 'Server', formKey = 'server',
|
||||
help = 'ID for the server',
|
||||
@@ -40,18 +39,18 @@ local setup = UI.SlideOut {
|
||||
formLabel = 'Run on startup', formKey = 'runOnStartup',
|
||||
help = 'Run this program on startup'
|
||||
},
|
||||
info = UI.TextArea {
|
||||
x = 1, ex = -1, y = 6, ey = -4,
|
||||
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.]],
|
||||
},
|
||||
},
|
||||
info = UI.TextArea {
|
||||
x = 2, ex = -2, y = 8, ey = -4,
|
||||
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.]],
|
||||
},
|
||||
statusBar = UI.StatusBar {
|
||||
backgroundColor = colors.cyan,
|
||||
backgroundColor = 'primary',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ end
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Speaker',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.Text {
|
||||
x = 2, y = 2,
|
||||
textColor = colors.yellow,
|
||||
|
||||
@@ -18,7 +18,6 @@ Right-clicking on the activity monitor will reset the totals.]]
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Status Monitor',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
[1] = UI.TextArea {
|
||||
x = 2, ex = -2, y = 2, ey = 6,
|
||||
marginRight = 0,
|
||||
@@ -86,6 +85,7 @@ local function createPage(node)
|
||||
[1] = UI.Tab {
|
||||
tabTitle = 'Overview',
|
||||
backgroundColor = colors.black,
|
||||
noFill = true,
|
||||
onlineLabel = UI.Text {
|
||||
x = 2, y = 2,
|
||||
value = 'Storage Status',
|
||||
@@ -136,12 +136,14 @@ local function createPage(node)
|
||||
},
|
||||
[2] = UI.Tab {
|
||||
tabTitle = 'Stats',
|
||||
noFill = true,
|
||||
textArea = UI.TextArea {
|
||||
y = 3,
|
||||
},
|
||||
},
|
||||
[3] = UI.Tab {
|
||||
tabTitle = 'Storage',
|
||||
noFill = true,
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2,
|
||||
columns = {
|
||||
@@ -156,6 +158,7 @@ local function createPage(node)
|
||||
},
|
||||
[4] = UI.Tab {
|
||||
tabTitle = 'Offline',
|
||||
noFill = true,
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2,
|
||||
columns = {
|
||||
@@ -166,12 +169,14 @@ local function createPage(node)
|
||||
},
|
||||
[5] = UI.Tab {
|
||||
tabTitle = 'Activity',
|
||||
noFill = true,
|
||||
term = UI.Embedded {
|
||||
--visible = true,
|
||||
},
|
||||
},
|
||||
[6] = UI.Tab {
|
||||
tabTitle = 'Tasks',
|
||||
noFill = true,
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2,
|
||||
values = context.tasks,
|
||||
|
||||
@@ -7,7 +7,6 @@ local device = _G.device
|
||||
local storageView = UI.WizardPage {
|
||||
title = 'Storage Options - General',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
form = UI.Form {
|
||||
x = 2, ex = -2, y = 1, ey = -2,
|
||||
manualControls = true,
|
||||
@@ -62,7 +61,6 @@ UI:getPage('nodeWizard').wizard:add({ storageGeneral = storageView })
|
||||
local lockView = UI.WizardPage {
|
||||
title = 'Storage Options - Locking',
|
||||
index = 3,
|
||||
backgroundColor = colors.cyan,
|
||||
form = UI.Form {
|
||||
x = 2, ex = -2, y = 1, ey = 3,
|
||||
manualControls = true,
|
||||
|
||||
@@ -12,7 +12,6 @@ local context = Milo:getContext()
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Transfer Inventory',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 2, ey = -2,
|
||||
values = context.storage.nodes,
|
||||
|
||||
@@ -9,7 +9,6 @@ local device = _G.device
|
||||
local wizardPage = UI.WizardPage {
|
||||
title = 'Trashcan',
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
info = UI.TextArea {
|
||||
x = 1, ex = -1, y = 2, ey = 4,
|
||||
textColor = colors.yellow,
|
||||
|
||||
Reference in New Issue
Block a user