Skip to content

Commit e368934

Browse files
committed
Removing IPluginInstallerSimple
1 parent 4ca4978 commit e368934

1 file changed

Lines changed: 46 additions & 51 deletions

File tree

games/game_fantasylifei.py

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,62 @@
99
from ..basic_game import BasicGame
1010
from ..steam_utils import find_steam_path
1111

12-
1312
class FantasyLifeIModDataChecker(mobase.ModDataChecker):
1413
def __init__(self: mobase.ModDataChecker) -> None:
1514
super().__init__()
1615

17-
def dataLooksValid(
18-
self: mobase.ModDataChecker, filetree: mobase.IFileTree
19-
) -> mobase.ModDataChecker.CheckReturn:
16+
_PAK_MOD_EXTENSIONS = (".pak", ".ucas", ".utoc")
17+
18+
def _api_mod(self, tree: mobase.IFileTree, mods_path: str) -> bool:
19+
if not tree.exists(mods_path, mobase.IFileTree.DIRECTORY):
20+
return False
21+
22+
try:
23+
for mod_folder in tree.find(mods_path, mobase.IFileTree.DIRECTORY):
24+
folder_name = mod_folder.name();
25+
26+
for subentry in mod_folder:
27+
subname = subentry.name();
28+
29+
if subname.lower() == "mod.json" or subname.lower().endswith('.mod'):
30+
return True
31+
32+
except Exception:
33+
return False
34+
return False
35+
36+
def _pak_mod(self, tree: mobase.IFileTree, paks_path: str) -> bool:
37+
if not tree.exists(paks_path, mobase.IFileTree.DIRECTORY):
38+
return False
39+
40+
try:
41+
for entry in tree.find(paks_path, mobase.IFileTree.DIRECTORY):
42+
for subentry in entry:
43+
if subentry.name().lower().endswith(self._PAK_MOD_EXTENSIONS):
44+
return True
45+
46+
except Exception:
47+
return False
48+
return False
49+
50+
def dataLooksValid(self, filetree: mobase.IFileTree) -> mobase.ModDataChecker.CheckReturn:
2051
if filetree.exists("Game", mobase.IFileTree.DIRECTORY):
21-
return mobase.ModDataChecker.INVALID
52+
pass
2253

23-
if filetree.exists("Mods", mobase.IFileTree.DIRECTORY) or filetree.exists(
24-
"Paks", mobase.IFileTree.DIRECTORY
25-
):
26-
return mobase.ModDataChecker.VALID
54+
for mods_path in ["Mods"]:
55+
if self._api_mod(filetree, mods_path):
56+
return mobase.ModDataChecker.VALID
2757

28-
return mobase.ModDataChecker.INVALID
58+
for paks_path in ["Paks"]:
59+
if self._pak_mod(filetree, paks_path):
60+
return mobase.ModDataChecker.VALID
2961

62+
return mobase.ModDataChecker.INVALID
3063

31-
class FantasyLifeI(BasicGame, mobase.IPluginFileMapper, mobase.IPluginInstallerSimple):
64+
class FantasyLifeI(BasicGame, mobase.IPluginFileMapper):
3265
Name = "Fantasy Life I Support Plugin"
3366
Author = "AmeliaCute"
34-
Version = "0.2.1"
67+
Version = "0.2.2"
3568

3669
GameName = "FANTASY LIFE i"
3770
GameShortName = "fantasylifei"
@@ -50,7 +83,6 @@ class FantasyLifeI(BasicGame, mobase.IPluginFileMapper, mobase.IPluginInstallerS
5083
def __init__(self):
5184
BasicGame.__init__(self)
5285
mobase.IPluginFileMapper.__init__(self)
53-
mobase.IPluginInstallerSimple.__init__(self)
5486

5587
def init(self, organizer: mobase.IOrganizer) -> bool:
5688
super().init(organizer)
@@ -64,7 +96,6 @@ def executables(self):
6496
]
6597

6698
## SAVE
67-
6899
# credit to game.darkestdungeon.py
69100
@staticmethod
70101
def getCloudSaveDirectory() -> str | None:
@@ -104,40 +135,4 @@ def exeDirectory(self) -> QDir:
104135
def mappings(self) -> list[mobase.Mapping]:
105136
return [
106137
mobase.Mapping("*.dll", self.exeDirectory().absolutePath(), False, True),
107-
]
108-
109-
## INSTALLER
110-
111-
_PAK_EXTENSIONS = (".pak", ".ucas", ".utoc")
112-
113-
def priority(self) -> int:
114-
return 150
115-
116-
def isArchiveSupported(self, tree: mobase.IFileTree) -> bool:
117-
for entry in tree:
118-
if entry.name().lower().endswith(self._PAK_EXTENSIONS):
119-
return True
120-
121-
if tree.exists("Mod.json", mobase.IFileTree.FILE):
122-
return True
123-
return False
124-
125-
def install(
126-
self,
127-
name: mobase.GuessedString,
128-
tree: mobase.IFileTree,
129-
version: str,
130-
nexus_id: int,
131-
) -> mobase.InstallResult:
132-
paks_dir = QDir(".").filePath("Paks/~mods/")
133-
mods_dir = QDir(".").filePath(f"Mods/{name.__str__()}/")
134-
135-
for entry in list(tree):
136-
if entry.name().lower().endswith(self._PAK_EXTENSIONS):
137-
tree.move(entry, paks_dir)
138-
139-
if tree.exists("Mod.json", mobase.IFileTree.FILE):
140-
for entry in list(tree):
141-
tree.move(entry, mods_dir)
142-
143-
return mobase.InstallResult.SUCCESS
138+
]

0 commit comments

Comments
 (0)