Advertisement
DOGGYWOOF

Doggy OS Legacy boot menu

Jul 25th, 2024 (edited)
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. -- Define GUI colors
  2. local bgColor = colors.black
  3. local fgColor = colors.white
  4. local buttonColor = colors.blue
  5. local buttonTextColor = colors.white
  6. local errorColor = colors.red
  7. local boxBgColor = colors.gray
  8.  
  9. -- Function to clear the screen and set background color
  10. local function clearScreen()
  11. term.setBackgroundColor(bgColor)
  12. term.setTextColor(fgColor)
  13. term.clear()
  14. term.setCursorPos(1, 1)
  15. end
  16.  
  17. -- Function to draw the title bar
  18. local function drawTitleBar()
  19. term.setBackgroundColor(colors.cyan)
  20. term.setTextColor(colors.white)
  21. term.setCursorPos(1, 1)
  22. term.clearLine()
  23. term.write("Doggy OS Legacy Bootloader")
  24. term.setBackgroundColor(bgColor)
  25. term.setTextColor(fgColor)
  26. term.setCursorPos(1, 2)
  27. end
  28.  
  29. -- Function to draw a message box
  30. local function drawMessageBox(title, message, buttonText)
  31. term.setBackgroundColor(bgColor)
  32. term.setTextColor(fgColor)
  33. local width, height = term.getSize()
  34.  
  35. -- Draw the box
  36. local boxWidth = width - 4
  37. local boxHeight = 5
  38. local boxX = 2
  39. local boxY = math.floor((height - boxHeight) / 2)
  40.  
  41. paintutils.drawFilledBox(boxX, boxY, boxX + boxWidth, boxY + boxHeight, boxBgColor)
  42. term.setBackgroundColor(boxBgColor)
  43. term.setTextColor(fgColor)
  44. term.setCursorPos(boxX + 2, boxY + 1)
  45. term.write(title)
  46.  
  47. term.setBackgroundColor(boxBgColor)
  48. term.setTextColor(fgColor)
  49. term.setCursorPos(boxX + 2, boxY + 2)
  50. term.write(message)
  51.  
  52. term.setBackgroundColor(buttonColor)
  53. term.setTextColor(buttonTextColor)
  54. term.setCursorPos(boxX + 2, boxY + boxHeight - 1)
  55. term.write(" " .. buttonText .. " ")
  56. end
  57.  
  58. -- Main bootloader function
  59. local function bootloader()
  60. clearScreen()
  61. drawTitleBar()
  62. drawMessageBox("Booting...", "Attempting to boot your OS.", "Please wait...")
  63. sleep(0.7)
  64.  
  65. -- Simulated boot process
  66. sleep(2)
  67.  
  68. if fs.exists("/disk/boot/error") then
  69. shell.run("/disk/boot/error")
  70. elseif fs.exists("/disk/boot/startup") then
  71. shell.run("/disk/boot/startup")
  72. elseif fs.exists("/disk/boot/startup.lua") then
  73. shell.run("/disk/boot/startup.lua")
  74. else
  75. clearScreen()
  76. drawTitleBar()
  77. drawMessageBox("Startup Error", "No boot files detected.", "Press enter to reboot...")
  78. read() -- Wait for user input to reboot
  79. os.reboot()
  80. end
  81. end
  82.  
  83. bootloader()
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement