Advertisement
DOGGYWOOF

Untitled

Oct 1st, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 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 and message box
  18. local function drawScreen(title, message, buttonText)
  19. clearScreen() -- Clear screen before drawing
  20.  
  21. -- Draw the title bar
  22. term.setBackgroundColor(colors.cyan)
  23. term.setTextColor(colors.white)
  24. term.setCursorPos(1, 1)
  25. term.clearLine()
  26. term.write("Doggy OS Legacy Bootloader")
  27.  
  28. -- Draw the message box
  29. term.setBackgroundColor(bgColor)
  30. term.setTextColor(fgColor)
  31. local width, height = term.getSize()
  32.  
  33. -- Box dimensions
  34. local boxWidth = width - 4
  35. local boxHeight = 5
  36. local boxX = 2
  37. local boxY = math.floor((height - boxHeight) / 2)
  38.  
  39. -- Draw the filled box
  40. paintutils.drawFilledBox(boxX, boxY, boxX + boxWidth, boxY + boxHeight, boxBgColor)
  41.  
  42. -- Title in the box
  43. term.setBackgroundColor(boxBgColor)
  44. term.setTextColor(fgColor)
  45. term.setCursorPos(boxX + 2, boxY + 1)
  46. term.write(title)
  47.  
  48. -- Message in the box
  49. term.setCursorPos(boxX + 2, boxY + 2)
  50. term.write(message)
  51.  
  52. -- Button in the box
  53. term.setBackgroundColor(buttonColor)
  54. term.setTextColor(buttonTextColor)
  55. term.setCursorPos(boxX + 2, boxY + boxHeight - 1)
  56. term.write(" " .. buttonText .. " ")
  57. end
  58.  
  59. -- Main bootloader function
  60. local function bootloader()
  61. drawScreen("Booting...", "Attempting to boot your OS. Please wait...", "...")
  62. sleep(2) -- Simulated boot delay
  63.  
  64. if fs.exists("/disk/boot/error") then
  65. shell.run("/disk/boot/error")
  66. elseif fs.exists("/disk/boot/startup") then
  67. shell.run("/disk/boot/startup")
  68. elseif fs.exists("/disk/boot/startup.lua") then
  69. shell.run("/disk/boot/startup.lua")
  70. else
  71. drawScreen("Startup Error", "No boot files detected.", "Press enter to reboot...")
  72. read() -- Wait for user input to reboot
  73. os.reboot()
  74. end
  75. end
  76.  
  77. bootloader()
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement