Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local basalt = require("basalt")
- local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
- local id = 1
- local processes = {}
- local function openProgram(path, title, x, y, w, h)
- local pId = id
- id = id + 1
- local f = main:addMovableFrame()
- :setSize(w or 30, h or 12)
- :setPosition(x or math.random(2, 12), y or math.random(2, 8))
- f:addLabel()
- :setSize("{parent.w}", 1)
- :setBackground(colors.black)
- :setForeground(colors.lightGray)
- :setText(title or "New Program")
- f:addProgram()
- :setSize("{parent.w-1}", "{parent.h - 2}")
- :setPosition(1, 2)
- :execute(path or "rom/programs/shell.lua")
- f:addButton()
- :setSize(1, 1)
- :setText("X")
- :setBackground(colors.black)
- :setForeground(colors.red)
- :setPosition("{parent.w-1}", 1)
- :onClick(function()
- f:remove()
- processes[pId] = nil
- end)
- processes[pId] = f
- return f
- end
- -- Adding a menubar with program options
- local menu = main:addMenubar()
- menu:addItem("Open Shell", colors.white, colors.blue):onClick(function()
- openProgram("rom/programs/shell.lua", "Shell")
- end)
- menu:addItem("Open Worm", colors.white, colors.blue):onClick(function()
- openProgram("rom/programs/fun/worm.lua", "Worm")
- end)
- basalt.autoUpdate()
Advertisement
Add Comment
Please, Sign In to add comment