1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-17 00:37:39 +00:00

custom help files + redo System UI

This commit is contained in:
kepler155c@gmail.com
2018-12-22 22:11:16 -05:00
parent 3de03bef22
commit 26564cbcc1
15 changed files with 541 additions and 292 deletions

View File

@@ -7,6 +7,7 @@ local Config = { }
function Config.load(fname, data)
local filename = 'usr/config/' .. fname
data = data or { }
if not fs.exists('usr/config') then
fs.makeDir('usr/config')

42
sys/apis/turtle/home.lua Normal file
View File

@@ -0,0 +1,42 @@
local Config = require('config')
local GPS = require('gps')
local turtle = _G.turtle
local Home = { }
function Home.go()
local config = { }
Config.load('gps', config)
if config.home then
if turtle.enableGPS() then
return turtle.pathfind(config.home)
end
end
end
function Home.set()
local config = { }
Config.load('gps', config)
local pt = GPS.getPoint()
if pt then
local originalHeading = turtle.point.heading
local heading = GPS.getHeading()
if heading then
local turns = (turtle.point.heading - originalHeading) % 4
pt.heading = (heading - turns) % 4
config.home = pt
Config.update('gps', config)
pt = GPS.getPoint()
pt.heading = heading
turtle.setPoint(pt, true)
turtle._goto(config.home)
return config.home
end
end
end
return Home

View File

@@ -2250,6 +2250,13 @@ function UI.Tabs:add(children)
end
end
function UI.Tabs:selectTab(tab)
local menuItem = Util.find(self.tabBar:getFocusables(), 'tabUid', tab.uid)
if menuItem then
self.tabBar:emit({ type = 'tab_select', button = { uid = menuItem.uid } })
end
end
function UI.Tabs:enable()
self.enabled = true
self.tabBar:enable()
@@ -2999,6 +3006,7 @@ function UI.Chooser:eventHandler(event)
if event.key == 'right' or event.key == 'space' then
local _,k = Util.find(self.choices, 'value', self.value)
local choice
if not k then k = 1 end
if k and k < #self.choices then
choice = self.choices[k+1]
else
@@ -3021,7 +3029,7 @@ function UI.Chooser:eventHandler(event)
self:draw()
return true
end
elseif event.type == 'mouse_click' then
elseif event.type == 'mouse_click' or event.type == 'mouse_doubleclick' then
if event.x == 1 then
self:emit({ type = 'key', key = 'left' })
return true