Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define GUI colors
- local bgColor = colors.black
- local fgColor = colors.white
- local buttonColor = colors.blue
- local buttonTextColor = colors.white
- local errorColor = colors.red
- local boxBgColor = colors.gray
- -- Function to clear the screen and set background color
- local function clearScreen()
- term.setBackgroundColor(bgColor)
- term.setTextColor(fgColor)
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to draw the title bar and message box
- local function drawScreen(title, message, buttonText)
- clearScreen() -- Clear screen before drawing
- -- Draw the title bar
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- term.setCursorPos(1, 1)
- term.clearLine()
- term.write("Doggy OS Legacy Bootloader")
- -- Draw the message box
- term.setBackgroundColor(bgColor)
- term.setTextColor(fgColor)
- local width, height = term.getSize()
- -- Box dimensions
- local boxWidth = width - 4
- local boxHeight = 5
- local boxX = 2
- local boxY = math.floor((height - boxHeight) / 2)
- -- Draw the filled box
- paintutils.drawFilledBox(boxX, boxY, boxX + boxWidth, boxY + boxHeight, boxBgColor)
- -- Title in the box
- term.setBackgroundColor(boxBgColor)
- term.setTextColor(fgColor)
- term.setCursorPos(boxX + 2, boxY + 1)
- term.write(title)
- -- Message in the box
- term.setCursorPos(boxX + 2, boxY + 2)
- term.write(message)
- -- Button in the box
- term.setBackgroundColor(buttonColor)
- term.setTextColor(buttonTextColor)
- term.setCursorPos(boxX + 2, boxY + boxHeight - 1)
- term.write(" " .. buttonText .. " ")
- end
- -- Main bootloader function
- local function bootloader()
- drawScreen("Booting...", "Attempting to boot your OS. Please wait...", "...")
- sleep(2) -- Simulated boot delay
- if fs.exists("/disk/boot/error") then
- shell.run("/disk/boot/error")
- elseif fs.exists("/disk/boot/startup") then
- shell.run("/disk/boot/startup")
- elseif fs.exists("/disk/boot/startup.lua") then
- shell.run("/disk/boot/startup.lua")
- else
- drawScreen("Startup Error", "No boot files detected.", "Press enter to reboot...")
- read() -- Wait for user input to reboot
- os.reboot()
- end
- end
- bootloader()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement