entities - display on overlay
This commit is contained in:
@@ -1,24 +1,28 @@
|
|||||||
|
local Config = require('config')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Project = require('neural.project')
|
local Project = require('neural.project')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
|
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local ni = device.neuralInterface
|
local ni = device.neuralInterface
|
||||||
local sensor = ni or device['plethora:sensor']
|
local sensor = ni or device['plethora:sensor'] or peripheral.find('manipulator')
|
||||||
if not sensor or not sensor.sense then
|
if not sensor or not sensor.sense then
|
||||||
error('Plethora sensor must be equipped')
|
error('Plethora sensor must be equipped')
|
||||||
end
|
end
|
||||||
|
|
||||||
local canvas = ni.canvas()
|
|
||||||
canvas.clear()
|
|
||||||
|
|
||||||
Project:init(canvas)
|
|
||||||
|
|
||||||
UI:configure('Entities', ...)
|
UI:configure('Entities', ...)
|
||||||
|
|
||||||
|
local config = Config.load('Entities', { })
|
||||||
|
|
||||||
local page = UI.Page {
|
local page = UI.Page {
|
||||||
|
menuBar = UI.MenuBar {
|
||||||
|
buttons = {
|
||||||
|
{ text = 'Project', event = 'project' },
|
||||||
|
},
|
||||||
|
},
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
@@ -45,6 +49,14 @@ end
|
|||||||
function page:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
Event.exitPullEvents()
|
Event.exitPullEvents()
|
||||||
|
elseif event.type == 'project' then
|
||||||
|
config.projecting = not config.projecting
|
||||||
|
if config.projecting then
|
||||||
|
Project:init(ni.canvas())
|
||||||
|
else
|
||||||
|
Project.canvas:clear()
|
||||||
|
end
|
||||||
|
Config.update('Entities', config)
|
||||||
end
|
end
|
||||||
UI.Page.eventHandler(self, event)
|
UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
@@ -54,15 +66,23 @@ Event.onInterval(.5, function()
|
|||||||
local meta = ni.getMetaOwner()
|
local meta = ni.getMetaOwner()
|
||||||
Util.filterInplace(entities, function(e) return e.id ~= meta.id end)
|
Util.filterInplace(entities, function(e) return e.id ~= meta.id end)
|
||||||
|
|
||||||
canvas:clear()
|
if config.projecting then
|
||||||
Project:drawPoints(meta, entities, 'X', 0xFFDF50AA)
|
Project.canvas:clear()
|
||||||
|
Project:drawPoints(meta, entities, 'X', 0xFFDF50AA)
|
||||||
|
end
|
||||||
|
|
||||||
page.grid:setValues(entities)
|
page.grid:setValues(entities)
|
||||||
page.grid:draw()
|
page.grid:draw()
|
||||||
page:sync()
|
page:sync()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if config.projecting then
|
||||||
|
Project:init(ni.canvas())
|
||||||
|
end
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
UI:pullEvents()
|
UI:pullEvents()
|
||||||
|
|
||||||
canvas:clear()
|
if config.projecting then
|
||||||
|
Project.canvas:clear()
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user