1717 utilities ,
1818 network_handler ,
1919)
20- KDK_API_LINK_ORIGIN :str = "https://dortania.github.io/KdkSupportPkg/manifest.json"
21- KDK_API_LINK_PROXY :str = "https://next.oclpapi.simplehac.cn/KdkSupportPkg/manifest.json"
2220class KDKDownloadFrame (wx .Frame ):
2321 def __init__ (self , parent : wx .Frame , title : str , global_constants : constants .Constants ,screen_location : tuple = None ):
2422 logging .info ("Initializing KDK Download Frame" )
2523 self .constants : constants .Constants = global_constants
2624 self .title : str = title
2725 self .parent : wx .Frame = parent
28- icon_path = str ( self . constants . icns_resource_path / "Package.icns" )
29- self .icons = [self ._icon_to_bitmap (icon_path ), self ._icon_to_bitmap (icon_path , (64 , 64 ))]
26+
27+ self .icons = [[ self ._icon_to_bitmap (icon_path ), self ._icon_to_bitmap (icon_path , (64 , 64 ))] for icon_path in self . constants . package_icns_paths ]
3028 self .repl = False
3129 self .path_validate = None
3230 self .retry_download :bool = False
@@ -42,8 +40,20 @@ def __init__(self, parent: wx.Frame, title: str, global_constants: constants.Con
4240 self .catalog_seed : sucatalog .SeedType = sucatalog .SeedType .DeveloperSeed
4341 self .frame_modal = wx .Dialog (parent , title = title , size = (330 , 200 ))
4442 self .on_download ()
43+
4544 def _icon_to_bitmap (self , icon : str , size : tuple = (32 , 32 )) -> wx .Bitmap :
4645 return wx .Bitmap (wx .Bitmap (icon , wx .BITMAP_TYPE_ICON ).ConvertToImage ().Rescale (size [0 ], size [1 ], wx .IMAGE_QUALITY_HIGH ))
46+
47+ def _macos_version_to_icon (self , version : int ) -> int :
48+ """
49+ Convert macOS version to icon(Package)
50+ """
51+ try :
52+ self .constants .package_icns_paths [version - 19 ]
53+ return version - 19
54+ except IndexError :
55+ return 0
56+
4757 def _generate_catalog_frame (self ) -> None :
4858 super (KDKDownloadFrame , self ).__init__ (None , title = self .title , size = (300 , 200 ), style = wx .DEFAULT_FRAME_STYLE & ~ (wx .RESIZE_BORDER | wx .MAXIMIZE_BOX ))
4959 gui_support .GenerateMenubar (self , self .constants ).generate ()
@@ -59,10 +69,7 @@ def _generate_catalog_frame(self) -> None:
5969 self .Show ()
6070 def _fetch_installers ():
6171 try :
62- if self .constants .github_proxy_link == "SimpleHac" :
63- KDK_API_LINK :str = KDK_API_LINK_PROXY
64- else :
65- KDK_API_LINK : str = KDK_API_LINK_ORIGIN
72+ KDK_API_LINK = self .constants .kdk_api_link
6673 response = requests .get (KDK_API_LINK ,verify = False )
6774 self .kdk_data = response .json ()
6875 self .kdk_data_latest = []
@@ -127,12 +134,14 @@ def _fetch_installers():
127134 self .on_return_to_main_menu ()
128135 else :
129136 self ._display_available_installers ()
137+
130138 def convert_size (self ,size_bytes ):
131139 for unit in ['B' , 'KB' , 'MB' , 'GB' ]:
132140 if size_bytes < 1024.0 :
133141 return f"{ size_bytes :.2f} { unit } "
134142 size_bytes /= 1024.0
135143 return f"{ size_bytes :.2f} TB"
144+
136145 def detect_os_build (self , rsr : bool = False ) -> str :
137146 import plistlib
138147 file_path = "/System/Library/CoreServices/SystemVersion.plist"
@@ -142,13 +151,14 @@ def detect_os_build(self, rsr: bool = False) -> str:
142151 return plistlib .load (open (file_path , "rb" ))["ProductBuildVersion" ]
143152 except Exception as e :
144153 raise RuntimeError (f"Failed to detect OS build: { e } " )
154+
145155 def _display_available_installers (self , event : wx .Event = None , show_full : bool = False ) -> None :
146156 if show_full :
147157 self .show_fully = True
148158 else :
149159 self .show_fully = False
150160 self .os_build_tahoe = self .detect_os_build (False )
151- bundles = [wx .BitmapBundle .FromBitmaps (self .icons ) ]
161+ bundles = [wx .BitmapBundle .FromBitmaps (icon ) for icon in self .icons ]
152162 self .frame_modal .Destroy ()
153163 self .frame_modal = wx .Dialog (self , title = "Choose KDK Version" , size = (500 , 580 ))
154164 title_label = wx .StaticText (self .frame_modal , label = "Choose KDKs" , pos = (- 1 ,- 1 ))
@@ -178,7 +188,7 @@ def _display_available_installers(self, event: wx.Event = None, show_full: bool
178188 logging .info (f"- { item ['name' ]} (macOS { item ['version' ]} - { item ['build' ]} ):\n - Size: { self .convert_size (item ['fileSize' ])} \n - Link: { item ['url' ]} \n " )
179189 version = re .search (r'^\d+' , item ['version' ])
180190 index = self .list .InsertItem (self .list .GetItemCount (), f"macOS { xnu_name [version .group ()]} " )
181- self .list .SetItemImage (index , 0 )
191+ self .list .SetItemImage (index , self . _macos_version_to_icon ( int ( item [ 'build' ][: 2 ])) )
182192 self .list .SetItem (index , 1 , f"{ item ['version' ]} " )
183193 self .list .SetItem (index , 2 , f"{ item ['build' ]} " )
184194 self .list .SetItem (index , 3 , f"{ self .convert_size (item ['fileSize' ])} " )
@@ -280,7 +290,7 @@ def is_dir_writable(dirpath):
280290 global_constants = self .constants ,
281291 download_obj = download_obj ,
282292 item_name = f"KDK { selected_installer ['version' ]} { selected_installer ['build' ]} " ,
283- download_icon = str ( self .constants .icns_resource_path / "Package.icns" )
293+ download_icon = self .constants .package_icns_paths [ self . _macos_version_to_icon ( int ( selected_installer [ 'build' ][: 2 ]))]
284294 )
285295 if download_obj .download_complete is False :
286296 import os
0 commit comments