more stuff
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
{
|
||||
[ "motd.path" ] = "/rom/motd.txt:/motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt:/rom/cccbridge_motd.txt",
|
||||
}
|
||||
11
apps-meta/Clicker.app
Normal file
11
apps-meta/Clicker.app
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
perms = {
|
||||
repo = false,
|
||||
network = false,
|
||||
app = false,
|
||||
http = false,
|
||||
},
|
||||
author = "CadenCoaster",
|
||||
name = "Dookie Clicker",
|
||||
appid = "com.ruffles.clicker",
|
||||
}
|
||||
BIN
apps/com.ruffles.clicker
Normal file
BIN
apps/com.ruffles.clicker
Normal file
Binary file not shown.
BIN
apps/com.ruffles.launcher
Normal file
BIN
apps/com.ruffles.launcher
Normal file
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
local containers = require "libs.containers"
|
||||
local appid = ...
|
||||
local w,h = term.getSize()
|
||||
local win = window.create(term.native(),1,2,w,h-2,true)
|
||||
local env = containers.getENV(fs.combine("/apps",appid),true, win)
|
||||
containers.start(env)
|
||||
4884
global-libraries/basalt.lua
Normal file
4884
global-libraries/basalt.lua
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
372
libs/windows.lua
Normal file
372
libs/windows.lua
Normal file
@@ -0,0 +1,372 @@
|
||||
local lib = {}
|
||||
local function add(t, v)
|
||||
for i = 1, #t + 1 do
|
||||
if t[i] == nil then
|
||||
t[i] = v
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- hex <-> color bit lookups (Lua 5.1 safe)
|
||||
local HEX = "0123456789abcdef"
|
||||
local hex_to_color, color_to_hex = {}, {}
|
||||
for i = 1, 16 do
|
||||
local c = HEX:sub(i, i)
|
||||
local v = bit32 and bit32.lshift(1, i - 1) or 2 ^ (i - 1)
|
||||
hex_to_color[c] = v
|
||||
color_to_hex[v] = c
|
||||
end
|
||||
|
||||
local function normalize_color(c)
|
||||
if color_to_hex[c] then return c end
|
||||
if type(c) ~= "number" or c < 1 or c > 0xffff then
|
||||
error("Colour out of range", 2)
|
||||
end
|
||||
-- match base's parse_color: coerce mask -> highest set bit (power-of-two)
|
||||
return 2 ^ math.floor(math.log(c, 2))
|
||||
end
|
||||
|
||||
local function clamp(v, lo, hi) return (v < lo) and lo or ((v > hi) and hi or v) end
|
||||
|
||||
function lib.create(name, w, h, x, y)
|
||||
local sx,sy = term.getSize()
|
||||
if not x then x = sx/2-w/2 end
|
||||
if not y then y = sy/2-h/2 end
|
||||
w = math.floor(w + 0.5)
|
||||
h = math.floor(h + 0.5)
|
||||
x = math.floor(x + 0.5)
|
||||
y = math.floor(y + 0.5)
|
||||
-- x,y are metadata for you; renderer can use them
|
||||
local t = {
|
||||
name = name,
|
||||
w = w,
|
||||
h = h,
|
||||
min_w = 3,
|
||||
min_h = 3,
|
||||
x = x or 1,
|
||||
y = y or 2,
|
||||
|
||||
-- column-major buffer: buffer[x][y] = {char, tc, bc}
|
||||
isFullscreen = false,
|
||||
buffer = {},
|
||||
cursorX = 1,
|
||||
cursorY = 1,
|
||||
textColor = colors.white,
|
||||
bgColor = colors.black,
|
||||
cursorBlink = false,
|
||||
resizable = true,
|
||||
draggable = true,
|
||||
decorations = true,
|
||||
alwaysOnTop = false,
|
||||
alwaysBelow = false,
|
||||
fullscreenButton = true,
|
||||
closing = false,
|
||||
_palette = {}, -- optional local palette store
|
||||
}
|
||||
|
||||
local function init_col(xi)
|
||||
local w = t.w
|
||||
local h = t.h
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
w = sw
|
||||
h = sh-2
|
||||
end
|
||||
if not t.buffer[xi] then
|
||||
t.buffer[xi] = {}
|
||||
for yy = 1, h do
|
||||
t.buffer[xi][yy] = { char = " ", tc = t.textColor, bc = t.bgColor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function t.clear()
|
||||
local w = t.w
|
||||
local h = t.h
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
w = sw
|
||||
h = sh-2
|
||||
end
|
||||
for xi = 1, w do
|
||||
init_col(xi)
|
||||
for yy = 1, h do
|
||||
local cell = t.buffer[xi][yy]
|
||||
if not cell then cell = { char = " ", tc = t.textColor, bc = t.bgColor } end
|
||||
cell.char, cell.tc, cell.bc = " ", t.textColor, t.bgColor
|
||||
end
|
||||
end
|
||||
t.cursorX, t.cursorY = 1, 1
|
||||
end
|
||||
|
||||
function t.current() return t end
|
||||
|
||||
function t.redirect() end
|
||||
|
||||
function t.clearLine()
|
||||
local y0 = t.cursorY
|
||||
local w = t.w
|
||||
local h = t.h
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
w = sw
|
||||
h = sh-2
|
||||
end
|
||||
if y0 < 1 or y0 > h then return end
|
||||
for xi = 1, w do
|
||||
init_col(xi)
|
||||
if not t.buffer[xi][y0] then t.buffer[xi][y0] = { char = " ", tc = t.textColor, bc = t.bgColor } end
|
||||
local cell = t.buffer[xi][y0]
|
||||
cell.char, cell.tc, cell.bc = " ", t.textColor, t.bgColor
|
||||
end
|
||||
-- base keeps cursorX unchanged
|
||||
end
|
||||
|
||||
function t.getSize()
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
return sw,sh-2
|
||||
end
|
||||
return t.w, t.h
|
||||
end
|
||||
|
||||
function t.setCursorPos(x0, y0)
|
||||
-- do NOT clamp; let writers clip like base window
|
||||
t.cursorX = math.floor(x0)
|
||||
t.cursorY = math.floor(y0)
|
||||
end
|
||||
|
||||
function t.getCursorPos() return t.cursorX, t.cursorY end
|
||||
|
||||
function t.setCursorBlink(b) t.cursorBlink = not not b end
|
||||
|
||||
function t.getCursorBlink() return t.cursorBlink end
|
||||
|
||||
function t.setTextColor(c) t.textColor = normalize_color(c) end
|
||||
|
||||
t.setTextColour = t.setTextColor
|
||||
|
||||
function t.getTextColor() return t.textColor end
|
||||
|
||||
t.getTextColour = t.getTextColor
|
||||
|
||||
function t.setBackgroundColor(c) t.bgColor = normalize_color(c) end
|
||||
|
||||
t.setBackgroundColour = t.setBackgroundColor
|
||||
|
||||
function t.getBackgroundColor() return t.bgColor end
|
||||
|
||||
t.getBackgroundColour = t.getBackgroundColor
|
||||
|
||||
function t.isColor()
|
||||
return term.native().isColor()
|
||||
end
|
||||
|
||||
t.isColour = t.isColor
|
||||
|
||||
-- Palette passthrough: store locally; renderer can apply
|
||||
function t.setPaletteColor(col, r, g, b)
|
||||
if type(r) == "number" and g and b then
|
||||
t._palette[col] = { r, g, b }
|
||||
elseif type(r) == "number" then
|
||||
-- assume 0xRRGGBB integer (no bitops)
|
||||
local v = r
|
||||
local R8 = math.floor(v / 65536) % 256
|
||||
local G8 = math.floor(v / 256) % 256
|
||||
local B8 = v % 256
|
||||
t._palette[col] = { R8 / 255, G8 / 255, B8 / 255 }
|
||||
end
|
||||
end
|
||||
|
||||
t.setPaletteColour = t.setPaletteColor
|
||||
|
||||
function t.getPaletteColor(col)
|
||||
local p = t._palette[col]
|
||||
if p then return p[1], p[2], p[3] end
|
||||
-- base always returns numbers; fall back to native
|
||||
return term.native().getPaletteColour(col)
|
||||
end
|
||||
|
||||
t.getPaletteColour = t.getPaletteColor
|
||||
|
||||
-- write/blit: mutate buffer with clipping; let cursor run past width
|
||||
function t.write(str)
|
||||
local w = t.w
|
||||
local h = t.h
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
w = sw
|
||||
h = sh-2
|
||||
end
|
||||
str = tostring(str)
|
||||
local y0 = t.cursorY
|
||||
for i = 1, #str do
|
||||
local x = t.cursorX + i - 1
|
||||
if x >= 1 and x <= w and y0 >= 1 and y0 <= h then
|
||||
init_col(x)
|
||||
if not t.buffer[x][y0] then t.buffer[x][y0] = { char = " ", tc = t.textColor, bc = t.bgColor } end
|
||||
local cell = t.buffer[x][y0]
|
||||
cell.char = str:sub(i, i)
|
||||
cell.tc, cell.bc = t.textColor, t.bgColor
|
||||
end
|
||||
end
|
||||
t.cursorX = t.cursorX + #str
|
||||
end
|
||||
|
||||
function t.blit(text, textColors, bgColors)
|
||||
if type(text) ~= "string" then error("bad argument #1 (expected string)", 2) end
|
||||
if textColors and type(textColors) ~= "string" then error("bad argument #2 (expected string)", 2) end
|
||||
if bgColors and type(bgColors) ~= "string" then error("bad argument #3 (expected string)", 2) end
|
||||
if textColors and #textColors ~= #text then error("Arguments must be the same length", 2) end
|
||||
if bgColors and #bgColors ~= #text then error("Arguments must be the same length", 2) end
|
||||
local w = t.w
|
||||
local h = t.h
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
w = sw
|
||||
h = sh-2
|
||||
end
|
||||
textColors = textColors and textColors:lower() or nil
|
||||
bgColors = bgColors and bgColors:lower() or nil
|
||||
|
||||
local y0 = t.cursorY
|
||||
local n = #text
|
||||
for i = 1, n do
|
||||
local x = t.cursorX + i - 1
|
||||
if x >= 1 and x <= w and y0 >= 1 and y0 <= h then
|
||||
init_col(x)
|
||||
local ch = text:sub(i, i)
|
||||
local tch = textColors and textColors:sub(i, i) or nil
|
||||
local bch = bgColors and bgColors:sub(i, i) or nil
|
||||
local tc = tch and hex_to_color[tch] or t.textColor
|
||||
local bc = bch and hex_to_color[bch] or t.bgColor
|
||||
|
||||
local cell = t.buffer[x][y0] or { char = " ", tc = t.textColor, bc = t.bgColor }
|
||||
cell.char, cell.tc, cell.bc = ch, tc, bc
|
||||
end
|
||||
end
|
||||
t.cursorX = t.cursorX + n
|
||||
end
|
||||
|
||||
-- scroll: supports positive (up) and negative (down)
|
||||
function t.scroll(n)
|
||||
local w = t.w
|
||||
local h = t.h
|
||||
if t.isFullscreen then
|
||||
local sw,sh = term.getSize()
|
||||
w = sw
|
||||
h = sh-2
|
||||
end
|
||||
n = math.floor(n or 1)
|
||||
if n == 0 then return end
|
||||
|
||||
local absn = math.abs(n)
|
||||
if absn >= h then
|
||||
-- clear all rows to new empty lines with current colors
|
||||
for xi = 1, w do
|
||||
init_col(xi)
|
||||
for yy = 1, h do
|
||||
local cell = t.buffer[xi][yy] or { char = " ", tc = t.textColor, bc = t.bgColor }
|
||||
cell.char, cell.tc, cell.bc = " ", t.textColor, t.bgColor
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if n > 0 then
|
||||
-- move content up
|
||||
for xi = 1, w do
|
||||
init_col(xi)
|
||||
for yy = 1, h - n do
|
||||
if not t.buffer[xi][yy] then t.buffer[xi][yy] = { char = " ", tc = t.textColor, bc = t.bgColor } end
|
||||
local dst, src = t.buffer[xi][yy], (t.buffer[xi][yy + n] or { char = " ", tc = t.textColor, bc = t.bgColor })
|
||||
dst.char, dst.tc, dst.bc = src.char, src.tc, src.bc
|
||||
end
|
||||
for yy = h - n + 1, h do
|
||||
local cell = t.buffer[xi][yy] or { char = " ", tc = t.textColor, bc = t.bgColor }
|
||||
cell.char, cell.tc, cell.bc = " ", t.textColor, t.bgColor
|
||||
end
|
||||
end
|
||||
else
|
||||
-- n < 0 : move content down
|
||||
local k = -n
|
||||
for xi = 1, w do
|
||||
init_col(xi)
|
||||
for yy = h, k + 1, -1 do
|
||||
local dst, src = t.buffer[xi][yy], t.buffer[xi][yy - k]
|
||||
dst.char, dst.tc, dst.bc = src.char, src.tc, src.bc
|
||||
end
|
||||
for yy = 1, k do
|
||||
local cell = t.buffer[xi][yy]
|
||||
cell.char, cell.tc, cell.bc = " ", t.textColor, t.bgColor
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- input hooks (no-op; your UI can override)
|
||||
function t.clicked(xc, yc, button) end
|
||||
|
||||
function t.released(xc, yc, button) end
|
||||
|
||||
function t.dragged(xc, yc, button) end
|
||||
|
||||
function t.scrolled(dir, xc, yc) end
|
||||
|
||||
function t.char(ch) end
|
||||
|
||||
function t.key(key, is_held) end
|
||||
|
||||
function t.key_up(key) end
|
||||
|
||||
function t.resized(w,h) end
|
||||
|
||||
function t.closeRequested() t.closing = true end
|
||||
|
||||
function t.close()
|
||||
t.closing = true
|
||||
end
|
||||
|
||||
-- ---- Compatibility shims with base window (no rendering inside) ----
|
||||
|
||||
function t.getPosition() return t.x, t.y end
|
||||
|
||||
function t.reposition(nx, ny, nw, nh, _new_parent)
|
||||
nw = math.floor(nw + 0.5)
|
||||
nh = math.floor(nh + 0.5)
|
||||
nx = math.floor(nx + 0.5)
|
||||
ny = math.floor(ny + 0.5)
|
||||
if type(nx) ~= "number" or type(ny) ~= "number" then error("bad position", 2) end
|
||||
t.x, t.y = nx, ny
|
||||
|
||||
if nw and nh then
|
||||
if type(nw) ~= "number" or type(nh) ~= "number" then error("bad size", 2) end
|
||||
local newbuf = {}
|
||||
for xi = 1, nw do
|
||||
newbuf[xi] = {}
|
||||
for yy = 1, nh do
|
||||
local from =
|
||||
(t.buffer[xi] and t.buffer[xi][yy]) and t.buffer[xi][yy]
|
||||
or { char = " ", tc = t.textColor, bc = t.bgColor }
|
||||
newbuf[xi][yy] = { char = from.char, tc = from.tc, bc = from.bc }
|
||||
end
|
||||
end
|
||||
t.buffer, t.w, t.h = newbuf, nw, nh
|
||||
end
|
||||
end
|
||||
|
||||
function t.redraw() end -- renderer handles this elsewhere
|
||||
|
||||
function t.setVisible(_) end
|
||||
|
||||
function t.isVisible() return true end
|
||||
|
||||
function t.restoreCursor() end
|
||||
|
||||
-- initialize
|
||||
t.clear()
|
||||
return t
|
||||
end
|
||||
|
||||
return lib
|
||||
@@ -1,27 +1,36 @@
|
||||
local apps = {}
|
||||
local windows = loadfile("/libs/windows.lua")()
|
||||
local containers = loadfile("/libs/containers.lua")()
|
||||
local focusedapp = nil
|
||||
local home_button = "[------]"
|
||||
local launcherappid = "com.ruffles.launcher"
|
||||
local launcherapp = nil
|
||||
_G.app = {}
|
||||
function _G.app.focusapp(pid)
|
||||
print("focusing "..pid)
|
||||
if focusedapp ~= nil and focusedapp.win ~= nil then
|
||||
focusedapp.win.setVisible(false)
|
||||
end
|
||||
focusedapp = apps[pid]
|
||||
print(focusedapp)
|
||||
if focusedapp ~= nil and focusedapp.win ~= nil then
|
||||
focusedapp.win.setVisible(true)
|
||||
end
|
||||
function _G.app.getApps()
|
||||
local out = {}
|
||||
for _,f in ipairs(fs.list("/apps-meta")) do
|
||||
if fs.exists(fs.combine("/apps-meta",f)) then
|
||||
print(f)
|
||||
local file = fs.open(fs.combine("/apps-meta",f),"r")
|
||||
if file then
|
||||
out[#out+1] = textutils.unserialise(file.readAll())
|
||||
file.close()
|
||||
end
|
||||
end
|
||||
function _G.app.launch(id)
|
||||
end
|
||||
return out
|
||||
end
|
||||
function _G.app.launch(id,perms)
|
||||
local w,h = term.getSize()
|
||||
if not fs.exists(fs.combine("/apps",id)) then return false,"App Not Found" end
|
||||
local win = window.create(term.native(),1,2,w,h-2,false)
|
||||
print("loading "..id)
|
||||
local env = containers.getENV(fs.combine("/apps",id),true, win)
|
||||
local appobj = {win=win,co=nil,id=id,title=""}
|
||||
local win = windows.create(id,w,h-2,1,2)
|
||||
local env = containers.getENV(fs.combine("/apps",id), win, perms)
|
||||
local appobj = {win=win,co=nil,id=id,title=id}
|
||||
function env.setAppTitle(str) appobj.title=str end
|
||||
print("loaded "..id)
|
||||
appobj.co = coroutine.create(function () containers.start(env) end)
|
||||
local pid = -1
|
||||
for k=1,#apps+1 do
|
||||
@@ -31,13 +40,43 @@ function _G.app.launch(id)
|
||||
end
|
||||
end
|
||||
app.focusapp(pid)
|
||||
return pid
|
||||
end
|
||||
|
||||
local function render()
|
||||
while true do
|
||||
local w,h = term.getSize()
|
||||
if focusedapp and focusedapp.win then
|
||||
local window = focusedapp.win
|
||||
for cy = 1, window.h do
|
||||
term.setCursorPos(window.x, window.y + cy - 1)
|
||||
local line, fg, bg = "", "", ""
|
||||
for cx = 1, window.w do
|
||||
if window.buffer[cx] then
|
||||
local cell = window.buffer[cx][cy]
|
||||
if cell then
|
||||
line = line .. cell.char
|
||||
fg = fg .. ("0123456789abcdef"):sub(math.log(cell.tc, 2) + 1, math.log(cell.tc, 2) + 1)
|
||||
bg = bg .. ("0123456789abcdef"):sub(math.log(cell.bc, 2) + 1, math.log(cell.bc, 2) + 1)
|
||||
else
|
||||
line = line .. " "
|
||||
fg = fg .. "0"
|
||||
bg = bg .. "f"
|
||||
end
|
||||
else
|
||||
line = line .. " "
|
||||
fg = fg .. "0"
|
||||
bg = bg .. "f"
|
||||
end
|
||||
end
|
||||
term.blit(line, fg, bg)
|
||||
end
|
||||
end
|
||||
term.setCursorPos(1,1)
|
||||
term.setBackgroundColor(colors.black)
|
||||
if focusedapp then
|
||||
term.setBackgroundColor(focusedapp.win.getBackgroundColour())
|
||||
end
|
||||
term.clearLine()
|
||||
term.write(os.date("%I:%M %p"))
|
||||
local candidate = network.getCandidate()
|
||||
@@ -47,17 +86,43 @@ local function render()
|
||||
end
|
||||
term.setCursorPos(w-right:len()+1,1)
|
||||
term.write(right)
|
||||
sleep()
|
||||
term.setCursorPos((w/2)-(home_button:len()/2)+1,h)
|
||||
term.write(home_button)
|
||||
term.setCursorPos(1,h)
|
||||
if focusedapp then
|
||||
local window = focusedapp.win
|
||||
if window then
|
||||
term.setCursorPos(window.cursorX,window.cursorY)
|
||||
term.setCursorBlink(window.cursorBlink)
|
||||
else
|
||||
term.setCursorBlink(false)
|
||||
end
|
||||
end
|
||||
sleep(1/20)
|
||||
end
|
||||
end
|
||||
|
||||
local function process()
|
||||
while true do
|
||||
local event = {os.pullEvent()}
|
||||
if event[1] == "mouse_click" then
|
||||
local w,h = term.getSize()
|
||||
if event[2] == 1 and event[3] >= (w/2)-(home_button:len()/2)+1 and event[3] <= (w/2)-(home_button:len()/2)+home_button:len() and event[4] == h then
|
||||
app.focusapp(launcherapp)
|
||||
end
|
||||
event[4] = event[4]-1
|
||||
elseif event[1] == "mouse_up" then
|
||||
event[4] = event[4]-1
|
||||
elseif event[1] == "mouse_drag" then
|
||||
event[4] = event[4]-1
|
||||
elseif event[1] == "mouse_scroll" then
|
||||
event[4] = event[4]-1
|
||||
end
|
||||
if focusedapp then
|
||||
if focusedapp.event then
|
||||
local success, content = coroutine.resume(focusedapp.co,table.unpack(focusedapp.event))
|
||||
if success then
|
||||
-- print(focusedapp.title,focusedapp.filter)
|
||||
focusedapp.event = nil
|
||||
focusedapp.filter = content
|
||||
else
|
||||
@@ -73,13 +138,13 @@ local function process()
|
||||
end
|
||||
end
|
||||
for k,v in pairs(apps) do
|
||||
if v.filter == nil or v.filter == event[1] and v.event == nil and not v == focusedapp then
|
||||
if v.filter == nil or v.filter == event[1] and v.event == nil and v ~= focusedapp then
|
||||
v.event = event
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
print("launching test..")
|
||||
app.launch("test")
|
||||
print("launched")
|
||||
print("launching launcher app..")
|
||||
launcherapp = app.launch(launcherappid,{http=true,app=true,repo=true,network=true})
|
||||
print("launched launcher app")
|
||||
parallel.waitForAny(process,render,network.run)
|
||||
29
system-apps/dookie-clicker/startup.lua
Normal file
29
system-apps/dookie-clicker/startup.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local basalt = require("globals.basalt")
|
||||
|
||||
-- Get the main frame (your window)
|
||||
local count = 0
|
||||
local main = basalt.getMainFrame()
|
||||
main:setBackground(colors.black)
|
||||
local w,h = term.getSize()
|
||||
main:addLabel({
|
||||
x = w/2-(7/2)+1,
|
||||
y = 2,
|
||||
text = "Welcome!",
|
||||
foreground = colors.yellow
|
||||
})
|
||||
local countLabel = main:addLabel({
|
||||
x = w/2-(7/2)+1,
|
||||
y = 5,
|
||||
text = "0",
|
||||
foreground = colors.white
|
||||
})
|
||||
|
||||
local button = main:addButton({
|
||||
x = w/2-(7/2)+1,
|
||||
y = 10,
|
||||
text = "Click Me!",
|
||||
foreground = colors.white
|
||||
}):center():onClick(function () count = count + 1 countLabel:setText(tostring(count)) end)
|
||||
|
||||
|
||||
basalt.run()
|
||||
Reference in New Issue
Block a user