Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions basic_features/basic_mod_data_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, globs: GlobPatterns) -> None:
self.move = {
key: re.compile(fnmatch.translate(key), re.I) for key in globs.move
}
self.ignore = OptionalRegexPattern(globs.ignore)

def move_match(self, value: str) -> str | None:
"""
Expand Down Expand Up @@ -79,6 +80,7 @@ class GlobPatterns:
valid: list[str] | None = None
delete: list[str] | None = None
move: dict[str, str] = field(default_factory=dict[str, str])
ignore: list[str] | None = None

def merge(
self, other: GlobPatterns, mode: Literal["merge", "replace"] = "replace"
Expand Down Expand Up @@ -106,13 +108,15 @@ def merge(
valid=_merge_list(self.valid, other.valid),
delete=_merge_list(self.delete, other.delete),
move=self.move | other.move,
ignore=_merge_list(self.ignore, other.ignore),
)
else:
return GlobPatterns(
unfold=other.unfold or self.unfold,
valid=other.valid or self.valid,
delete=other.delete or self.delete,
move=other.move or self.move,
ignore=other.ignore or self.ignore,
)


Expand All @@ -125,6 +129,8 @@ class BasicModDataChecker(mobase.ModDataChecker):

Args:
file_patterns (optional): A GlobPatterns object, with the following attributes:
ignore: [ "list of files and folders to ignore." ]
# Check result: unchanged
unfold: [ "list of folders to unfold" ],
# (remove and move contents to parent), after being checked and
# fixed recursively.
Expand Down Expand Up @@ -175,6 +181,8 @@ def dataLooksValid(
for entry in filetree:
name = entry.name().casefold()

if rp.ignore.match(name):
continue
if rp.unfold.match(name):
if is_directory(entry):
status = self.dataLooksValid(entry)
Expand All @@ -196,6 +204,8 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
for entry in list(filetree):
name = entry.name()

if rp.ignore.match(name):
continue
# unfold first - if this match, entry is a directory (checked in
# dataLooksValid)
if rp.unfold.match(name):
Expand Down
10 changes: 10 additions & 0 deletions basic_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class BasicGameMappings:
gameName: BasicGameMapping[str]
gameShortName: BasicGameMapping[str]
gameNexusName: BasicGameMapping[str]
gameThunderstoreName: BasicGameMapping[str]
validShortNames: BasicGameMapping[list[str]]
nexusGameId: BasicGameMapping[int]
binaryName: BasicGameMapping[str]
Expand Down Expand Up @@ -265,6 +266,12 @@ def __init__(self, game: BasicGame):
"gameNexusName",
default=lambda g: g.gameShortName(),
)
self.gameThunderstoreName = BasicGameMapping(
game,
"GameThunderstoreName",
"gameThunderstoreName",
default=lambda g: "",
)
self.validShortNames = BasicGameMapping(
game,
"GameValidShortNames",
Expand Down Expand Up @@ -529,6 +536,9 @@ def validShortNames(self) -> list[str]:
def gameNexusName(self) -> str:
return self._mappings.gameNexusName.get()

def gameThunderstoreName(self) -> str:
return self._mappings.gameThunderstoreName.get()

def nexusModOrganizerID(self) -> int:
return 0

Expand Down
6 changes: 1 addition & 5 deletions games/game_subnautica-below-zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@

class SubnauticaBelowZeroGame(game_subnautica.SubnauticaGame):
Name = "Subnautica Below Zero Support Plugin"
Author = "dekart811, Zash"
Version = "2.2"

GameName = "Subnautica: Below Zero"
GameShortName = "subnauticabelowzero"
GameNexusName = "subnauticabelowzero"
GameThunderstoreName = "subnautica-below-zero"
GameSteamId = 848450
GameEpicId = "foxglove"
GameBinary = "SubnauticaZero.exe"
GameDataPath = "_ROOT"
GameDocumentsDirectory = "%GAME_PATH%"
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Subnautica:-Below-Zero"
)
GameSavesDirectory = r"%GAME_PATH%\SNAppData\SavedGames"

_game_extra_save_paths = [
r"%USERPROFILE%\Appdata\LocalLow\Unknown Worlds"
Expand Down
4 changes: 3 additions & 1 deletion games/game_subnautica.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, patterns: GlobPatterns | None = None, use_qmods: bool = False
"changelog.txt",
"libdoorstop.dylib",
],
ignore=["*.mohidden"],
delete=[
"*.txt",
"*.md",
Expand Down Expand Up @@ -87,11 +88,12 @@ def fix(self, filetree: mobase.IFileTree) -> mobase.IFileTree:
class SubnauticaGame(BasicGame, mobase.IPluginFileMapper):
Name = "Subnautica Support Plugin"
Author = "dekart811, Zash"
Version = "2.2"
Version = "2.3"

GameName = "Subnautica"
GameShortName = "subnautica"
GameNexusName = "subnautica"
GameThunderstoreName = "subnautica"
GameSteamId = 264710
GameEpicId = "Jaguar"
GameBinary = "Subnautica.exe"
Expand Down
6 changes: 5 additions & 1 deletion games/game_valheim.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@ def allFiles(self) -> list[str]:
class ValheimGame(BasicGame):
Name = "Valheim Support Plugin"
Author = "Zash"
Version = "1.2.2"
Version = "1.3"

GameName = "Valheim"
GameShortName = "valheim"
GameThunderstoreName = "valheim"
GameNexusId = 3667
GameSteamId = [892970, 896660, 1223920]
GameBinary = "valheim.exe"
Expand Down Expand Up @@ -333,6 +334,9 @@ def init(self, organizer: mobase.IOrganizer) -> bool:
#
"AdvancedBuilder",
],
ignore=[
"*.mohidden",
],
delete=[
"*.txt",
"*.md",
Expand Down