Skip to content

Commit b901309

Browse files
authored
Add support for Thunderstore plugin (#199)
1 parent cc5c3f2 commit b901309

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

basic_features/basic_mod_data_checker.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(self, globs: GlobPatterns) -> None:
5050
self.move = {
5151
key: re.compile(fnmatch.translate(key), re.I) for key in globs.move
5252
}
53+
self.ignore = OptionalRegexPattern(globs.ignore)
5354

5455
def move_match(self, value: str) -> str | None:
5556
"""
@@ -79,6 +80,7 @@ class GlobPatterns:
7980
valid: list[str] | None = None
8081
delete: list[str] | None = None
8182
move: dict[str, str] = field(default_factory=dict[str, str])
83+
ignore: list[str] | None = None
8284

8385
def merge(
8486
self, other: GlobPatterns, mode: Literal["merge", "replace"] = "replace"
@@ -106,13 +108,15 @@ def merge(
106108
valid=_merge_list(self.valid, other.valid),
107109
delete=_merge_list(self.delete, other.delete),
108110
move=self.move | other.move,
111+
ignore=_merge_list(self.ignore, other.ignore),
109112
)
110113
else:
111114
return GlobPatterns(
112115
unfold=other.unfold or self.unfold,
113116
valid=other.valid or self.valid,
114117
delete=other.delete or self.delete,
115118
move=other.move or self.move,
119+
ignore=other.ignore or self.ignore,
116120
)
117121

118122

@@ -125,6 +129,8 @@ class BasicModDataChecker(mobase.ModDataChecker):
125129
126130
Args:
127131
file_patterns (optional): A GlobPatterns object, with the following attributes:
132+
ignore: [ "list of files and folders to ignore." ]
133+
# Check result: unchanged
128134
unfold: [ "list of folders to unfold" ],
129135
# (remove and move contents to parent), after being checked and
130136
# fixed recursively.
@@ -175,6 +181,8 @@ def dataLooksValid(
175181
for entry in filetree:
176182
name = entry.name().casefold()
177183

184+
if rp.ignore.match(name):
185+
continue
178186
if rp.unfold.match(name):
179187
if is_directory(entry):
180188
status = self.dataLooksValid(entry)
@@ -196,6 +204,8 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
196204
for entry in list(filetree):
197205
name = entry.name()
198206

207+
if rp.ignore.match(name):
208+
continue
199209
# unfold first - if this match, entry is a directory (checked in
200210
# dataLooksValid)
201211
if rp.unfold.match(name):

basic_game.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class BasicGameMappings:
199199
gameName: BasicGameMapping[str]
200200
gameShortName: BasicGameMapping[str]
201201
gameNexusName: BasicGameMapping[str]
202+
gameThunderstoreName: BasicGameMapping[str]
202203
validShortNames: BasicGameMapping[list[str]]
203204
nexusGameId: BasicGameMapping[int]
204205
binaryName: BasicGameMapping[str]
@@ -265,6 +266,12 @@ def __init__(self, game: BasicGame):
265266
"gameNexusName",
266267
default=lambda g: g.gameShortName(),
267268
)
269+
self.gameThunderstoreName = BasicGameMapping(
270+
game,
271+
"GameThunderstoreName",
272+
"gameThunderstoreName",
273+
default=lambda g: "",
274+
)
268275
self.validShortNames = BasicGameMapping(
269276
game,
270277
"GameValidShortNames",
@@ -529,6 +536,9 @@ def validShortNames(self) -> list[str]:
529536
def gameNexusName(self) -> str:
530537
return self._mappings.gameNexusName.get()
531538

539+
def gameThunderstoreName(self) -> str:
540+
return self._mappings.gameThunderstoreName.get()
541+
532542
def nexusModOrganizerID(self) -> int:
533543
return 0
534544

games/game_subnautica-below-zero.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@
66

77
class SubnauticaBelowZeroGame(game_subnautica.SubnauticaGame):
88
Name = "Subnautica Below Zero Support Plugin"
9-
Author = "dekart811, Zash"
10-
Version = "2.2"
119

1210
GameName = "Subnautica: Below Zero"
1311
GameShortName = "subnauticabelowzero"
1412
GameNexusName = "subnauticabelowzero"
13+
GameThunderstoreName = "subnautica-below-zero"
1514
GameSteamId = 848450
1615
GameEpicId = "foxglove"
1716
GameBinary = "SubnauticaZero.exe"
18-
GameDataPath = "_ROOT"
19-
GameDocumentsDirectory = "%GAME_PATH%"
2017
GameSupportURL = (
2118
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
2219
"Game:-Subnautica:-Below-Zero"
2320
)
24-
GameSavesDirectory = r"%GAME_PATH%\SNAppData\SavedGames"
2521

2622
_game_extra_save_paths = [
2723
r"%USERPROFILE%\Appdata\LocalLow\Unknown Worlds"

games/game_subnautica.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, patterns: GlobPatterns | None = None, use_qmods: bool = False
3737
"changelog.txt",
3838
"libdoorstop.dylib",
3939
],
40+
ignore=["*.mohidden"],
4041
delete=[
4142
"*.txt",
4243
"*.md",
@@ -87,11 +88,12 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
8788
class SubnauticaGame(BasicGame, mobase.IPluginFileMapper):
8889
Name = "Subnautica Support Plugin"
8990
Author = "dekart811, Zash"
90-
Version = "2.2"
91+
Version = "2.3"
9192

9293
GameName = "Subnautica"
9394
GameShortName = "subnautica"
9495
GameNexusName = "subnautica"
96+
GameThunderstoreName = "subnautica"
9597
GameSteamId = 264710
9698
GameEpicId = "Jaguar"
9799
GameBinary = "Subnautica.exe"

games/game_valheim.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,11 @@ def allFiles(self) -> list[str]:
290290
class ValheimGame(BasicGame):
291291
Name = "Valheim Support Plugin"
292292
Author = "Zash"
293-
Version = "1.2.2"
293+
Version = "1.3"
294294

295295
GameName = "Valheim"
296296
GameShortName = "valheim"
297+
GameThunderstoreName = "valheim"
297298
GameNexusId = 3667
298299
GameSteamId = [892970, 896660, 1223920]
299300
GameBinary = "valheim.exe"
@@ -333,6 +334,9 @@ def init(self, organizer: mobase.IOrganizer) -> bool:
333334
#
334335
"AdvancedBuilder",
335336
],
337+
ignore=[
338+
"*.mohidden",
339+
],
336340
delete=[
337341
"*.txt",
338342
"*.md",

0 commit comments

Comments
 (0)