Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Doggy OS Recovery System with Enhanced UI
- local w, h = term.getSize()
- -- Function to center text horizontally
- local function centerText(y, text)
- local x = math.floor((w - #text) / 2)
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to draw the spinner animation
- local function drawSpinner(x, y, duration)
- local spinnerFrames = {
- "[ ]",
- "[= ]",
- "[== ]",
- "[=== ]",
- "[====]",
- "[ ===]",
- "[ ==]",
- "[ =]",
- "[ ]",
- "[ =]",
- "[ ==]",
- "[ ===]",
- "[====]",
- "[=== ]",
- "[== ]",
- "[= ]"
- }
- local delay = 0.1
- local frameCount = #spinnerFrames
- local spinnerX = x
- local spinnerY = y
- local spinnerIndex = 1
- local startTime = os.clock()
- while os.clock() - startTime < duration do
- term.setCursorPos(spinnerX, spinnerY)
- term.write(spinnerFrames[spinnerIndex])
- spinnerIndex = spinnerIndex % frameCount + 1
- os.sleep(delay)
- end
- end
- -- ASCII art dog image
- local dogImage = {
- " |\\_/| ",
- " | @ @ Doggy OS ",
- " | <> _ ",
- " | _/\\------____ ((| |))",
- " | `--' | ",
- " _____|_ ___| |___.' ",
- "/_/_____/____/_______| "
- }
- -- Function to draw the ASCII art
- local function drawASCIIArt(y)
- for i, line in ipairs(dogImage) do
- centerText(y + i - 1, line)
- end
- end
- -- Function to draw the shutdown screen
- local function drawShutdownScreen()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- local artHeight = #dogImage
- local artY = math.floor((h - artHeight) / 2)
- drawASCIIArt(artY)
- -- Calculate spinner position
- local spinnerX = math.floor(w / 2) - 3
- local spinnerY = artY + artHeight + 2
- -- Start spinner animation
- drawSpinner(spinnerX, spinnerY, 9) -- Spinner runs for 9 seconds
- end
- -- Function to clear the screen and prepare for the next operation
- local function clearScreenForNext()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to perform actions and show the shutdown screen before continuing
- local function performActionWithShutdownScreen(action)
- -- Show shutdown screen with spinner animation
- drawShutdownScreen()
- -- Perform the action (e.g., recovery, setup, or resetting)
- action()
- -- Clear the screen for the next operation
- clearScreenForNext()
- end
- -- Full System Recovery function with the new UI
- local function fullSystemRecovery()
- performActionWithShutdownScreen(function()
- -- Recovery actions here (e.g., checking and copying missing files)
- print("Full System Recovery in progress...")
- sleep(3) -- Simulating the recovery process
- print("Full System Recovery completed.")
- end)
- end
- -- Wipe Data and Reset Factory Defaults function with the new UI
- local function wipeDataAndResetFactoryDefaults()
- performActionWithShutdownScreen(function()
- -- Simulate wiping data and copying factory defaults
- print("Wiping data and resetting to factory defaults...")
- -- Delete the /disk/ directory and copy over /.doggyfactorydefaults/ to /disk/
- fs.delete("/disk/")
- fs.copyDir("/.doggyfactorydefaults/", "/disk/")
- -- Show loading bar for resetting
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- centerText(1, "Resetting this PC...")
- drawSpinner(math.floor(w / 2) - 3, 2, 5) -- Spinner runs for 5 seconds
- sleep(3) -- Simulate reset duration
- -- Run the setup after reset
- print("Factory reset completed. Starting setup...")
- sleep(2) -- Simulate transition time
- shell.run("/disk/setup/")
- end)
- end
- -- System Setup function with the new UI
- local function systemSetup()
- performActionWithShutdownScreen(function()
- -- Setup actions here
- print("System setup is starting...")
- sleep(3) -- Simulating the setup process
- print("System setup completed.")
- end)
- end
- -- Main menu for user to choose options
- local function mainMenu()
- while true do
- clearScreenForNext()
- print("===== Doggy OS DEV Recovery GUI =====")
- print("1. Full System Recovery")
- print("2. Wipe Data / Reset to Factory Defaults")
- print("3. System Setup")
- print("4. Exit")
- local choice = tonumber(io.read())
- if choice == 1 then
- fullSystemRecovery()
- elseif choice == 2 then
- wipeDataAndResetFactoryDefaults()
- elseif choice == 3 then
- systemSetup()
- elseif choice == 4 then
- break
- else
- print("Invalid choice. Please try again.")
- sleep(2)
- end
- end
- end
- -- Start the main menu
- mainMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement