From d808885c591952747812b7265f20a64bae60a785 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Tue, 17 Apr 2018 13:28:08 +0100 Subject: [PATCH] Fix missing NeoUX docs, start work on "nbox2018", more logo cleanup --- code/data/app-klogo/logo.bmp | Bin 2598 -> 2598 bytes repository/apps/app-nbox2018.lua | 120 +++++++++++++++++++++ repository/data/app-claw/local.lua | 17 ++- repository/docs/ul-neoux | 162 +++++++++++++++++++++++++---- 4 files changed, 277 insertions(+), 22 deletions(-) create mode 100644 repository/apps/app-nbox2018.lua diff --git a/code/data/app-klogo/logo.bmp b/code/data/app-klogo/logo.bmp index 1186b2fbb87a221f357cf4ea2b07e62d5c511c2f..aff9588df24fedea5ff138d1cab79ed1d4cd79c0 100644 GIT binary patch literal 2598 zcmcguJ5B^K4E4-@W@p1W5G6t&dI~zOLBooc8z6B9Za{$$6)Orl5EV5YC6{1$&(3F7 zD@aCsyozHxetxkt5*!?D&PC-IdJAg@Ya6SQ8MMeltDC9~XfDd${;r%a4&~%@A@9pG zxxT%TyZfblyj;lR^OJP1m(smmN!N7-_(SbP92R8eTxCR#7F?BNX_y(rSZ3v%wTdFJ z;Ho4`!vW(#k%+mee6lobJZnV6r1HtqFflIllR6@Xy^X9VBSP-T!n|IT(2-)SH^Pi) zgftxZmLn#N4oA~CL{u*!;uWksi&Hqn?}?CLl)RY1*cq^2cf@l~1QW0-Poyx%m4s&L|Ml_8UqTh_pFyXai0zdmk9-~A$F$A(7gWk=5e;gPk z4$&OWB?-!VOd1^`>z{Xm#HT>0|3-Ntt1*D6Px{;Tc(8~JhKxm;@z5W5hC&+f=xX8y zDoVDMq}pb zS-%Pb0m86lh21=AMsVle-HaxOF)TT_AXZ9EdRCKe4VyHz-a*r(!QXzunwCHD%RH~G zK+8?fp=czvIQcz?@#IgOCX@GZW&p7X01>YnYybcN diff --git a/repository/apps/app-nbox2018.lua b/repository/apps/app-nbox2018.lua new file mode 100644 index 0000000..b349749 --- /dev/null +++ b/repository/apps/app-nbox2018.lua @@ -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 diff --git a/repository/data/app-claw/local.lua b/repository/data/app-claw/local.lua index 75c84d1..99350a2 100644 --- a/repository/data/app-claw/local.lua +++ b/repository/data/app-claw/local.lua @@ -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" + }, + }, } diff --git a/repository/docs/ul-neoux b/repository/docs/ul-neoux index 79e80be..e82e73c 100644 --- a/repository/docs/ul-neoux +++ b/repository/docs/ul-neoux @@ -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.