@@ -49,8 +49,8 @@ def set_theme_path(cls,path, width = 0, height = 0):
4949 cls ._load_from_file (os .path .join (path , config_path ))
5050
5151 cls ._path = path
52- cls ._skin_folder = cls ._get_asset_folder ("skin" , width , height )
53- cls ._icon_folder = cls ._get_asset_folder ("icons" , width , height )
52+ cls ._skin_folder = cls ._get_asset_folder (cls . _path , "skin" , width , height )
53+ cls ._icon_folder = cls ._get_asset_folder (cls . _path , "icons" , width , height )
5454 daijisho_theme_index_file = os .path .join (cls ._path , cls ._icon_folder ,"index.json" )
5555 if os .path .exists (daijisho_theme_index_file ):
5656 try :
@@ -132,17 +132,17 @@ def load_defaults_so_user_can_see_at_least(cls, path):
132132 cls ._load_from_file (os .path .join (path , "config.json" ))
133133
134134 cls ._path = path
135- cls ._skin_folder = cls ._get_asset_folder ("skin" , - 1 , - 1 )
136- cls ._icon_folder = cls ._get_asset_folder ("icons" , - 1 , - 1 )
135+ cls ._skin_folder = cls ._get_asset_folder (cls . _path , "skin" , - 1 , - 1 )
136+ cls ._icon_folder = cls ._get_asset_folder (cls . _path , "icons" , - 1 , - 1 )
137137
138138 @classmethod
139139 def get_theme_path (cls ):
140140 return cls ._path
141141
142142 @classmethod
143- def _get_asset_folder (cls , base_folder , width , height ):
143+ def _get_asset_folder (cls , path , base_folder , width , height ):
144144 folder = f"{ base_folder } _{ width } x{ height } "
145- full_path = os .path .join (cls . _path , folder )
145+ full_path = os .path .join (path , folder )
146146 if os .path .isdir (full_path ):
147147 #PyUiLogger.get_logger().info(f"Resolution specific assets found, using {folder}")
148148 return folder
@@ -1508,3 +1508,31 @@ def check_and_create_ra_assets(cls):
15081508 1.00 )
15091509
15101510
1511+
1512+ @classmethod
1513+ def get_cfw_default_icon (cls , icon_name ):
1514+ cfw_theme = PyUiConfig .get ("theme" )
1515+ PyUiLogger .get_logger ().debug (f"Getting CFW default icon '{ icon_name } ' for theme '{ cfw_theme } '" )
1516+ if (cfw_theme is None ):
1517+ PyUiLogger .get_logger ().debug (f"CFW theme is None, cannot get icon" )
1518+ return None
1519+ else :
1520+ cfw_theme_path = os .path .join (PyUiConfig .get ("themeDir" ),cfw_theme )
1521+ PyUiLogger .get_logger ().debug (f"cfw_theme_path is '{ cfw_theme_path } '" )
1522+ path = os .path .join (cfw_theme_path ,
1523+ cls ._get_asset_folder (cfw_theme_path , "icons" ,
1524+ Device .screen_width (),
1525+ Device .screen_height ()),
1526+ "app" ,icon_name )
1527+
1528+ PyUiLogger .get_logger ().debug (f"icon path resolved to '{ path } '" )
1529+ if os .path .exists (path ):
1530+ return path
1531+
1532+ # Fallback only makes sense for .qoi assets/icons
1533+ if path .endswith (".qoi" ):
1534+ png_path = path [:- 4 ] + ".png"
1535+ if os .path .exists (png_path ):
1536+ return png_path
1537+
1538+ return None
0 commit comments