@@ -27,7 +27,7 @@ class Content(IntEnum):
2727
2828
2929class CrimeBossModDataContent (mobase .ModDataContent ):
30- contents : list [int ] = []
30+ content : list [int ] = []
3131 GAMECONTENTS : list [tuple [Content , str , str , bool ] | tuple [Content , str , str ]] = [
3232 (Content .UCAS , "UCAS" , ":/MO/gui/content/geometries" ),
3333 (Content .UTOC , "UTOC" , ":/MO/gui/content/inifile" ),
@@ -44,15 +44,15 @@ def walkContent(self, path: str, entry: mobase.FileTreeEntry):
4444 if entry .isFile ():
4545 match entry .suffix ().casefold ():
4646 case "utoc" :
47- self .contents . add (Content .UTOC )
47+ self .content . append (Content .UTOC )
4848 case "ucas" :
49- self .contents . add (Content .UCAS )
49+ self .content . append (Content .UCAS )
5050 case "pak" :
51- self .contents . add (Content .PAK )
51+ self .content . append (Content .PAK )
5252 case "lua" :
53- self .contents . add (Content .UE4SS )
53+ self .content . append (Content .UE4SS )
5454 case "dll" :
55- self .contents . add (Content .DLL )
55+ self .content . append (Content .DLL )
5656 case "bk2" :
5757 self .contents .add (Content .BK2 )
5858 case _:
@@ -72,7 +72,7 @@ def __init__(self, organizer: mobase.IOrganizer):
7272 self .organizer .modList ().onModInstalled (self ._Fix_Installed_Mod )
7373 self .needsNameFix = False
7474
75- def move_overwrite_merge (self , source , destination ):
75+ def move_overwrite_merge (self , source : str , destination : str ):
7676 if not os .path .exists (destination ):
7777 shutil .move (source , destination )
7878 return
@@ -88,11 +88,11 @@ def move_overwrite_merge(self, source, destination):
8888 def _Fix_Installed_Mod (self , mod : mobase .IModInterface ):
8989 if not self .needsNameFix :
9090 return
91- GameDataNativeMods = self .organizer .managedGame (). GameDataNativeMods
91+ GameDataNativeMods = getattr ( self .organizer .managedGame (), " GameDataNativeMods" , "" )
9292 filetree : mobase .IFileTree = mod .fileTree ()
9393 fixed = False
9494 modname = mod .name ()
95- if filetree is not None and filetree .exists (GameDataNativeMods + "/FOLDERNAME" , mobase .IFileTree .DIRECTORY ):
95+ if filetree .exists (GameDataNativeMods + "/FOLDERNAME" , mobase .IFileTree .DIRECTORY ):
9696 path = mod .absolutePath ()
9797 old_path = os .path .join (path , GameDataNativeMods + "/FOLDERNAME" )
9898 new_path = os .path .join (path , GameDataNativeMods + f"/{ modname } " )
@@ -103,41 +103,43 @@ def _Fix_Installed_Mod(self, mod: mobase.IModInterface):
103103 self .needsNameFix = False
104104
105105 def dataLooksValid (self , filetree : mobase .IFileTree ) -> mobase .ModDataChecker .CheckReturn :
106- GameDataUE4SSMods = self .organizer .managedGame ().GameDataUE4SSMods
107- GameDataPakMods = self .organizer .managedGame ().GameDataPakMods
108- GameDataNativeMods = self .organizer .managedGame ().GameDataNativeMods
106+ GameDataUE4SSMods = getattr (self .organizer .managedGame (), "GameDataUE4SSMods" , "" )
107+ GameDataPakMods = getattr (self .organizer .managedGame (), "GameDataPakMods" , "" )
108+ GameDataNativeMods = getattr (self .organizer .managedGame (), "GameDataNativeMods" , "" )
109+ GameDataMovies = getattr (self .organizer .managedGame (), "GameDataMovies" , "" )
109110 if filetree .exists (GameDataPakMods , mobase .IFileTree .DIRECTORY ):
110111 return mobase .ModDataChecker .VALID
111112 if filetree .exists (os .path .dirname (GameDataUE4SSMods ), mobase .IFileTree .DIRECTORY ):
112113 return mobase .ModDataChecker .VALID
113114 if filetree .exists (GameDataNativeMods , mobase .IFileTree .DIRECTORY ) and not filetree .exists ("UE4SS.dll" , mobase .IFileTree .FILE ):
114115 return mobase .ModDataChecker .VALID
116+ if filetree .exists (GameDataMovies , mobase .IFileTree .DIRECTORY ):
117+ return mobase .ModDataChecker .VALID
115118 return mobase .ModDataChecker .FIXABLE
116119
117120 def fileExistsInNextSubDir (self , filetree : mobase .IFileTree , name : str ):
118121 for branch in filetree :
119- if branch is not None and branch . isDir ( ):
122+ if isinstance ( branch , mobase . IFileTree ):
120123 for e in branch :
121- if e is not None and e .name () == name :
124+ if e .name () == name :
122125 return True
123126 return False
124127
125128 def allMoveTo (self , filetree : mobase .IFileTree , toMoveTo : str ):
126129 entriesToMove : list [mobase .FileTreeEntry ] = []
127130 retVal = 0
128131 for e in filetree :
129- if e is not None :
130- entriesToMove .append (e )
132+ entriesToMove .append (e )
131133 for e in entriesToMove :
132134 filetree .move (e , toMoveTo , mobase .IFileTree .MERGE )
133135 retVal = 1
134136 return retVal
135137
136- def fix (self , filetree : mobase .IFileTree ) -> mobase .IFileTree :
137- GameDataUE4SSMods = self .organizer .managedGame (). GameDataUE4SSMods + "/"
138- GameDataPakMods = self .organizer .managedGame (). GameDataPakMods + "/"
139- GameDataNativeMods = self .organizer .managedGame (). GameDataNativeMods + "/"
140- GameDataMovies = self .organizer .managedGame (). GameDataMovies + "/"
138+ def fix (self , filetree : mobase .IFileTree ) -> mobase .IFileTree | None :
139+ GameDataUE4SSMods = getattr ( self .organizer .managedGame (), " GameDataUE4SSMods" , "" ) + "/"
140+ GameDataPakMods = getattr ( self .organizer .managedGame (), " GameDataPakMods" , "" ) + "/"
141+ GameDataNativeMods = getattr ( self .organizer .managedGame (), " GameDataNativeMods" , "" ) + "/"
142+ GameDataMovies = getattr ( self .organizer .managedGame (), " GameDataMovies" , "" ) + "/"
141143 treefixed = 0
142144 if filetree .exists ("UE4SS.dll" , mobase .IFileTree .FILE ):
143145 treefixed = self .allMoveTo (filetree , os .path .dirname (os .path .dirname (GameDataUE4SSMods )) + "/" )
@@ -154,28 +156,27 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
154156 allowedUnzippedExt = ["pak" , "utoc" , "ucas" , "bk2" , "dll" ]
155157 entriesToMove : list [mobase .FileTreeEntry ] = []
156158 for e in filetree :
157- if e is not None :
158- if e .isFile ():
159- fileext = e .suffix ().casefold ()
160- if fileext in allowedUnzippedExt :
161- mod_name = filetree .name ()
162- if mod_name == "" :
163- mod_name = e .name ()
164- mod_path = os .path .join (self .organizer .modsPath (), mod_name )
165- if filetree .createOrphanTree ("OrphanTree" ) is None and os .path .exists (mod_path ):
166- match e .suffix ().casefold ():
167- case "pak" | "utoc" | "ucas" :
168- os .makedirs (os .path .join (mod_path , GameDataPakMods ), exist_ok = True )
169- shutil .move (os .path .join (mod_path , e .name ()), os .path .join (mod_path , GameDataPakMods , e .name ()))
170- case "bk2" :
171- os .makedirs (os .path .join (mod_path , GameDataMovies ), exist_ok = True )
172- shutil .move (os .path .join (mod_path , e .name ()), os .path .join (mod_path , GameDataMovies , e .name ()))
173- case _:
174- pass
175- treefixed = 1
176- else :
177- entriesToMove .append (e )
178- if entriesToMove is not None :
159+ if e .isFile ():
160+ fileext = e .suffix ().casefold ()
161+ if fileext in allowedUnzippedExt :
162+ mod_name = filetree .name ()
163+ if mod_name == "" :
164+ mod_name = e .name ()
165+ mod_path = os .path .join (self .organizer .modsPath (), mod_name )
166+ if not filetree .createOrphanTree ("OrphanTree" ) and os .path .exists (mod_path ):
167+ match e .suffix ().casefold ():
168+ case "pak" | "utoc" | "ucas" :
169+ os .makedirs (os .path .join (mod_path , GameDataPakMods ), exist_ok = True )
170+ shutil .move (os .path .join (mod_path , e .name ()), os .path .join (mod_path , GameDataPakMods , e .name ()))
171+ case "bk2" :
172+ os .makedirs (os .path .join (mod_path , GameDataMovies ), exist_ok = True )
173+ shutil .move (os .path .join (mod_path , e .name ()), os .path .join (mod_path , GameDataMovies , e .name ()))
174+ case _:
175+ pass
176+ treefixed = 1
177+ else :
178+ entriesToMove .append (e )
179+ if entriesToMove :
179180 for e in entriesToMove :
180181 match e .suffix ().casefold ():
181182 case "pak" | "utoc" | "ucas" :
0 commit comments