cleanup + example start
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
_G.requireInjector(_ENV)
|
|
||||||
|
|
||||||
local Ansi = require('opus.ansi')
|
local Ansi = require('opus.ansi')
|
||||||
local Event = require('opus.event')
|
local Event = require('opus.event')
|
||||||
local UI = require('opus.ui')
|
local UI = require('opus.ui')
|
||||||
@@ -27,7 +25,7 @@ local peripheralsPage = UI.Page {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function peripheralsPage.grid:draw()
|
function peripheralsPage.grid:enable()
|
||||||
local sides = peripheral.getNames()
|
local sides = peripheral.getNames()
|
||||||
|
|
||||||
Util.clear(self.values)
|
Util.clear(self.values)
|
||||||
@@ -39,7 +37,7 @@ function peripheralsPage.grid:draw()
|
|||||||
end
|
end
|
||||||
self:update()
|
self:update()
|
||||||
self:adjustWidth()
|
self:adjustWidth()
|
||||||
UI.Grid.draw(self)
|
UI.Grid.enable(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function peripheralsPage:updatePeripherals()
|
function peripheralsPage:updatePeripherals()
|
||||||
@@ -84,7 +82,6 @@ local methodsPage = UI.Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function methodsPage:enable(p)
|
function methodsPage:enable(p)
|
||||||
|
|
||||||
self.peripheral = p or self.peripheral
|
self.peripheral = p or self.peripheral
|
||||||
|
|
||||||
p = peripheral.wrap(self.peripheral.side)
|
p = peripheral.wrap(self.peripheral.side)
|
||||||
@@ -136,7 +133,6 @@ function methodsPage:eventHandler(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function methodsPage:getDocumentation()
|
function methodsPage:getDocumentation()
|
||||||
|
|
||||||
local method = self.grid:getSelected()
|
local method = self.grid:getSelected()
|
||||||
|
|
||||||
if method.noext then -- computercraft docs
|
if method.noext then -- computercraft docs
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ if not peripheral.find('speaker') then
|
|||||||
error('No speaker attached')
|
error('No speaker attached')
|
||||||
end
|
end
|
||||||
|
|
||||||
local rawSounds = Util.readLines('packages/games/etc/sounds.txt') or error('Unable to read sounds file')
|
local rawSounds = Util.readLines('packages/common/etc/sounds.txt') or error('Unable to read sounds file')
|
||||||
local sounds = { }
|
local sounds = { }
|
||||||
for _, s in pairs(rawSounds) do
|
for _, s in pairs(rawSounds) do
|
||||||
table.insert(sounds, { name = s })
|
table.insert(sounds, { name = s })
|
||||||
|
|||||||
@@ -59,4 +59,10 @@
|
|||||||
iconExt = "\030 \031 \128\030d\159\030 \031d\140\030d\031 \155\030 \0315\140\0305\031 \155\030 \128\010\030 \031d\136\145\0315\136\145\031d\153\031 \128\0315\153\010\030 \031 \128\031d\130\140\134\0315\140\134\031 \128",
|
iconExt = "\030 \031 \128\030d\159\030 \031d\140\030d\031 \155\030 \0315\140\0305\031 \155\030 \128\010\030 \031d\136\145\0315\136\145\031d\153\031 \128\0315\153\010\030 \031 \128\031d\130\140\134\0315\140\134\031 \128",
|
||||||
run = "packages/common/hexedit.lua",
|
run = "packages/common/hexedit.lua",
|
||||||
},
|
},
|
||||||
|
[ "fb1c39e9f4f3c2628ad173ab401a6e4e4baf783d" ] = {
|
||||||
|
title = "Sounds",
|
||||||
|
category = "System",
|
||||||
|
run = "SoundPlayer",
|
||||||
|
iconExt = "\030 \031 \128\0307\159\129\030 \0317\149\0310\144\0300\031 \155\030 \0310\137\144\010\0307\0317\128\128\128\030 \149\0300\031 \149\030 \128\0310\149\0300\031 \149\010\030 \031 \128\0317\130\0307\031 \144\030 \0317\149\0310\129\134\152\129",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
6
examples/.package
Normal file
6
examples/.package
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
title = 'Example programs for coding in Opus',
|
||||||
|
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/examples',
|
||||||
|
description = [[Starter/example programs for creating Opus programs.]],
|
||||||
|
license = 'MIT',
|
||||||
|
}
|
||||||
44
examples/grid.lua
Normal file
44
examples/grid.lua
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
local UI = require('opus.ui')
|
||||||
|
|
||||||
|
local page = UI.Page {
|
||||||
|
menuBar = UI.MenuBar {
|
||||||
|
buttons = {
|
||||||
|
{ text = 'Shuffle', event = 'shuffle' },
|
||||||
|
{ text = 'Clear', event = 'clear', },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
grid = UI.ScrollingGrid {
|
||||||
|
y = 2, ey = -2,
|
||||||
|
values = {
|
||||||
|
{ col = 'column1', value = 'value1' },
|
||||||
|
{ col = 'column2', value = 'value2' },
|
||||||
|
{ col = 'column3', value = 'value3' },
|
||||||
|
},
|
||||||
|
columns = {
|
||||||
|
{ heading = 'HDR1', key = 'col' },
|
||||||
|
{ heading = 'HDR2', key = 'value' },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
statusBar = UI.StatusBar { },
|
||||||
|
}
|
||||||
|
|
||||||
|
function page:eventHandler(event)
|
||||||
|
if event.type == 'grid_select' then
|
||||||
|
self.statusBar:setStatus('Selected: ' .. event.selected.value)
|
||||||
|
|
||||||
|
elseif event.type == 'shuffle' then
|
||||||
|
for _,v in pairs(self.grid.values) do
|
||||||
|
v.col = 'column' .. math.random(1,3)
|
||||||
|
end
|
||||||
|
self.grid:update()
|
||||||
|
self.grid:draw()
|
||||||
|
|
||||||
|
elseif event.type == 'clear' then
|
||||||
|
self.grid:setValues({ })
|
||||||
|
self.grid:draw()
|
||||||
|
end
|
||||||
|
return UI.Page.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
|
||||||
|
UI:setPage(page)
|
||||||
|
UI:pullEvents()
|
||||||
@@ -17,12 +17,6 @@
|
|||||||
run = "Pipes",
|
run = "Pipes",
|
||||||
iconExt = "\030 \031 \128\0300\0310\128\030 \031 \128\0310\143\0300\031 \130\030 \128\0300\0310\128\010\0300\031 \131\0310\128\031 \131\131\030 \0310\159\031 \128\0310\143\010\030 \031 \128\0315\143\031 \128\128\128\128\0300\131",
|
iconExt = "\030 \031 \128\0300\0310\128\030 \031 \128\0310\143\0300\031 \130\030 \128\0300\0310\128\010\0300\031 \131\0310\128\031 \131\131\030 \0310\159\031 \128\0310\143\010\030 \031 \128\0315\143\031 \128\128\128\128\0300\131",
|
||||||
},
|
},
|
||||||
[ "fb1c39e9f4f3c2628ad173ab401a6e4e4baf783d" ] = {
|
|
||||||
title = "Sounds",
|
|
||||||
category = "System",
|
|
||||||
run = "SoundPlayer",
|
|
||||||
iconExt = "\030 \031 \128\0307\159\129\030 \0317\149\0310\144\0300\031 \155\030 \0310\137\144\010\0307\0317\128\128\128\030 \149\0300\031 \149\030 \128\0310\149\0300\031 \149\010\030 \031 \128\0317\130\0307\031 \144\030 \0317\149\0310\129\134\152\129",
|
|
||||||
},
|
|
||||||
[ "a2accffe95b2c8be30e8a05e0c6ab7e8f5966f43" ] = {
|
[ "a2accffe95b2c8be30e8a05e0c6ab7e8f5966f43" ] = {
|
||||||
title = "Strafe",
|
title = "Strafe",
|
||||||
category = "Games",
|
category = "Games",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
title = 'Recipe books for crafting programs',
|
title = 'Recipe books for crafting programs',
|
||||||
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/recipeBook',
|
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/recipeBook',
|
||||||
description = [[ WIP ]],
|
description = [[Recipe book manager for Milo and programs that utilize crafting]],
|
||||||
license = 'MIT',
|
license = 'MIT',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user