Skip to content

Commit cf77b29

Browse files
committed
Refactor mod data checker to use GameDataUE4SSRoot for mod paths
1 parent 7bdcbcf commit cf77b29

17 files changed

Lines changed: 88 additions & 71 deletions

games/game_batmanlegacy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_crimeboss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def dataLooksValid(
142142
self, filetree: mobase.IFileTree
143143
) -> mobase.ModDataChecker.CheckReturn:
144144
GameDataUE4SSMods = getattr(
145-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
145+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
146146
)
147147
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
148148
GameDataNativeMods = getattr(
@@ -253,7 +253,7 @@ def collectModCandidates(
253253
entryext = "None"
254254

255255
GameDataUE4SSRootDir = getattr(
256-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
256+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
257257
)
258258
GameDataPakModsDir = getattr(
259259
self.organizer.managedGame(), "GameDataPakMods", ""

games/game_enotria.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_goatsimulator3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_goatsimulatorremaster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_gothamknights.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_littlenightmares1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_littlenightmares2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_littlenightmares3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def dataLooksValid(
120120
self, filetree: mobase.IFileTree
121121
) -> mobase.ModDataChecker.CheckReturn:
122122
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
123+
getattr(self.organizer.managedGame(), "GameDataUE4SSRoot", "") + "/Mods"
124124
)
125125
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126126
GameDataMovieMods = getattr(
@@ -229,7 +229,7 @@ def collectModCandidates(
229229
category = None
230230
entryext = "None"
231231
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
232+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233233
)
234234
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235235
GameDataPakModsDir = getattr(

games/game_marvelrivals.py

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
from PyQt6.QtWidgets import (
1111
QDialog,
1212
QDialogButtonBox,
13+
QHBoxLayout,
1314
QLabel,
1415
QListWidget,
1516
QListWidgetItem,
1617
QMainWindow,
18+
QPushButton,
1719
QTabWidget,
1820
QVBoxLayout,
1921
QWidget,
@@ -113,14 +115,14 @@ def sanitizeFolderName(self, name: str) -> str:
113115
name = "".join(c for c in name if ord(c) >= 32)
114116
name = name.rstrip(". ")
115117
if not name:
116-
name = "FOLDERNAME"
118+
name = "Mod"
117119
return name
118120

119121
def dataLooksValid(
120122
self, filetree: mobase.IFileTree
121123
) -> mobase.ModDataChecker.CheckReturn:
122-
GameDataUE4SSMods = (
123-
getattr(self.organizer.managedGame(), "GameDataUE4SSMods", "") + "/Mods"
124+
GameDataUE4SSMods = getattr(
125+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
124126
)
125127
GameDataPakMods = getattr(self.organizer.managedGame(), "GameDataPakMods", "")
126128
GameDataMovieMods = getattr(
@@ -145,8 +147,8 @@ def moveTreeContent(
145147
targettree.move(entry, destination, mobase.IFileTree.MERGE)
146148
elif installtype == "os":
147149
if isinstance(entry, mobase.IFileTree):
148-
for element in entry:
149-
mod_file = element.name()
150+
for subentry in entry:
151+
mod_file = subentry.name()
150152
mod_name = entry.name()
151153
mod_path = os.path.join(self.organizer.modsPath(), mod_name)
152154
insideMods = os.path.join(mod_path, destination)
@@ -167,7 +169,7 @@ def addModDetectionCandidate(
167169
destination: str,
168170
installtype: str,
169171
) -> None:
170-
tree_name = tree.name()
172+
tree_name = self.sanitizeFolderName(tree.name())
171173

172174
self.modDetectionCandidates.append(
173175
{
@@ -178,6 +180,9 @@ def addModDetectionCandidate(
178180
"installtype": installtype,
179181
}
180182
)
183+
print(
184+
f"Added mod detection candidate: {tree_name} as {category} with install type {installtype} and destination {destination}"
185+
)
181186

182187
def showModDetectionDialog(self) -> set[int] | None:
183188
if not self.modDetectionCandidates:
@@ -199,6 +204,19 @@ def showModDetectionDialog(self) -> set[int] | None:
199204

200205
layout.addWidget(listWidget)
201206

207+
selectButtons = QHBoxLayout()
208+
selectAllButton = QPushButton("Select All")
209+
selectNoneButton = QPushButton("Select None")
210+
selectAllButton.clicked.connect(
211+
lambda: self.setDialogSelection(listWidget, True)
212+
)
213+
selectNoneButton.clicked.connect(
214+
lambda: self.setDialogSelection(listWidget, False)
215+
)
216+
selectButtons.addWidget(selectAllButton)
217+
selectButtons.addWidget(selectNoneButton)
218+
layout.addLayout(selectButtons)
219+
202220
buttonBox = QDialogButtonBox(
203221
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
204222
)
@@ -220,6 +238,13 @@ def showModDetectionDialog(self) -> set[int] | None:
220238

221239
return selectedIndexes
222240

241+
def setDialogSelection(self, listWidget: QListWidget, select: bool) -> None:
242+
state = Qt.CheckState.Checked if select else Qt.CheckState.Unchecked
243+
for index in range(listWidget.count()):
244+
item = listWidget.item(index)
245+
if isinstance(item, QListWidgetItem):
246+
item.setCheckState(state)
247+
223248
def collectModCandidates(
224249
self,
225250
tree: mobase.IFileTree | mobase.FileTreeEntry,
@@ -229,7 +254,7 @@ def collectModCandidates(
229254
category = None
230255
entryext = "None"
231256
GameDataUE4SSRootDir = getattr(
232-
self.organizer.managedGame(), "GameDataUE4SSMods", ""
257+
self.organizer.managedGame(), "GameDataUE4SSRoot", ""
233258
)
234259
GameDataUE4SSModsDir = GameDataUE4SSRootDir + "/Mods"
235260
GameDataPakModsDir = getattr(
@@ -247,7 +272,7 @@ def collectModCandidates(
247272

248273
if isinstance(tree, mobase.IFileTree) and tree.isDir():
249274
if tree.exists("ue4ss.dll", mobase.IFileTree.FILE) or tree.exists(
250-
"ue4ss_loader.dll", mobase.IFileTree.FILE
275+
"dsound.dll", mobase.IFileTree.FILE
251276
):
252277
category = "Root"
253278
elif tree.exists("Scripts", mobase.IFileTree.DIRECTORY) and not tree.exists(
@@ -282,44 +307,39 @@ def collectModCandidates(
282307
else:
283308
destination = "/"
284309

285-
self.addModDetectionCandidate(
286-
tree,
287-
sanitized_name,
288-
f"{category} Mod",
289-
destination,
290-
installtype,
291-
)
310+
if category == "Root":
311+
for element in tree:
312+
self.addModDetectionCandidate(
313+
element,
314+
sanitized_name,
315+
f"{category} Mod",
316+
destination,
317+
installtype,
318+
)
319+
320+
else:
321+
self.addModDetectionCandidate(
322+
tree,
323+
sanitized_name,
324+
f"{category} Mod",
325+
destination,
326+
installtype,
327+
)
292328
return True
293329

294330
def walkEntry(self, path: str, entry: mobase.FileTreeEntry):
295331
self.collectModCandidates(entry)
296332
return mobase.IFileTree.WalkReturn.CONTINUE
297333

298-
def fileExistsInNextSubDir(self, filetree: mobase.IFileTree, name: str):
299-
for branch in filetree:
300-
if isinstance(branch, mobase.IFileTree):
301-
for e in branch:
302-
if e.name() == name:
303-
return True
304-
return False
305-
306-
def allMoveTo(self, filetree: mobase.IFileTree, toMoveTo: str):
307-
entriesToMove: list[mobase.FileTreeEntry] = []
308-
retVal = 0
309-
for e in filetree:
310-
entriesToMove.append(e)
311-
for e in entriesToMove:
312-
filetree.move(e, toMoveTo, mobase.IFileTree.MERGE)
313-
retVal = 1
314-
return retVal
315-
316334
def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree | None:
317335
self.modDetectionCandidates = []
318-
newtree = filetree.createOrphanTree("Fixed Tree")
319336
# Check for Non Zipped Mod
337+
UnZippedInstallation = False
320338
if filetree.name() != "":
321339
self.collectModCandidates(filetree, installtype="os")
340+
UnZippedInstallation = True
322341
else:
342+
newtree = filetree.createOrphanTree("Fixed Tree")
323343
self.collectModCandidates(filetree)
324344
filetree.walk(self.walkEntry, "/")
325345

@@ -335,14 +355,11 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree | None:
335355
self.moveTreeContent(
336356
candidate["installtype"],
337357
candidate["tree"],
338-
newtree,
358+
filetree if UnZippedInstallation else newtree,
339359
candidate["destination"],
340360
)
341361

342-
if newtree:
343-
return newtree
344-
else:
345-
return filetree
362+
return filetree if UnZippedInstallation else newtree
346363

347364

348365
class MarvelRivalsGame(BasicGame):

0 commit comments

Comments
 (0)