Flench04

sendtocc

Jan 14th, 2024 (edited)
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. local basalt = require("basalt")
  2.  
  3. local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
  4.  
  5. local id = 1
  6. local processes = {}
  7.  
  8. local function openProgram(path, title, x, y, w, h)
  9. local pId = id
  10. id = id + 1
  11. local f = main:addMovableFrame()
  12. :setSize(w or 30, h or 12)
  13. :setPosition(x or math.random(2, 12), y or math.random(2, 8))
  14.  
  15. f:addLabel()
  16. :setSize("{parent.w}", 1)
  17. :setBackground(colors.black)
  18. :setForeground(colors.lightGray)
  19. :setText(title or "New Program")
  20.  
  21. f:addProgram()
  22. :setSize("{parent.w-1}", "{parent.h - 2}")
  23. :setPosition(1, 2)
  24. :execute(path or "rom/programs/shell.lua")
  25.  
  26. f:addButton()
  27. :setSize(1, 1)
  28. :setText("X")
  29. :setBackground(colors.black)
  30. :setForeground(colors.red)
  31. :setPosition("{parent.w-1}", 1)
  32. :onClick(function()
  33. f:remove()
  34. processes[pId] = nil
  35. end)
  36. processes[pId] = f
  37. return f
  38. end
  39.  
  40. -- Adding a menubar with program options
  41. local menu = main:addMenubar()
  42.  
  43. menu:addItem("Open Shell", colors.white, colors.blue):onClick(function()
  44. openProgram("rom/programs/shell.lua", "Shell")
  45. end)
  46.  
  47. menu:addItem("Open Worm", colors.white, colors.blue):onClick(function()
  48. openProgram("rom/programs/fun/worm.lua", "Worm")
  49. end)
  50.  
  51. basalt.autoUpdate()
  52.  
Advertisement
Add Comment
Please, Sign In to add comment