This commit is contained in:
Jazzzny
2023-09-26 21:24:16 -04:00
parent 6bb274638e
commit 89e36d762b
3 changed files with 50 additions and 23 deletions
+31 -2
View File
@@ -119,6 +119,7 @@ class Constants:
self.original_path: Path = Path(__file__).parent.parent.resolve()
self.payload_path: Path = self.current_path / Path("payloads")
# Patcher Settings
## Internal settings
self.allow_oc_everywhere: bool = False # Set whether Patcher can be run on unsupported Macs
@@ -235,6 +236,14 @@ class Constants:
os_data.os_data.ventura,
]
self.icons_path = [
str(self.icon_path_macos_generic),
str(self.icon_path_macos_big_sur),
str(self.icon_path_macos_monterey),
str(self.icon_path_macos_ventura),
str(self.icon_path_macos_sonoma)
]
@property
def special_build(self):
"""
@@ -679,7 +688,27 @@ class Constants:
@property
def icon_path_ssd(self):
return self.payload_path / Path("Icon/SSD/.VolumeIcon.icns")
@property
def icon_path_macos_generic(self):
return self.payload_path / Path("Icon/AppIcons/Generic.icns")
@property
def icon_path_macos_big_sur(self):
return self.payload_path / Path("Icon/AppIcons/BigSur.icns")
@property
def icon_path_macos_monterey(self):
return self.payload_path / Path("Icon/AppIcons/Monterey.icns")
@property
def icon_path_macos_ventura(self):
return self.payload_path / Path("Icon/AppIcons/Ventura.icns")
@property
def icon_path_macos_sonoma(self):
return self.payload_path / Path("Icon/AppIcons/Sonoma.icns")
@property
def gui_path(self):
return self.payload_path / Path("Icon/Resources.zip")
@@ -741,4 +770,4 @@ class Constants:
"Mac-942B59F58194171B", # iMac12,2
"Mac-94245AF5819B141B", # AppleInternal MacBookPro8,3
"Mac-942B5B3A40C91381", # AppleInternal iMac12,2
]
]
+1 -1
View File
@@ -50,7 +50,7 @@ class DownloadFrame(wx.Frame):
title_label.SetFont(gui_support.font_factory(19, wx.FONTWEIGHT_BOLD))
title_label.Centre(wx.HORIZONTAL)
progress_bar = wx.Gauge(frame, range=100, pos=(-1, title_label.GetPosition()[1] + title_label.GetSize()[1] + 5), size=(300, 20), style=wx.GA_PROGRESS| wx.GA_SMOOTH)
progress_bar = wx.Gauge(frame, range=100, pos=(-1, title_label.GetPosition()[1] + title_label.GetSize()[1] + 5), size=(300, 20))
progress_bar.Centre(wx.HORIZONTAL)
label_amount = wx.StaticText(frame, label="Preparing download", pos=(-1, progress_bar.GetPosition()[1] + progress_bar.GetSize()[1]))
@@ -44,21 +44,22 @@ class macOSInstallerDownloadFrame(wx.Frame):
self._generate_elements(self.frame_modal)
self.frame_modal.ShowWindowModal()
self.icons_path = [
str(self.constants.icns_resource_path / "Generic.icns"),
str(self.constants.icns_resource_path / "BigSur.icns"),
str(self.constants.icns_resource_path / "Monterey.icns"),
str(self.constants.icns_resource_path / "Ventura.icns"),
str(self.constants.icns_resource_path / "Sonoma.icns")
]
self.icons = [[self._icon_to_bitmap(i), self._icon_to_bitmap(i, (64, 64))] for i in self.constants.icons_path]
self.icons = [
[wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Generic.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(32, 32, wx.IMAGE_QUALITY_HIGH)),wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Generic.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(64, 64, wx.IMAGE_QUALITY_HIGH))],
[wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "BigSur.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(32, 32, wx.IMAGE_QUALITY_HIGH)),wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "BigSur.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(64, 64, wx.IMAGE_QUALITY_HIGH))],
[wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Monterey.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(32, 32, wx.IMAGE_QUALITY_HIGH)),wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Monterey.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(64, 64, wx.IMAGE_QUALITY_HIGH))],
[wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Ventura.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(32, 32, wx.IMAGE_QUALITY_HIGH)),wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Ventura.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(64, 64, wx.IMAGE_QUALITY_HIGH))],
[wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Sonoma.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(32, 32, wx.IMAGE_QUALITY_HIGH)),wx.Bitmap(wx.Bitmap(str(self.constants.icns_resource_path / "Sonoma.icns"),wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(64, 64, wx.IMAGE_QUALITY_HIGH))]
]
def _icon_to_bitmap(self, icon: str, size: tuple = (32, 32)) -> wx.Bitmap:
"""
Convert icon to bitmap
"""
return wx.Bitmap(wx.Bitmap(icon, wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(size[0], size[1], wx.IMAGE_QUALITY_HIGH))
def _macos_version_to_icon(self, version: int) -> int:
"""
Convert macOS version to icon
"""
if version < os_data.os_data.big_sur or version > os_data.os_data.sonoma:
return 0
else:
return version - 19
def _generate_elements(self, frame: wx.Frame = None) -> None:
@@ -173,10 +174,7 @@ class macOSInstallerDownloadFrame(wx.Frame):
extra = " Beta" if installers[item]['Variant'] in ["DeveloperSeed" , "PublicSeed"] else ""
logging.info(f"- macOS {installers[item]['Version']} ({installers[item]['Build']}):\n - Size: {utilities.human_fmt(installers[item]['Size'])}\n - Source: {installers[item]['Source']}\n - Variant: {installers[item]['Variant']}\n - Link: {installers[item]['Link']}\n")
index = self.list.InsertItem(self.list.GetItemCount(), f"macOS {installers[item]['Version']} {os_data.os_conversion.convert_kernel_to_marketing_name(int(installers[item]['Build'][:2]))}{extra} ({installers[item]['Build']})")
if int(installers[item]['Build'][:2]) > os_data.os_data.sonoma:
self.list.SetItemImage(index, 0)
else:
self.list.SetItemImage(index, int(installers[item]['Build'][:2])-19) # Darwin version to index conversion. i.e. Darwin 20 -> 1 -> BigSur.icns
self.list.SetItemImage(index, self._macos_version_to_icon(int(installers[item]['Build'][:2])))
self.list.SetItem(index, 1, utilities.human_fmt(installers[item]['Size']))
self.list.SetItem(index, 2, installers[item]['Date'].strftime("%x"))
@@ -315,7 +313,7 @@ class macOSInstallerDownloadFrame(wx.Frame):
global_constants=self.constants,
download_obj=download_obj,
item_name=f"macOS {list(installers.values())[selected_item]['Version']} ({list(installers.values())[selected_item]['Build']})",
download_icon=self.icons_path[int(list(installers.values())[selected_item]['Build'][:2])-19] if int(list(installers.values())[selected_item]['Build'][:2]) <= os_data.os_data.sonoma else self.icons_path[0]
download_icon=self.constants.icons_path[self._macos_version_to_icon(int(list(installers.values())[selected_item]['Build'][:2]))]
)
if download_obj.download_complete is False:
@@ -324,7 +322,7 @@ class macOSInstallerDownloadFrame(wx.Frame):
self._validate_installer(list(installers.values())[selected_item]['integrity'])
def _validate_installer(self, chunklist_link: str) -> None:
"""
Validate macOS installer