gui_main.py: Streamline relaunch

This commit is contained in:
Mykola Grymalyuk
2022-04-04 21:55:44 -06:00
parent c839e9192d
commit 391ef62b33
3 changed files with 37 additions and 4 deletions

View File

@@ -6,6 +6,8 @@
- Drops `CSR_ALLOW_UNTRUSTED_KEXTS` and `CSR_ALLOW_UNAPPROVED_KEXTS` - Drops `CSR_ALLOW_UNTRUSTED_KEXTS` and `CSR_ALLOW_UNAPPROVED_KEXTS`
- Remember TeraScale 2 Setting on MacBookPro8,2/3 - Remember TeraScale 2 Setting on MacBookPro8,2/3
- Avoids requiring toggling after first time - Avoids requiring toggling after first time
- Streamline GUI relaunch for Root Patch/Unpatch
- On relaunch, GUI starts patching immediately (previously user would need to re-nagivate the menu)
## 0.4.3 ## 0.4.3
- Increment Binaries: - Increment Binaries:

View File

@@ -22,6 +22,7 @@ class wx_python_gui:
self.computer = self.constants.computer self.computer = self.constants.computer
self.constants.gui_mode = True self.constants.gui_mode = True
self.walkthrough_mode = False self.walkthrough_mode = False
self.finished_auto_patch = False
# Backup stdout for usage with wxPython # Backup stdout for usage with wxPython
self.stock_stdout = sys.stdout self.stock_stdout = sys.stdout
@@ -124,10 +125,18 @@ class wx_python_gui:
# Show Dialog Box # Show Dialog Box
if self.dialog.ShowModal() == wx.ID_YES: if self.dialog.ShowModal() == wx.ID_YES:
print("Relaunching as root") print("Relaunching as root")
extension = ""
if event:
if event.GetEventObject().GetLabel() == "Start Root Patching":
extension = " --gui_patch"
elif event.GetEventObject().GetLabel() == "Revert Root Patches":
extension = " --gui_unpatch"
if self.constants.launcher_script is None: if self.constants.launcher_script is None:
args_string = f"'{self.constants.launcher_binary}'" args_string = f"'{self.constants.launcher_binary}'{extension}"
else: else:
args_string = f"{self.constants.launcher_binary} {self.constants.launcher_script}" args_string = f"{self.constants.launcher_binary} {self.constants.launcher_script}{extension}"
args = [ args = [
"osascript", "osascript",
@@ -333,6 +342,16 @@ class wx_python_gui:
) )
) )
if self.finished_auto_patch is False:
if "--gui_patch" in sys.argv:
self.patches = sys_patch_detect.detect_root_patch(self.computer.real_model, self.constants).detect_patch_set()
self.root_patch_start()
elif "--gui_unpatch" in sys.argv:
self.patches = sys_patch_detect.detect_root_patch(self.computer.real_model, self.constants).detect_patch_set()
self.root_patch_revert()
self.finished_auto_patch = True
if self.app.MainLoop() is None: if self.app.MainLoop() is None:
self.app.MainLoop() self.app.MainLoop()
@@ -874,7 +893,11 @@ class wx_python_gui:
sys.stderr = menu_redirect.RedirectText(self.text_box, True) sys.stderr = menu_redirect.RedirectText(self.text_box, True)
wx.GetApp().Yield() wx.GetApp().Yield()
self.frame.Show() self.frame.Show()
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_patch() try:
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_patch()
except Exception as e:
self.text_box.AppendText(f"- An internal error occured while running the Root Patcher:\n{str(e)}")
pass
sys.stdout = self.stock_stdout sys.stdout = self.stock_stdout
sys.stderr = self.stock_stderr sys.stderr = self.stock_stderr
@@ -947,7 +970,11 @@ class wx_python_gui:
sys.stdout = menu_redirect.RedirectText(self.text_box, True) sys.stdout = menu_redirect.RedirectText(self.text_box, True)
sys.stderr = menu_redirect.RedirectText(self.text_box, True) sys.stderr = menu_redirect.RedirectText(self.text_box, True)
wx.GetApp().Yield() wx.GetApp().Yield()
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_unpatch() try:
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_unpatch()
except Exception as e:
self.text_box.AppendText(f"- An internal error occured while running the Root Patcher:\n{str(e)}")
pass
sys.stdout = self.stock_stdout sys.stdout = self.stock_stdout
sys.stderr = self.stock_stderr sys.stderr = self.stock_stderr

View File

@@ -451,6 +451,10 @@ def check_cli_args():
# validation args # validation args
parser.add_argument("--validate", help="Runs Validation Tests for CI", action="store_true", required=False) parser.add_argument("--validate", help="Runs Validation Tests for CI", action="store_true", required=False)
# GUI args
parser.add_argument("--gui_patch", help="Starts GUI in Root Patcher", action="store_true", required=False)
parser.add_argument("--gui_unpatch", help="Starts GUI in Root Unpatcher", action="store_true", required=False)
args = parser.parse_args() args = parser.parse_args()
if not (args.build or args.patch_sys_vol or args.unpatch_sys_vol or args.validate): if not (args.build or args.patch_sys_vol or args.unpatch_sys_vol or args.validate):
return None return None