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
- local function drawTitleBar()
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- term.setCursorPos(1, 1)
- term.clearLine()
- term.write("Doggy OS Legacy Bootloader")
- term.setBackgroundColor(bgColor)
- term.setTextColor(fgColor)
- term.setCursorPos(1, 2)
- end
- -- Function to draw a message box
- local function drawMessageBox(title, message, buttonText)
- term.setBackgroundColor(bgColor)
- term.setTextColor(fgColor)
- local width, height = term.getSize()
- -- Draw the box
- local boxWidth = width - 4
- local boxHeight = 5
- local boxX = 2
- local boxY = math.floor((height - boxHeight) / 2)
- paintutils.drawFilledBox(boxX, boxY, boxX + boxWidth, boxY + boxHeight, boxBgColor)
- term.setBackgroundColor(boxBgColor)
- term.setTextColor(fgColor)
- term.setCursorPos(boxX + 2, boxY + 1)
- term.write(title)
- term.setBackgroundColor(boxBgColor)
- term.setTextColor(fgColor)
- term.setCursorPos(boxX + 2, boxY + 2)
- term.write(message)
- term.setBackgroundColor(buttonColor)
- term.setTextColor(buttonTextColor)
- term.setCursorPos(boxX + 2, boxY + boxHeight - 1)
- term.write(" " .. buttonText .. " ")
- end
- -- Main bootloader function
- local function bootloader()
- clearScreen()
- drawTitleBar()
- drawMessageBox("Booting...", "Attempting to boot your OS.", "Please wait...")
- sleep(0.7)
- -- Simulated boot process
- sleep(2)
- 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
- clearScreen()
- drawTitleBar()
- drawMessageBox("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