Advertisement
DOGGYWOOF

Untitled

Dec 28th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. -- Doggy OS Recovery System with Enhanced UI
  2.  
  3. local w, h = term.getSize()
  4.  
  5. -- Function to center text horizontally
  6. local function centerText(y, text)
  7. local x = math.floor((w - #text) / 2)
  8. term.setCursorPos(x, y)
  9. term.write(text)
  10. end
  11.  
  12. -- Function to draw the spinner animation
  13. local function drawSpinner(x, y, duration)
  14. local spinnerFrames = {
  15. "[ ]",
  16. "[= ]",
  17. "[== ]",
  18. "[=== ]",
  19. "[====]",
  20. "[ ===]",
  21. "[ ==]",
  22. "[ =]",
  23. "[ ]",
  24. "[ =]",
  25. "[ ==]",
  26. "[ ===]",
  27. "[====]",
  28. "[=== ]",
  29. "[== ]",
  30. "[= ]"
  31. }
  32. local delay = 0.1
  33. local frameCount = #spinnerFrames
  34.  
  35. local spinnerX = x
  36. local spinnerY = y
  37.  
  38. local spinnerIndex = 1
  39. local startTime = os.clock()
  40. while os.clock() - startTime < duration do
  41. term.setCursorPos(spinnerX, spinnerY)
  42. term.write(spinnerFrames[spinnerIndex])
  43.  
  44. spinnerIndex = spinnerIndex % frameCount + 1
  45. os.sleep(delay)
  46. end
  47. end
  48.  
  49. -- ASCII art dog image
  50. local dogImage = {
  51. " |\\_/| ",
  52. " | @ @ Doggy OS ",
  53. " | <> _ ",
  54. " | _/\\------____ ((| |))",
  55. " | `--' | ",
  56. " _____|_ ___| |___.' ",
  57. "/_/_____/____/_______| "
  58. }
  59.  
  60. -- Function to draw the ASCII art
  61. local function drawASCIIArt(y)
  62. for i, line in ipairs(dogImage) do
  63. centerText(y + i - 1, line)
  64. end
  65. end
  66.  
  67. -- Function to draw the shutdown screen
  68. local function drawShutdownScreen()
  69. term.setBackgroundColor(colors.black)
  70. term.clear()
  71.  
  72. term.setTextColor(colors.white)
  73. local artHeight = #dogImage
  74. local artY = math.floor((h - artHeight) / 2)
  75. drawASCIIArt(artY)
  76.  
  77. -- Calculate spinner position
  78. local spinnerX = math.floor(w / 2) - 3
  79. local spinnerY = artY + artHeight + 2
  80.  
  81. -- Start spinner animation
  82. drawSpinner(spinnerX, spinnerY, 9) -- Spinner runs for 9 seconds
  83. end
  84.  
  85. -- Function to clear the screen and prepare for the next operation
  86. local function clearScreenForNext()
  87. term.setBackgroundColor(colors.black)
  88. term.clear()
  89. term.setCursorPos(1, 1)
  90. end
  91.  
  92. -- Function to perform actions and show the shutdown screen before continuing
  93. local function performActionWithShutdownScreen(action)
  94. -- Show shutdown screen with spinner animation
  95. drawShutdownScreen()
  96.  
  97. -- Perform the action (e.g., recovery, setup, or resetting)
  98. action()
  99.  
  100. -- Clear the screen for the next operation
  101. clearScreenForNext()
  102. end
  103.  
  104. -- Full System Recovery function with the new UI
  105. local function fullSystemRecovery()
  106. performActionWithShutdownScreen(function()
  107. -- Recovery actions here (e.g., checking and copying missing files)
  108. print("Full System Recovery in progress...")
  109. sleep(3) -- Simulating the recovery process
  110. print("Full System Recovery completed.")
  111. end)
  112. end
  113.  
  114. -- Wipe Data and Reset Factory Defaults function with the new UI
  115. local function wipeDataAndResetFactoryDefaults()
  116. performActionWithShutdownScreen(function()
  117. -- Simulate wiping data and copying factory defaults
  118. print("Wiping data and resetting to factory defaults...")
  119.  
  120. -- Delete the /disk/ directory and copy over /.doggyfactorydefaults/ to /disk/
  121. fs.delete("/disk/")
  122. fs.copyDir("/.doggyfactorydefaults/", "/disk/")
  123.  
  124. -- Show loading bar for resetting
  125. term.setBackgroundColor(colors.black)
  126. term.clear()
  127. term.setTextColor(colors.white)
  128. centerText(1, "Resetting this PC...")
  129. drawSpinner(math.floor(w / 2) - 3, 2, 5) -- Spinner runs for 5 seconds
  130. sleep(3) -- Simulate reset duration
  131.  
  132. -- Run the setup after reset
  133. print("Factory reset completed. Starting setup...")
  134. sleep(2) -- Simulate transition time
  135. shell.run("/disk/setup/")
  136. end)
  137. end
  138.  
  139. -- System Setup function with the new UI
  140. local function systemSetup()
  141. performActionWithShutdownScreen(function()
  142. -- Setup actions here
  143. print("System setup is starting...")
  144. sleep(3) -- Simulating the setup process
  145. print("System setup completed.")
  146. end)
  147. end
  148.  
  149. -- Main menu for user to choose options
  150. local function mainMenu()
  151. while true do
  152. clearScreenForNext()
  153. print("===== Doggy OS DEV Recovery GUI =====")
  154. print("1. Full System Recovery")
  155. print("2. Wipe Data / Reset to Factory Defaults")
  156. print("3. System Setup")
  157. print("4. Exit")
  158.  
  159. local choice = tonumber(io.read())
  160.  
  161. if choice == 1 then
  162. fullSystemRecovery()
  163. elseif choice == 2 then
  164. wipeDataAndResetFactoryDefaults()
  165. elseif choice == 3 then
  166. systemSetup()
  167. elseif choice == 4 then
  168. break
  169. else
  170. print("Invalid choice. Please try again.")
  171. sleep(2)
  172. end
  173. end
  174. end
  175.  
  176. -- Start the main menu
  177. mainMenu()
  178.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement