diff --git a/resources/build/firmware.py b/resources/build/firmware.py index a60e27dec..8bc416c73 100644 --- a/resources/build/firmware.py +++ b/resources/build/firmware.py @@ -73,7 +73,7 @@ class BuildFirmware: support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleIntelCPUPowerManagement.kext", self.constants.aicpupm_version, self.constants.aicpupm_path) support.BuildSupport(self.model, self.constants, self.config).enable_kext("AppleIntelCPUPowerManagementClient.kext", self.constants.aicpupm_version, self.constants.aicpupm_client_path) - if smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge.value or self.constants.disable_xcpm is True: + if smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.sandy_bridge.value or self.constants.disable_fw_throttle is True: # With macOS 12.3 Beta 1, Apple dropped the 'plugin-type' check within X86PlatformPlugin # Because of this, X86PP will match onto the CPU instead of ACPI_SMC_PlatformPlugin # This causes power management to break on pre-Ivy Bridge CPUs as they don't have correct @@ -81,11 +81,11 @@ class BuildFirmware: # This patch will simply increase ASPP's 'IOProbeScore' to outmatch X86PP logging.info("- Overriding ACPI SMC matching") support.BuildSupport(self.model, self.constants, self.config).enable_kext("ASPP-Override.kext", self.constants.aspp_override_version, self.constants.aspp_override_path) - if self.constants.disable_xcpm is True: + if self.constants.disable_fw_throttle is True: # Only inject on older OSes if user requests support.BuildSupport(self.model, self.constants, self.config).get_item_by_kv(self.config["Kernel"]["Add"], "BundlePath", "ASPP-Override.kext")["MinKernel"] = "" - if self.constants.disable_msr_power_ctl is True and smbios_data.smbios_dictionary[self.model]["CPU Generation"] >= cpu_data.cpu_data.nehalem.value: + if self.constants.disable_fw_throttle is True and smbios_data.smbios_dictionary[self.model]["CPU Generation"] >= cpu_data.cpu_data.nehalem.value: logging.info("- Disabling Firmware Throttling") # Nehalem and newer systems force firmware throttling via MSR_POWER_CTL support.BuildSupport(self.model, self.constants, self.config).enable_kext("SimpleMSR.kext", self.constants.simplemsr_version, self.constants.simplemsr_path) diff --git a/resources/constants.py b/resources/constants.py index be3f90157..841d806a0 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -205,12 +205,11 @@ class Constants: self.dGPU_switch: bool = False # Set Display GPU Switching for Windows self.force_surplus: bool = False # Force SurPlus patch in newer OSes self.force_latest_psp: bool = False # Force latest PatcherSupportPkg - self.disable_msr_power_ctl: bool = False # Disable MSR Power Control (missing battery throttling) + self.disable_fw_throttle: bool = False # Disable MSR Power Control and XCPM self.software_demux: bool = False # Enable Software Demux patch set self.force_vmm: bool = False # Force VMM patch self.disable_connectdrivers: bool = False # Disable ConnectDrivers (hibernation) self.set_content_caching: bool = False # Set Content Caching - self.disable_xcpm: bool = False # Disable XCPM (X86PlatformPlugin.kext) self.set_vmm_cpuid: bool = False # Set VMM bit inside CPUID self.disable_cat_colorsync: bool = False # Disable the ColorSync patch to regain Display Profiles self.set_alc_usage: bool = True # Set AppleALC usage diff --git a/resources/wx_gui/gui_main_menu.py b/resources/wx_gui/gui_main_menu.py index 158553316..9b712fbdc 100644 --- a/resources/wx_gui/gui_main_menu.py +++ b/resources/wx_gui/gui_main_menu.py @@ -8,7 +8,7 @@ from resources.wx_gui import ( gui_settings, ) from resources import constants -from data import model_array, os_data +from data import os_data class MainMenu(wx.Frame): def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Constants, screen_location: tuple = None): @@ -124,7 +124,6 @@ class MainMenu(wx.Frame): screen_location=self.GetPosition() ) - def on_help(self, event: wx.Event = None): gui_help.HelpFrame( parent=self, diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 73a86099c..f61b9d0f5 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -1,6 +1,8 @@ import wx import logging +from resources.wx_gui import gui_support + from resources import constants, global_settings, defaults from data import model_array @@ -14,7 +16,7 @@ class SettingsFrame(wx.Frame): self.settings = self._settings() - self.frame_modal = wx.Dialog(parent, title=title, size=(500, 500)) + self.frame_modal = wx.Dialog(parent, title=title, size=(600, 750)) self._generate_elements(self.frame_modal) self.frame_modal.ShowWindowModal() @@ -24,48 +26,101 @@ class SettingsFrame(wx.Frame): notebook = wx.Notebook(frame) notebook.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.AddSpacer(10) + + model_label = wx.StaticText(frame, label="Target Model", pos=(-1, -1)) + model_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) + sizer.Add(model_label, 0, wx.ALIGN_CENTER | wx.ALL, 5) + + model_choice = wx.Choice(frame, choices=model_array.SupportedSMBIOS + ["Host Model"] if self.constants.computer.real_model not in model_array.SupportedSMBIOS else model_array.SupportedSMBIOS, pos=(-1, -1)) + model_choice.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + model_choice.Bind(wx.EVT_CHOICE, lambda event: self.on_model_choice(event, model_choice)) + selection = self.constants.custom_model if self.constants.custom_model else self.constants.computer.real_model + if selection not in model_array.SupportedSMBIOS: + selection = "Host Model" + model_choice.SetSelection(model_choice.FindString(selection)) + + sizer.Add(model_choice, 0, wx.ALIGN_CENTER | wx.ALL, 5) + + # Add label below Override Model + model_description = wx.StaticText(frame, label="Overrides system OCLP will build for.", pos=(-1, -1)) + model_description.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + sizer.Add(model_description, 0, wx.ALIGN_CENTER | wx.ALL, 5) + + tabs = [ - "General", - "OpenCore", + "Build", + "Advanced", "Security", "Root Patching", "Non-Metal", + "SMBIOS", + "App" ] for tab in tabs: panel = wx.Panel(notebook) notebook.AddPage(panel, tab) - sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 30) - frame.SetSizer(sizer) - # Set sizer spacing - sizer.SetItemMinSize(notebook, (300, 300)) + sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 10) # Add return button - return_button = wx.Button(frame, label="Return", pos=(10, frame.GetSize()[1] - 60), size=(100, 30 - )) + return_button = wx.Button(frame, label="Return", pos=(-1, -1), size=(100, 30)) return_button.Bind(wx.EVT_BUTTON, self.on_return) return_button.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) - return_button.Center(wx.HORIZONTAL) + sizer.Add(return_button, 0, wx.ALIGN_CENTER | wx.ALL, 10) + + + frame.SetSizer(sizer) + + horizontal_center = frame.GetSize()[0] / 2 for tab in tabs: - height = 0 if tab != "General" else 80 - width = 0 + stock_height = 0 + stock_width = 20 + + height = stock_height + width = stock_width panel = notebook.GetPage(tabs.index(tab)) + if tab not in self.settings: + continue + + lowest_height_reached = height + highest_height_reached = height + for setting, setting_info in self.settings[tab].items(): if setting_info["type"] == "populate": # execute populate function if setting_info["args"] == wx.Frame: setting_info["function"](panel) - continue - - if setting_info["type"] == "wrap_around": - height = 0 if tab != "General" else 80 - width += 210 continue - elif setting_info["type"] == "checkbox": + if setting_info["type"] == "title": + stock_height = lowest_height_reached + height = stock_height + width = stock_width + + height += 10 + + # Add title + title = wx.StaticText(panel, label=setting, pos=(-1, -1)) + title.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) + + title.SetPosition((int(horizontal_center) - int(title.GetSize()[0] / 2) - 15, height)) + highest_height_reached = height + title.GetSize()[1] + 10 + + height += title.GetSize()[1] + 10 + + continue + + if setting_info["type"] == "wrap_around": + height = highest_height_reached + width = 300 if width is stock_width else stock_width + + continue + + if setting_info["type"] == "checkbox": # Add checkbox, and description underneath checkbox = wx.CheckBox(panel, label=setting, pos=(10 + width, 10 + height), size = (200,-1)) checkbox.SetValue(setting_info["value"] if setting_info["value"] else False) @@ -75,136 +130,156 @@ class SettingsFrame(wx.Frame): elif setting_info["type"] == "spinctrl": # Add spinctrl, and description underneath - spinctrl = wx.SpinCtrl(panel, value=str(setting_info["value"]), pos=(5 + width, 10 + height), min=setting_info["min"], max=setting_info["max"], size = (45,-1)) + spinctrl = wx.SpinCtrl(panel, value=str(setting_info["value"]), pos=(width - 20, 10 + height), min=setting_info["min"], max=setting_info["max"], size = (45,-1)) spinctrl.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) - spinctrl.Bind(wx.EVT_TEXT, lambda event: self.on_spinctrl(event, setting)) + spinctrl.Bind(wx.EVT_TEXT, lambda event, variable=setting: self.on_spinctrl(event, variable)) # Add label next to spinctrl - label = wx.StaticText(panel, label=setting, pos=(spinctrl.GetSize()[0] + 10 + width, spinctrl.GetPosition()[1])) + label = wx.StaticText(panel, label=setting, pos=(spinctrl.GetSize()[0] + width - 16, spinctrl.GetPosition()[1])) label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) else: logging.critical(f"Unknown setting type: {setting_info['type']}") continue - description = wx.StaticText(panel, label=setting_info["description"], pos=(30 + width, 10 + height + 20)) + lines = '\n'.join(setting_info["description"]) + description = wx.StaticText(panel, label=lines, pos=(30 + width, 10 + height + 20)) description.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) height += 40 # Check number of lines in description, and adjust spacer accordingly - description_lines = len(description.GetLabel().split("\n")) + description_lines = len(lines.split('\n')) if description_lines > 1: - height += (description_lines) * 10 + height += (description_lines) * 11 + + if height > lowest_height_reached: + lowest_height_reached = height def _settings(self): settings = { - "General": { - "Populate SMBIOS": { - "type": "populate", - "function": self._populate_model_selection, - "args": wx.Frame, + + "Build": { + "General": { + "type": "title", }, - "Allow native models": { - "type": "checkbox", - "value": self.constants.allow_oc_everywhere, - "variable": "allow_oc_everywhere", - "description": "Allow OpenCore to be installed\non natively supported Macs.\nNote this will not allow unsupported\nmacOS versions to be installed on\nyour system.", - "warning": "This option should only be used if your Mac natively supports the OSes you wish to run.\n\nIf you are currently running an unsupported OS, this option will break booting. Only toggle for enabling OS features on a native Mac.\n\nAre you certain you want to continue?", - }, - "Verbose": { - "type": "checkbox", - "value": self.constants.verbose_debug, - "variable": "verbose_debug", - "description": "Enable verbose debug logging", - }, - "Kext Debugging": { - "type": "checkbox", - "value": self.constants.kext_debug, - "variable": "kext_debug", - "description": "Enable additional kext logging.", - }, - "OpenCore Debugging": { - "type": "checkbox", - "value": self.constants.opencore_debug, - "variable": "opencore_debug", - "description": "Enable additional OpenCore logging.", - }, - "Show Boot Picker": { - "type": "checkbox", - "value": self.constants.showpicker, - "variable": "showpicker", - "description": "Show OpenCore boot picker\nWhen disabled, users can hold ESC to\nshow picker in the firmware.", - }, - "wrap_around": { - "type": "wrap_around", - }, - "Boot Picker Timeout": { - "type": "spinctrl", - "value": self.constants.oc_timeout, - "variable": "oc_timeout", - "description": "Timeout for OpenCore boot picker\nin seconds.\nSet to 0 for no timeout", - "min": 0, - "max": 60, - }, - "Ignore App Updates": { - "type": "checkbox", - "value": self.constants.ignore_updates, - "variable": "ignore_updates", - "description": "Ignore app updates\nWhen enabled, the app will not\ncheck for updates.", - }, - "Disable Reporting": { - "type": "checkbox", - "value": global_settings.GlobalEnviromentSettings().read_property("DisableCrashAndAnalyticsReporting"), - "variable": "DisableCrashAndAnalyticsReporting", - "description": "Disable crash and system reporting\nWhen enabled, the app will not\nreport any info to Dortania.", - "override_function": global_settings.GlobalEnviromentSettings().write_property, - }, - }, - "OpenCore": { "FireWire Booting": { "type": "checkbox", "value": self.constants.firewire_boot, "variable": "firewire_boot", - "description": "Enable booting macOS from\nFireWire drives", + "description": [ + "Enable booting macOS from", + "FireWire drives", + ], }, "XHCI Booting": { "type": "checkbox", "value": self.constants.xhci_boot, "variable": "xhci_boot", - "description": "Enable booting macOS from add-in\nUSB 3.0 expansion cards", + "description": [ + "Enable booting macOS from add-in", + "USB 3.0 expansion cards", + ], }, "NVMe Booting": { "type": "checkbox", "value": self.constants.nvme_boot, "variable": "nvme_boot", - "description": "Enable booting macOS from NVMe\ndrives", - }, - "3rd Party NVMe PM": { - "type": "checkbox", - "value": self.constants.allow_nvme_fixing, - "variable": "allow_nvme_fixing", - "description": "Enable 3rd party NVMe power\nmanagement. When enabled, macOS\n will be able to control the power\nmanagement of NVMe drives.", + "description": [ + "Enable booting macOS from NVMe", + "drives", + "Note: Requires Firmware support", + "for OpenCore to load from NVMe", + ], }, "Wake on WLAN": { "type": "checkbox", "value": self.constants.enable_wake_on_wlan, "variable": "enable_wake_on_wlan", - "description": "Enable Wake on WLAN\nWhen enabled, macOS will be able to\nwake from sleep using a Wireless\nNetwork connection.", + "description": [ + "Enable Wake on WLAN", + "When enabled, macOS will be able to", + "wake from sleep using a Wireless", + "Network connection.", + ], }, - "wrap_around": { + "wrap_around 2": { "type": "wrap_around", }, "Content Caching": { "type": "checkbox", "value": self.constants.set_content_caching, "variable": "set_content_caching", - "description": "Enable Content Caching\nWhen enabled, macOS will be able\nto use the Content Caching feature.", + "description": [ + "Enable Content Caching", + ], }, "APFS Trim": { "type": "checkbox", "value": self.constants.apfs_trim_timeout, "variable": "apfs_trim_timeout", - "description": "Enable APFS Trim\nRecommended for all users, however faulty\nSSDs benefit from disabling this.", + "description": [ + "Recommended for all users, however faulty", + "SSDs benefit from disabling this.", + ], + + }, + "Show Boot Picker": { + "type": "checkbox", + "value": self.constants.showpicker, + "variable": "showpicker", + "description": [ + "Show OpenCore boot picker", + "When disabled, users can hold ESC to", + "show picker in the firmware.", + ], + + }, + "Boot Picker Timeout": { + "type": "spinctrl", + "value": self.constants.oc_timeout, + "variable": "oc_timeout", + "description": [ + "Timeout for OpenCore boot picker", + "in seconds.", + "Set to 0 for no timeout", + ], + + "min": 0, + "max": 60, + }, + "Debug": { + "type": "title", + }, + + "Verbose": { + "type": "checkbox", + "value": self.constants.verbose_debug, + "variable": "verbose_debug", + "description": [ + "Verbose output during boot", + ], + + }, + "Kext Debugging": { + "type": "checkbox", + "value": self.constants.kext_debug, + "variable": "kext_debug", + "description": [ + "Use DEBUG variants of kexts and", + "enables additional kernel logging.", + ], + }, + "wrap_around 1": { + "type": "wrap_around", + }, + "OpenCore Debugging": { + "type": "checkbox", + "value": self.constants.opencore_debug, + "variable": "opencore_debug", + "description": [ + "Use DEBUG variant of OpenCore", + "and enables additional logging.", + ], }, }, "Security": { @@ -212,45 +287,151 @@ class SettingsFrame(wx.Frame): "type": "checkbox", "value": self.constants.disable_cs_lv, "variable": "disable_cs_lv", - "description": "Required for root volume patching,\nallowing our custom frameworks to\nload.", + "description": [ + "Required for root volume patching,", + "allowing our custom frameworks to", + "load.", + ], }, "Disable AMFI": { "type": "checkbox", "value": self.constants.disable_amfi, "variable": "disable_amfi", - "description": "Extended version of 'Disable\nLibrary Validation', required for\npatching macOS.", + "description": [ + "Extended version of 'Disable", + "Library Validation', required for", + "patching macOS.", + ], + }, + "Secure Boot Model": { + "type": "checkbox", + "value": self.constants.secure_status, + "variable": "secure_status", + "description": [ + "Enable SecureBootModel", + ], + } + }, + "Advanced": { + "AMD GOP Injection": { + "type": "checkbox", + "value": self.constants.amd_gop_injection, + "variable": "amd_gop_injection", + "description": [ + "Inject AMD GOP for boot screen", + "support on PC GPUs.", + ], + }, + "Nvidia GOP Injection": { + "type": "checkbox", + "value": self.constants.nvidia_kepler_gop_injection, + "variable": "nvidia_kepler_gop_injection", + "description": [ + "Inject Nvidia Kepler GOP for boot", + "screen support on PC GPUs.", + ], + }, + "Disable Firmware Throttling": { + "type": "checkbox", + "value": self.constants.disable_fw_throttle, + "variable": "disable_fw_throttle", + "description": [ + "Disables firmware based throttling", + "caused by missing hardware.", + "ex. Missing Display, Battery, etc.", + ], + }, + "Software DeMUX": { + "type": "checkbox", + "value": self.constants.software_demux, + "variable": "software_demux", + "description": [ + "Enable software based DeMUX", + "for MacBookPro8,2 and MacBookPro8,3", + "Prevents faulty dGPU from turning on", + ], + }, + "wrap_around 1": { + "type": "wrap_around", + }, + "3rd Party NVMe PM": { + "type": "checkbox", + "value": self.constants.allow_nvme_fixing, + "variable": "allow_nvme_fixing", + "description": [ + "Enable 3rd party NVMe power", + "management. When enabled, macOS", + "will be able to control the power", + "management of NVMe drives.", + ], + }, + "3rd Party SATA PM": { + "type": "checkbox", + "value": self.constants.allow_3rd_party_drives, + "variable": "allow_3rd_party_drives", + "description": [ + "Enable 3rd party SATA power", + "management. When enabled, macOS", + "will be able to control the power", + "management of SATA drives.", + ], }, }, "Root Patching": {}, "Non-Metal": {}, + "App": { + "Allow native models": { + "type": "checkbox", + "value": self.constants.allow_oc_everywhere, + "variable": "allow_oc_everywhere", + "description": [ + "Allow OpenCore to be installed", + "on natively supported Macs.", + "Note this will not allow unsupported", + "macOS versions to be installed on", + "your system.", + ], + "warning": "This option should only be used if your Mac natively supports the OSes you wish to run.\n\nIf you are currently running an unsupported OS, this option will break booting. Only toggle for enabling OS features on a native Mac.\n\nAre you certain you want to continue?", + }, + "Ignore App Updates": { + "type": "checkbox", + "value": self.constants.ignore_updates, + "variable": "ignore_updates", + "description": [ + "Ignore app updates", + "When enabled, the app will not", + "check for updates.", + ], + }, + "wrap_around 1": { + "type": "wrap_around", + }, + "Disable Reporting": { + "type": "checkbox", + "value": global_settings.GlobalEnviromentSettings().read_property("DisableCrashAndAnalyticsReporting"), + "variable": "DisableCrashAndAnalyticsReporting", + "description": [ + "Disable crash and system reporting", + "When enabled, the app will not", + "report any info to Dortania.", + ], + "override_function": global_settings.GlobalEnviromentSettings().write_property, + }, + "Disable Unused KDKs": { + "type": "checkbox", + "value": self.constants.should_nuke_kdks, + "variable": "should_nuke_kdks", + "description": [ + "Disable unused KDKs", + "When enabled, the app will remove", + "unused KDKs from the system.", + ], + }, + }, } return settings - def _populate_model_selection(self, panel: wx.Frame) -> None: - # Set Override Model to top middle - model_choice = wx.Choice(panel, choices=model_array.SupportedSMBIOS + ["Host Model"] if self.constants.computer.real_model not in model_array.SupportedSMBIOS else model_array.SupportedSMBIOS, pos=(panel.GetSize()[0] / 2, 10)) - model_choice.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) - model_choice.Bind(wx.EVT_CHOICE, lambda event: self.on_model_choice(event, model_choice)) - selection = self.constants.custom_model if self.constants.custom_model else self.constants.computer.real_model - if selection not in model_array.SupportedSMBIOS: - selection = "Host Model" - model_choice.SetSelection(model_choice.FindString(selection)) - - # Set position to middle of panel - center = (panel.GetSize()[0] + 150) - model_choice.SetPosition((center, 10)) - - # Add label below Override Model - model_label = wx.StaticText(panel, label="Target Model", pos=(model_choice.GetPosition()[0] + 100, model_choice.GetSize()[1] + 20)) - model_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) - model_label.SetPosition((center + 20, model_choice.GetSize()[1] + 20)) - - # Description: Overrides system OCLP will build for - model_description = wx.StaticText(panel, label="Overrides system OCLP will build for.", pos=(model_choice.GetPosition()[0] + 100, model_choice.GetSize()[1] + 40)) - model_description.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) - model_description.SetPosition((model_label.GetPosition()[0] - 60, model_choice.GetSize()[1] + 40)) - def on_model_choice(self, event: wx.Event, model_choice: wx.Choice) -> None: @@ -264,6 +445,7 @@ class SettingsFrame(wx.Frame): logging.info(f"Using Custom Model: {selection}") self.constants.custom_model = selection defaults.GenerateDefaults(self.constants.custom_model, False, self.constants) + self.parent.build_button.Enable() self.parent.model_label.SetLabel(f"Model: {selection}") self.parent.model_label.Center(wx.HORIZONTAL) @@ -277,6 +459,133 @@ class SettingsFrame(wx.Frame): ) + def _populate_sip_settings(self, panel: wx.Frame) -> None: + + spacer = 280 + + # Title: System Integrity Protection + sip_title = wx.StaticText(panel, label="System Integrity Protection", pos=(-1, 10 + spacer)) + sip_title.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) + + # Label: Flip individual bits corresponding to XNU's csr.h + # If you're unfamiliar with how SIP works, do not touch this menu + sip_label = wx.StaticText(panel, label="Flip individual bits corresponding to", pos=(-1, sip_title.GetSize()[1] + 20 + spacer)) + sip_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + + # Hyperlink: csr.h + sip_csr_h = wx.adv.HyperlinkCtrl(panel, id=wx.ID_ANY, label="XNU's csr.h", url="https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/csr.h.auto.html", pos=(-1, sip_title.GetSize()[1] + 40 + spacer)) + sip_csr_h.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + + # Label: If you're unfamiliar with how SIP works, do not touch this menu + sip_description = wx.StaticText(panel, label="If you're unfamiliar with how SIP works, do not touch this menu", pos=(-1, sip_title.GetSize()[1] + 60 + spacer)) + sip_description.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) + + # Label: SIP Status + sip_status = wx.StaticText(panel, label="SIP Status", pos=(-1, sip_title.GetSize()[1] + 100 + spacer)) + sip_status.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) + + # Label: SIP Status Description + sip_status_description = wx.StaticText(panel, label="Displays the current status of SIP", pos=(-1, sip_title.GetSize()[1] + 120 + spacer)) + +# self.configure_sip_title = wx.StaticText(self.frame_modal, label="Configure SIP", pos=wx.Point(10, 10)) +# self.configure_sip_title.SetFont(wx.Font(19, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) +# self.configure_sip_title.Center(wx.HORIZONTAL) + +# # Label: Flip individual bits corresponding to XNU's csr.h +# # If you're unfamiliar with how SIP works, do not touch this menu +# self.sip_label = wx.StaticText(self.frame_modal, label="Flip individual bits corresponding to") +# self.sip_label.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_label.SetPosition( +# wx.Point(-1, self.configure_sip_title.GetPosition().y + self.configure_sip_title.GetSize().height + 10) +# ) +# self.sip_label.Center(wx.HORIZONTAL) +# self.sip_label.SetPosition( +# wx.Point(self.sip_label.GetPosition().x - 25, -1) +# ) + +# hyperlink_label = hyperlink.HyperLinkCtrl( +# self.frame_modal, +# -1, +# "XNU's csr.h", +# pos=(self.sip_label.GetPosition().x + self.sip_label.GetSize().width, self.sip_label.GetPosition().y), +# URL="https://github.com/apple/darwin-xnu/blob/main/bsd/sys/csr.h", +# ) +# hyperlink_label.SetForegroundColour(self.hyperlink_colour) +# hyperlink_label.SetColours( +# link=self.hyperlink_colour, +# visited=self.hyperlink_colour, +# rollover=self.hyperlink_colour, +# ) + +# if self.constants.custom_sip_value is not None: +# self.sip_value = int(self.constants.custom_sip_value, 16) +# elif self.constants.sip_status is True: +# self.sip_value = 0x00 +# else: +# self.sip_value = 0x803 + +# self.sip_label_2 = wx.StaticText(self.frame_modal, label=f"Currently configured SIP: {hex(self.sip_value)}") +# self.sip_label_2.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, ".AppleSystemUIFont")) +# self.sip_label_2.SetPosition( +# wx.Point(self.sip_label.GetPosition().x, self.sip_label.GetPosition().y + self.sip_label.GetSize().height + 10) +# ) +# self.sip_label_2.Center(wx.HORIZONTAL) + +# self.sip_label_2_2 = wx.StaticText(self.frame_modal, label=f"Currently Booted SIP: {hex(py_sip_xnu.SipXnu().get_sip_status().value)}") +# self.sip_label_2_2.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_label_2_2.SetPosition( +# wx.Point(self.sip_label_2.GetPosition().x, self.sip_label_2.GetPosition().y + self.sip_label_2.GetSize().height + 5) +# ) +# self.sip_label_2_2.Center(wx.HORIZONTAL) + +# self.sip_label_3 = wx.StaticText(self.frame_modal, label="For older Macs requiring root patching, we set SIP to\n be partially disabled (0x803) to allow root patching.") +# self.sip_label_3.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_label_3.SetPosition( +# wx.Point(self.sip_label_2_2.GetPosition().x, self.sip_label_2_2.GetPosition().y + self.sip_label_2_2.GetSize().height + 10) +# ) +# self.sip_label_3.Center(wx.HORIZONTAL) + +# self.sip_label_4 = wx.StaticText(self.frame_modal, label="This value (0x803) corresponds to the following bits in csr.h:") +# self.sip_label_4.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_label_4.SetPosition( +# wx.Point(self.sip_label_3.GetPosition().x, self.sip_label_3.GetPosition().y + self.sip_label_3.GetSize().height + 5) +# ) +# self.sip_label_4.Center(wx.HORIZONTAL) + +# self.sip_label_5 = wx.StaticText(self.frame_modal, label=" 0x1 - CSR_ALLOW_UNTRUSTED_KEXTS\n 0x2 - CSR_ALLOW_UNRESTRICTED_FS\n 0x800 - CSR_ALLOW_UNAUTHENTICATED_ROOT") +# self.sip_label_5.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_label_5.SetPosition( +# wx.Point(self.sip_label_4.GetPosition().x, self.sip_label_4.GetPosition().y + self.sip_label_4.GetSize().height + 7) +# ) +# self.sip_label_5.Center(wx.HORIZONTAL) + +# warning_string = """ +# OpenCore Legacy Patcher by default knows the most ideal +# SIP value for your system. Override this value only if you +# understand the consequences. Reckless usage of this +# menu can break your installation. +# """ +# self.sip_label_6 = wx.StaticText(self.frame_modal, label=warning_string) +# self.sip_label_6.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_label_6.SetPosition( +# wx.Point(self.sip_label_5.GetPosition().x, self.sip_label_5.GetPosition().y + self.sip_label_5.GetSize().height - 10) +# ) +# self.sip_label_6.Center(wx.HORIZONTAL) + +# i = -10 +# for sip_bit in sip_data.system_integrity_protection.csr_values_extended: +# self.sip_checkbox = wx.CheckBox(self.frame_modal, label=sip_data.system_integrity_protection.csr_values_extended[sip_bit]["name"]) +# self.sip_checkbox.SetFont(wx.Font(13, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, ".AppleSystemUIFont")) +# self.sip_checkbox.SetToolTip(f'Description: {sip_data.system_integrity_protection.csr_values_extended[sip_bit]["description"]}\nValue: {hex(sip_data.system_integrity_protection.csr_values_extended[sip_bit]["value"])}\nIntroduced in: macOS {sip_data.system_integrity_protection.csr_values_extended[sip_bit]["introduced_friendly"]}') +# self.sip_checkbox.SetPosition( +# wx.Point(70, self.sip_label_6.GetPosition().y + self.sip_label_6.GetSize().height + i) +# ) +# i = i + 20 +# self.sip_checkbox.Bind(wx.EVT_CHECKBOX, self.update_sip_value) +# if self.sip_value & sip_data.system_integrity_protection.csr_values_extended[sip_bit]["value"] == sip_data.system_integrity_protection.csr_values_extended[sip_bit]["value"]: +# self.sip_checkbox.SetValue(True) + + def on_checkbox(self, event: wx.Event, warning_pop: str = "", override_function: bool = False) -> None: """ """ @@ -288,23 +597,34 @@ class SettingsFrame(wx.Frame): event.GetEventObject().SetValue(not event.GetEventObject().GetValue()) return if override_function is True: - print(f"Overriding function: {self.settings['General'][label]['override_function']}") - self.settings["General"][label]["override_function"](self.settings["General"][label]["variable"], value) + self.settings[self._find_parent_for_key(label)][label]["override_function"](self.settings["General"][label]["variable"], value) return - self._update_setting(self.settings["General"][label]["variable"], value) + + self._update_setting(self.settings[self._find_parent_for_key(label)][label]["variable"], value) + if label == "Allow native models": + if gui_support.CheckProperties(self.constants).host_can_build() is True: + self.parent.build_button.Enable() + else: + self.parent.build_button.Disable() def on_spinctrl(self, event: wx.Event, label: str) -> None: """ """ value = event.GetEventObject().GetValue() - self._update_setting(self.settings["General"][label]["variable"], value) + self._update_setting(self.settings[self._find_parent_for_key(label)][label]["variable"], value) def _update_setting(self, variable, value): - print(f"Updating Setting: {variable} = {value}") + logging.info(f"Updating Setting: {variable} = {value}") setattr(self.constants, variable, value) + def _find_parent_for_key(self, key: str) -> str: + for parent in self.settings: + if key in self.settings[parent]: + return parent + + def on_return(self, event): self.frame_modal.Destroy() \ No newline at end of file