11import os
2+ from pathlib import Path
23from typing import List , Tuple
34
45from loguru import logger
1415
1516
1617class SupercellSWF :
17- TEXTURES_TAGS = (1 , 16 , 28 , 29 , 34 , 19 , 24 , 27 , 45 )
18+ TEXTURES_TAGS = (1 , 16 , 28 , 29 , 34 , 19 , 24 , 27 , 45 , 47 )
1819 SHAPES_TAGS = (2 , 18 )
19- MOVIE_CLIPS_TAGS = (3 , 10 , 12 , 14 , 35 )
20+ MOVIE_CLIPS_TAGS = (3 , 10 , 12 , 14 , 35 , 49 )
2021
2122 TEXTURE_EXTENSION = "_tex.sc"
2223
2324 def __init__ (self ):
24- self .filename : str
25- self .reader : Reader
25+ self .filename : str | None = None
26+ self .reader : Reader | None = None
2627
2728 self .use_lowres_texture : bool = False
2829
@@ -32,8 +33,8 @@ def __init__(self):
3233
3334 self .xcod_writer = Writer ("big" )
3435
35- self ._filepath : str
36- self ._uncommon_texture_path : str
36+ self ._filepath : Path | None = None
37+ self ._uncommon_texture_path : str | os . PathLike | None = None
3738
3839 self ._lowres_suffix : str = DEFAULT_LOWRES_SUFFIX
3940 self ._highres_suffix : str = DEFAULT_HIGHRES_SUFFIX
@@ -50,13 +51,13 @@ def __init__(self):
5051 self ._export_names : List [str ] = []
5152
5253 self ._matrix_banks : List [MatrixBank ] = []
53- self ._matrix_bank : MatrixBank
54+ self ._matrix_bank : MatrixBank | None = None
5455
5556 def load (self , filepath : str | os .PathLike ) -> Tuple [bool , bool ]:
56- self ._filepath = str (filepath )
57+ self ._filepath = Path (filepath )
5758
5859 texture_loaded , use_lzham = self ._load_internal (
59- self ._filepath , self ._filepath .endswith ("_tex.sc" )
60+ self ._filepath , self ._filepath .name . endswith ("_tex.sc" )
6061 )
6162
6263 if not texture_loaded :
@@ -65,12 +66,14 @@ def load(self, filepath: str | os.PathLike) -> Tuple[bool, bool]:
6566 self ._uncommon_texture_path , True
6667 )
6768 else :
68- texture_path = self ._filepath [:- 3 ] + SupercellSWF .TEXTURE_EXTENSION
69+ texture_path = str ( self ._filepath ) [:- 3 ] + SupercellSWF .TEXTURE_EXTENSION
6970 texture_loaded , use_lzham = self ._load_internal (texture_path , True )
7071
7172 return texture_loaded , use_lzham
7273
73- def _load_internal (self , filepath : str , is_texture_file : bool ) -> Tuple [bool , bool ]:
74+ def _load_internal (
75+ self , filepath : str | os .PathLike , is_texture_file : bool
76+ ) -> Tuple [bool , bool ]:
7477 self .filename = os .path .basename (filepath )
7578
7679 logger .info (locale .collecting_inf % self .filename )
@@ -180,12 +183,12 @@ def _load_tags(self, is_texture_file: bool) -> bool:
180183 elif tag == 30 :
181184 self ._use_uncommon_texture = True
182185 highres_texture_path = (
183- self ._filepath [:- 3 ]
186+ str ( self ._filepath ) [:- 3 ]
184187 + self ._highres_suffix
185188 + SupercellSWF .TEXTURE_EXTENSION
186189 )
187190 lowres_texture_path = (
188- self ._filepath [:- 3 ]
191+ str ( self ._filepath ) [:- 3 ]
189192 + self ._lowres_suffix
190193 + SupercellSWF .TEXTURE_EXTENSION
191194 )
@@ -231,3 +234,7 @@ def get_display_object(
231234
232235 def get_matrix_bank (self , index : int ) -> MatrixBank :
233236 return self ._matrix_banks [index ]
237+
238+ @property
239+ def filepath (self ) -> Path :
240+ return self ._filepath
0 commit comments