From 1fba4901c485f1e5a59cb35840d1002b866494d9 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Fri, 1 Jul 2022 22:24:54 -0600 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=98Allow=20native=20models=E2=80=99?= =?UTF-8?q?=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ data/os_data.py | 64 ++++++++++++++++++++++++++++++++++++------------- gui/gui_main.py | 15 ++++++++++++ 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aede60371..82085f665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - ie. M2 specific build (21F2092) - Avoid adding OpenCore icon in boot picker if Windows bootloader on same partition - Add error-handling to corrupt/non-standard NVRAM variables +- Add warning prompt when using 'Allow native models' + - Attempt to avoid misuse of option ## 0.4.7 - Fix crashing on defaults parsing diff --git a/data/os_data.py b/data/os_data.py index 65dbd5bc8..92952c3b2 100644 --- a/data/os_data.py +++ b/data/os_data.py @@ -3,22 +3,26 @@ import enum class os_data(enum.IntEnum): # OS Versions, Based off Major Kernel Version - tiger = 8 - leopard = 9 - snow_leopard = 10 - lion = 11 + cheetah = 4 # Actually 1.3.1 + puma = 5 + jaguar = 6 + panther = 7 + tiger = 8 + leopard = 9 + snow_leopard = 10 + lion = 11 mountain_lion = 12 - mavericks = 13 - yosemite = 14 - el_capitan = 15 - sierra = 16 - high_sierra = 17 - mojave = 18 - catalina = 19 - big_sur = 20 - monterey = 21 - ventura = 22 - max_os = 99 + mavericks = 13 + yosemite = 14 + el_capitan = 15 + sierra = 16 + high_sierra = 17 + mojave = 18 + catalina = 19 + big_sur = 20 + monterey = 21 + ventura = 22 + max_os = 99 class os_conversion: @@ -45,4 +49,32 @@ class os_conversion: if source_minor < target_minor: return True else: - return False \ No newline at end of file + return False + + def convert_kernel_to_marketing_name(kernel): + # Convert major XNU version to Marketing Name + try: + # Find os_data enum name + os_name = os_data(kernel).name + + # Remove "_" from the string + os_name = os_name.replace("_", " ") + + # Upper case the first letter of each word + os_name = os_name.title() + except ValueError: + # Handle cases where no enum value exists + # Pass kernel_to_os() as a substitute for a proper OS name + os_name = os_conversion.kernel_to_os(kernel) + + return os_name + + def convert_marketing_name_to_kernel(marketing_name): + # Convert Marketing Name to major XNU version + try: + # Find os_data enum value + os_kernel = os_data[marketing_name.lower().replace(" ", "_")] + except KeyError: + os_kernel = 0 + + return int(os_kernel) \ No newline at end of file diff --git a/gui/gui_main.py b/gui/gui_main.py index 9c5576d6d..1dbc373e6 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -2175,6 +2175,21 @@ class wx_python_gui: def allow_native_models_click(self, event=None): if self.checkbox_allow_native_models.GetValue(): + # Throw a prompt warning about this + dlg = wx.MessageDialog(self.frame_modal, "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 sure you want to continue?", "Warning", wx.YES_NO | wx.ICON_WARNING) + if dlg.ShowModal() == wx.ID_NO: + self.checkbox_allow_native_models.SetValue(False) + return + # If the system is running an unsupported OS, throw a second warning + if self.constants.computer.real_model in smbios_data.smbios_dictionary: + if self.constants.detected_os > smbios_data.smbios_dictionary[self.constants.computer.real_model]["Max OS Supported"]: + chassis_type = "aluminum" + if self.constants.computer.real_model in ["MacBook4,1", "MacBook5,2", "MacBook6,1", "MacBook7,1"]: + chassis_type = "plastic" + dlg = wx.MessageDialog(self.frame_modal, f"This model, {self.constants.computer.real_model}, does not natively support macOS {os_data.os_conversion.kernel_to_os(self.constants.detected_os)}, {os_data.os_conversion.convert_kernel_to_marketing_name(self.constants.detected_os)}. The last native OS was macOS {os_data.os_conversion.kernel_to_os(smbios_data.smbios_dictionary[self.constants.computer.real_model]['Max OS Supported'])}, {os_data.os_conversion.convert_kernel_to_marketing_name(smbios_data.smbios_dictionary[self.constants.computer.real_model]['Max OS Supported'])}\n\nToggling this option will breaking booting on this OS. Are you absolutely certain this is desired?\n\nYou may end up with a nice {chassis_type} brick 🧱", "Are you certain?", wx.YES_NO | wx.ICON_WARNING) + if dlg.ShowModal() == wx.ID_NO: + self.checkbox_allow_native_models.SetValue(False) + return print("Allow Native Models") self.constants.allow_oc_everywhere = True self.constants.serial_settings = "None"