1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-23 10:58:06 +11:00

Fix missing NeoUX docs, start work on "nbox2018", more logo cleanup

This commit is contained in:
20kdc 2018-04-17 13:28:08 +01:00
parent 491f5ad3cc
commit d808885c59
4 changed files with 277 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,120 @@
-- This is released into the public domain.
-- No warranty is provided, implied or otherwise.
-- app-nbox2018.lua : NODEBOX 2018
-- Authors: 20kdc
-- program start
local window = neo.requireAccess("x.neo.pub.window", "window")(40, 13)
-- ["A"] = {
-- tex = "",
-- -- numbers are 0 to 15:
-- minX = 0, minY = 0, minZ = 0,
-- maxX = 0, maxY = 0, maxZ = 0
-- }
local boxes = {
["A"] = {},
["B"] = {},
["C"] = {},
["D"] = {},
["E"] = {},
["F"] = {},
["G"] = {},
["H"] = {},
["I"] = {},
}
local selectedBox
local workingOnBox = false
local workingOnBoxSt2 = nil
local workingOnBoxSt3 = nil
local function cirno(line)
if line < 9 then
local textA, textB = "", ""
for i = 1, 16 do
-- ▄▀█ and space
textA = textA .. ""
textB = textB .. ""
end
window.span(1, line, "|" .. textA .. "|" .. textB .. "| ", 0, 0xFFFFFF)
for i = 1, 5 do
local boxId = string.char(i + ((line - 1) * 5) + 64)
if boxes[boxId] then
if selectedBox == boxId then
window.span(35 + i, line, boxId, 0xFFFFFF, 0)
else
window.span(35 + i, line, boxId, 0, 0xFFFFFF)
end
end
end
elseif line == 9 then
window.span(1, line, "+XZ Ortho--------+XY Ortho-----+-+Boxes", 0, 0xFFFFFF)
elseif line > 9 then
local text = {
"Nothing selected. |F1 New ",
"Enter starts a new box, while |F3 Load",
" the A-Z keys select a box that |F4 Save",
" is already on the board. |F5 XYXZ"
}
if selectedBox then
text = {
"Box " .. selectedBox .. " selected. |F1 New ",
"Enter deselects the box, while |F3 Load",
" Delete deletes the box, and the|F4 Save",
" A-Z keys select another box. |F5 XYXZ"
}
elseif workingOnBox then
if not workingOnBoxSt1 then
text = {
"Creating box: Placing Point A. |F1 New ",
"Arrows to move around. Use F5 to|F3 Load",
" swap from XY to XZ or back. |F4 Save",
"Enter confirms, Delete cancels. |F5 XYXZ"
}
elseif not workingOnBoxSt2 then
text = {
"Creating box: Placing Point B. |F1 New ",
"Arrows to move around. Use F5 to|F3 Load",
" swap from XY to XZ or back. |F4 Save",
"Enter confirms, Delete cancels. |F5 XYXZ"
}
else
local tex = require("fmttext").pad(unicode.safeTextFormat(workingOnBoxSt2.tex), 30, false, true)
text = {
"Box Texture Entry: Type & press |F1 New ",
" Enter to confirm, or use the |F3 Load",
" out-of-game clipboard. |F4 Save",
"[" .. tex .. "]|F5 XYXZ"
}
end
end
window.span(1, line, text[line - 9] or "", 0, 0xFFFFFF)
end
end
local function refresh()
for i = 1, 14 do
cirno(i)
end
end
while true do
local event, a, b, c, d, e = coroutine.yield()
if event == "x.neo.pub.window" then
if b == "line" then
cirno(c)
end
if b == "key" then
if e then
workingOnBox = not workingOnBox
refresh()
end
end
if b == "close" then
return
end
end
end

View File

@ -6,7 +6,7 @@
return {
["app-eeprog"] = {
desc = "EEPROM programmer / copier",
desc = "Example program: EEPROM programmer / copier",
v = 0,
deps = {
"neo"
@ -45,5 +45,18 @@ return {
"docs/ul-bmp__",
"docs/gp-pedan"
},
}
},
["app-nbox2018"] = {
desc = "NBOX-2018, a 3D printing toolbox",
v = 0,
deps = {
"neo"
},
dirs = {
"apps"
},
files = {
"apps/app-nbox2018.lua"
},
},
}

View File

@ -44,9 +44,49 @@ Main functions:
mode is the mode used for the file,
so see ul-fwrap for values.
neoux.create = TODO
function (w, h, title, callback)
callback(window, evt, ...)
neoux.create(w, h, title, callback):
Creates a window,
including a NeoUX window wrapper.
The parameter list is compatible
with the window "reset" function,
and it is intended that you use
this to simplify your code where
possible.
The callback is of the kind:
function(window, evt, ...)
Where window is the window wrapper,
and everything else is the Everest
event with API and Window ID gone.
It is recommended that you use this
in the form shown:
local stopping = false
local function genWindow()
return 8, 8, "mainwin",
neoux.tcwindow(8, 8, {
-- you can have as many
-- controls as you want,
-- but don't be deliberately
-- wasteful
neoux.tcrawview(1, 1, {
"Each day",
"shall en",
"d as it ",
"begins, ",
"and thou",
"gh you'r",
"e far aw",
"ay from "
})
}, function (w)
w.close()
stopping = true
end, 0xFFFFFF, 0)
end
local w = neoux.create(genWindow())
while not stopping do
event.pull()
end
pad: See ul-fmttx, but loaded on
demand and unloaded after use.
@ -54,9 +94,26 @@ Main functions:
fmtText: See ul-fmttx, but loaded on
demand and unloaded after use.
neoux.tcwindow = TODO
function (w, h, controls, closing,
bg, fg, selIndex)
neoux.tcwindow(w, h, controls,
closing, bg, fg[, selIndex]):
Creates a neoux.create-compatible
callback for a NeoUX GUI framework
window.
W/H is the width/height of the
window, for background drawing.
controls is an ipairsable table
containing UI framework controls.
(The definition of a UI framework
control is noted at the top of the
neoux.lua library file, so that it
does not become out of date.)
closing is a function (window) used
when a close request occurs.
bg/fg sets the application's colour
scheme for controls that care.
selIndex, if provided, is the index
of the control that should start
out selected.
startDialog(fmt, title, wait):
Shows a text dialog.
@ -67,22 +124,87 @@ Main functions:
wait can be nil/false to not wait,
and otherwise.
UI framework window API (TODO):
reset(...): For parameters, see the
neoux.create function. Resets the
window without closing/reopening,
essentially reusing the window yet
changing its contents. Choose over
destroying and then creating a
window - it acts better with
shutdown, for example.
Implicitly performs a setSize,
so a refresh will occur.
getSize(): Returns width, height.
setSize(w, h): Changes the width and
height. Like in the API this wraps,
this is guaranteed to refresh all
the lines of your window.
getDepth(...): Read the note
in us-evrst for details.
span(...): Read the relevant note in
us-evrst for details.
recommendPalette(...): Read the note
in us-evrst for details.
close(): Closes the window, freeing
both Everest and NeoUX resources
associated with it.
UI framework controls (TODO):
neoux.tcrawview =
function (x, y, lines)
table of lines not STF'd
neoux.tchdivider =
function (x, y, w)
neoux.tcvdivider =
function (x, y, h)
neoux.tcbutton =
function (x, y, text, callback)
callback(window)
neoux.tcfield =
function (x, y, w, textprop)
textprop(newval) -> nil
textprop() -> val
(X/Y positions are 1-based, as usual
in OpenComputers)
neoux.tcrawview(x, y, lines)
Creates a UI element that displays
some raw lines, in the format from
the fmtText function.
This format is essentially raw span
text, pre-STF'd, immediately
ready to submit to Everest.
neoux.tchdivider(x, y, w)
Creates a UI element that displays
a 1-high horizontal divider.
The used characters are a detail of
the implementation.
neoux.tcvdivider(x, y, h)
Creates a UI element that displays
a 1-wide vertical divider.
The used characters are a detail of
the implementation.
neoux.tcbutton(x, y, text, callback)
Creates a UI element for a button.
The text is not run through
safeTextFormat automatically, so
you must do it yourself if wide
characters are expected.
The width is thus always equal to:
unicode.len(text) + 2
The height is always 1.
The callback is a function (window)
where window is the NeoUX wrapped
window.
neoux.tcfield(x, y, w, textprop)
Creates a UI element for a text
field.
textprop is a function, which
can be called in two ways:
textprop(newval) -> nil
Writes a string.
textprop() -> val
Reads a string. The string must
NOT be safeTextFormatted, as this
is done internally (in contrast to
tcbutton) only for display, as the
textfield has to edit the string.
-- This is released into
the public domain.