|
4 | 4 |
|
5 | 5 | import mobase |
6 | 6 |
|
7 | | -from ..basic_features.basic_local_savegames import BasicLocalSavegames |
| 7 | +from ..basic_features import BasicLocalSavegames, BasicModDataChecker, GlobPatterns |
8 | 8 | from ..basic_features.basic_save_game_info import BasicGameSaveGame |
9 | 9 | from ..basic_game import BasicGame |
10 | 10 | from ..steam_utils import find_steam_path |
11 | 11 |
|
12 | | - |
13 | | -class FantasyLifeIModDataChecker(mobase.ModDataChecker): |
14 | | - def __init__(self: mobase.ModDataChecker) -> None: |
15 | | - super().__init__() |
16 | | - |
17 | | - _PAK_MOD_EXTENSIONS = (".pak", ".ucas", ".utoc") |
18 | | - |
19 | | - def _api_mod(self, tree: mobase.IFileTree, mods_path: str) -> bool: |
20 | | - if not tree.exists(mods_path, mobase.IFileTree.DIRECTORY): |
21 | | - return False |
22 | | - |
23 | | - try: |
24 | | - for mod_folder in tree.find(mods_path, mobase.IFileTree.DIRECTORY): |
25 | | - for subentry in mod_folder: |
26 | | - subname = subentry.name() |
27 | | - |
28 | | - if subname.lower() == "mod.json" or subname.lower().endswith( |
29 | | - ".mod" |
30 | | - ): |
31 | | - return True |
32 | | - |
33 | | - except Exception: |
34 | | - return False |
35 | | - return False |
36 | | - |
37 | | - def _pak_mod(self, tree: mobase.IFileTree, paks_path: str) -> bool: |
38 | | - if not tree.exists(paks_path, mobase.IFileTree.DIRECTORY): |
39 | | - return False |
40 | | - |
41 | | - try: |
42 | | - for entry in tree.find(paks_path, mobase.IFileTree.DIRECTORY): |
43 | | - for subentry in entry: |
44 | | - if subentry.name().lower().endswith(self._PAK_MOD_EXTENSIONS): |
45 | | - return True |
46 | | - |
47 | | - except Exception: |
48 | | - return False |
49 | | - return False |
50 | | - |
51 | | - def dataLooksValid( |
52 | | - self, filetree: mobase.IFileTree |
53 | | - ) -> mobase.ModDataChecker.CheckReturn: |
54 | | - if filetree.exists("Game", mobase.IFileTree.DIRECTORY): |
55 | | - pass |
56 | | - |
57 | | - for mods_path in ["Mods"]: |
58 | | - if self._api_mod(filetree, mods_path): |
59 | | - return mobase.ModDataChecker.VALID |
60 | | - |
61 | | - for paks_path in ["Paks"]: |
62 | | - if self._pak_mod(filetree, paks_path): |
63 | | - return mobase.ModDataChecker.VALID |
64 | | - |
65 | | - return mobase.ModDataChecker.INVALID |
66 | | - |
| 12 | +class FantasyLifeIModDataChecker(BasicModDataChecker): |
| 13 | + def __init__(self): |
| 14 | + super().__init__( |
| 15 | + GlobPatterns( |
| 16 | + move= |
| 17 | + { |
| 18 | + "*.fliarchive": "Mods/", |
| 19 | + "*.pak": "Paks/~mods/", |
| 20 | + "*.ucas": "Paks/~mods/", |
| 21 | + "*.utoc": "Paks/~mods/", |
| 22 | + }, |
| 23 | + valid= |
| 24 | + [ |
| 25 | + "L10N", |
| 26 | + "sound", |
| 27 | + "Mods", |
| 28 | + "Paks" |
| 29 | + ] |
| 30 | + ) |
| 31 | + ) |
67 | 32 |
|
68 | 33 | class FantasyLifeI(BasicGame, mobase.IPluginFileMapper): |
69 | 34 | Name = "Fantasy Life I Support Plugin" |
|
0 commit comments