entities - display on overlay

This commit is contained in:
kepler155c@gmail.com
2018-12-17 00:30:38 -05:00
parent 400ebabed3
commit 7f458484b6

View File

@@ -1,24 +1,28 @@
local Config = require('config')
local Event = require('event')
local Project = require('neural.project')
local UI = require('ui')
local Util = require('util')
local device = _G.device
local device = _G.device
local peripheral = _G.peripheral
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
error('Plethora sensor must be equipped')
end
local canvas = ni.canvas()
canvas.clear()
Project:init(canvas)
UI:configure('Entities', ...)
local config = Config.load('Entities', { })
local page = UI.Page {
menuBar = UI.MenuBar {
buttons = {
{ text = 'Project', event = 'project' },
},
},
grid = UI.ScrollingGrid {
columns = {
{ heading = 'Name', key = 'displayName' },
@@ -45,6 +49,14 @@ end
function page:eventHandler(event)
if event.type == 'quit' then
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
UI.Page.eventHandler(self, event)
end
@@ -54,15 +66,23 @@ Event.onInterval(.5, function()
local meta = ni.getMetaOwner()
Util.filterInplace(entities, function(e) return e.id ~= meta.id end)
canvas:clear()
Project:drawPoints(meta, entities, 'X', 0xFFDF50AA)
if config.projecting then
Project.canvas:clear()
Project:drawPoints(meta, entities, 'X', 0xFFDF50AA)
end
page.grid:setValues(entities)
page.grid:draw()
page:sync()
end)
if config.projecting then
Project:init(ni.canvas())
end
UI:setPage(page)
UI:pullEvents()
canvas:clear()
if config.projecting then
Project.canvas:clear()
end