Advertisement
DOGGYWOOF

Untitled

Dec 29th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. -- Doggy OS Full System Recovery with GUI
  2.  
  3. -- Create a window with title
  4. local function createWindow(title)
  5. local w, h = term.getSize()
  6. local win = window.create(term.current(), 1, 1, w, h)
  7. win.setBackgroundColor(colors.black)
  8. win.clear()
  9. win.setTextColor(colors.white)
  10. win.setCursorPos(1, 1)
  11. win.write(title)
  12. return win
  13. end
  14.  
  15. -- Show a loading screen with progress
  16. local function showLoadingScreen(win, message, totalSteps)
  17. local barLength = 30 -- Length of the loading bar
  18. win.clear()
  19. win.setCursorPos(1, 2)
  20. win.write(message)
  21. for step = 1, totalSteps do
  22. win.setCursorPos(1, 3)
  23. win.write("[")
  24. for i = 1, barLength do
  25. if i <= math.floor((step / totalSteps) * barLength) then
  26. win.write("=") -- Progress part of the bar
  27. else
  28. win.write(" ") -- Empty part of the bar
  29. end
  30. end
  31. win.write("] " .. math.floor((step / totalSteps) * 100) .. "%")
  32. os.sleep(0.3) -- Slow down the animation for better visual effect
  33. end
  34. end
  35.  
  36. -- Perform an action and show success or error message
  37. local function performAction(action, win, successMessage, failureMessage)
  38. win.clear()
  39. local success, err = pcall(action)
  40. if success then
  41. win.setCursorPos(1, 2)
  42. win.write(successMessage)
  43. else
  44. win.setCursorPos(1, 2)
  45. win.write(failureMessage or "An error occurred: " .. err)
  46. end
  47. os.sleep(2)
  48. end
  49.  
  50. -- Recovery options menu
  51. local function recoveryMenu(win)
  52. while true do
  53. win.clear()
  54. win.setCursorPos(1, 2)
  55. win.write("===== Recovery Options =====")
  56.  
  57. -- Buttons for Recovery Options
  58. win.setCursorPos(1, 4)
  59. win.write("[1] Full System Recovery")
  60. win.setCursorPos(1, 6)
  61. win.write("[2] Wipe Data / Reset to Factory Defaults")
  62. win.setCursorPos(1, 8)
  63. win.write("[3] Back")
  64.  
  65. -- Wait for a mouse click event
  66. local event, button = os.pullEvent("mouse_click")
  67. local _, y = button[1], button[2]
  68.  
  69. -- Button clicks handling based on mouse Y position
  70. if y == 4 then
  71. fullSystemRecovery(win)
  72. elseif y == 6 then
  73. wipeDataAndResetFactoryDefaults(win)
  74. elseif y == 8 then
  75. break
  76. end
  77. end
  78. end
  79.  
  80. -- Power menu for Reboot/Shutdown
  81. local function powerMenu(win)
  82. win.clear()
  83. win.setCursorPos(1, 2)
  84. win.write("===== Power Options =====")
  85.  
  86. -- Buttons for Power Options
  87. win.setCursorPos(1, 4)
  88. win.write("[1] Reboot System")
  89. win.setCursorPos(1, 6)
  90. win.write("[2] Shutdown System")
  91.  
  92. -- Wait for a mouse click event
  93. local event, button = os.pullEvent("mouse_click")
  94. local _, y = button[1], button[2]
  95.  
  96. -- Button clicks handling based on mouse Y position
  97. if y == 4 then
  98. os.reboot()
  99. elseif y == 6 then
  100. os.shutdown()
  101. end
  102. end
  103.  
  104. -- Main menu where recovery and power options are presented
  105. local function mainMenu()
  106. local w, h = term.getSize()
  107. local win = createWindow("Doggy OS DEV Recovery GUI")
  108.  
  109. while true do
  110. win.clear()
  111. win.setCursorPos(1, 2)
  112. win.write("===== Doggy OS DEV Recovery GUI =====")
  113.  
  114. -- Main Menu Buttons
  115. win.setCursorPos(1, 4)
  116. win.write("[1] Recovery Options")
  117. win.setCursorPos(1, 6)
  118. win.write("[2] Power Options")
  119. win.setCursorPos(1, 8)
  120. win.write("[3] Exit")
  121.  
  122. -- Wait for a mouse click event
  123. local event, button = os.pullEvent("mouse_click")
  124. local _, y = button[1], button[2]
  125.  
  126. -- Button clicks handling based on mouse Y position
  127. if y == 4 then
  128. recoveryMenu(win)
  129. elseif y == 6 then
  130. powerMenu(win)
  131. elseif y == 8 then
  132. break
  133. end
  134. end
  135. end
  136.  
  137. -- Placeholder functions for fullSystemRecovery and wipeDataAndResetFactoryDefaults
  138. function fullSystemRecovery(win)
  139. showLoadingScreen(win, "Performing Full System Recovery...", 10)
  140. -- Add actual system recovery code here
  141. performAction(function()
  142. -- System recovery logic
  143. end, win, "Full System Recovery Completed.", "Full System Recovery Failed.")
  144. end
  145.  
  146. function wipeDataAndResetFactoryDefaults(win)
  147. showLoadingScreen(win, "Wiping Data and Resetting to Factory Defaults...", 10)
  148. -- Add actual wipe/reset logic here
  149. performAction(function()
  150. -- Wipe data and reset system
  151. end, win, "System Reset to Factory Defaults Completed.", "System Reset Failed.")
  152. end
  153.  
  154. -- Start the main menu
  155. mainMenu()
  156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement