|
| 1 | +import mobase |
| 2 | +from PyQt6.QtCore import QDir, QFileInfo |
| 3 | + |
| 4 | +from ..basic_features import BasicLocalSavegames |
| 5 | +from ..basic_game import BasicGame |
| 6 | +from ..steam_utils import find_steam_path |
| 7 | + |
| 8 | + |
| 9 | +# Lifted from https://github.com/ModOrganizer2/modorganizer-basic_games/blob/71dbb8c557d43cba9d290674a332e7ecd1650261/games/game_darkestdungeon.py |
| 10 | +class ArkhamCityModDataChecker(mobase.ModDataChecker): |
| 11 | + def __init__(self): |
| 12 | + super().__init__() |
| 13 | + self.validDirNames = [ |
| 14 | + "config", |
| 15 | + "cookedpcconsole", |
| 16 | + "localization", |
| 17 | + "movies", |
| 18 | + "moviesstereo", |
| 19 | + "splash", |
| 20 | + ] |
| 21 | + |
| 22 | + def dataLooksValid( |
| 23 | + self, filetree: mobase.IFileTree |
| 24 | + ) -> mobase.ModDataChecker.CheckReturn: |
| 25 | + for entry in filetree: |
| 26 | + if not entry.isDir(): |
| 27 | + continue |
| 28 | + if entry.name().casefold() in self.validDirNames: |
| 29 | + return mobase.ModDataChecker.VALID |
| 30 | + return mobase.ModDataChecker.INVALID |
| 31 | + |
| 32 | + |
| 33 | +class ArkhamCityGame(BasicGame): |
| 34 | + Name = "Batman: Arkham City Plugin" |
| 35 | + Author = "Paynamia" |
| 36 | + Version = "0.5.3" |
| 37 | + |
| 38 | + GameName = "Batman: Arkham City" |
| 39 | + GameShortName = "batmanarkhamcity" |
| 40 | + GameNexusId = 372 |
| 41 | + GameSteamId = 200260 |
| 42 | + GameGogId = 1260066469 |
| 43 | + GameEpicId = "Egret" |
| 44 | + GameBinary = "Binaries/Win32/BatmanAC.exe" |
| 45 | + GameLauncher = "Binaries/Win32/BmLauncher.exe" |
| 46 | + GameDataPath = "BmGame" |
| 47 | + GameDocumentsDirectory = ( |
| 48 | + "%DOCUMENTS%/WB Games/Batman Arkham City GOTY/BmGame/Config" |
| 49 | + ) |
| 50 | + GameIniFiles = ["UserEngine.ini", "UserGame.ini", "UserInput.ini"] |
| 51 | + GameSaveExtension = "sgd" |
| 52 | + |
| 53 | + # This will only detect saves from the earliest-created Steam profile on the user's PC. |
| 54 | + def savesDirectory(self) -> QDir: |
| 55 | + docSaves = QDir(self.documentsDirectory().cleanPath("../../SaveData")) |
| 56 | + if self.is_steam(): |
| 57 | + if (steamDir := find_steam_path()) is None: |
| 58 | + return docSaves |
| 59 | + for child in steamDir.joinpath("userdata").iterdir(): |
| 60 | + if not child.is_dir() or child.name == "0": |
| 61 | + continue |
| 62 | + steamSaves = child.joinpath("200260", "remote") |
| 63 | + if steamSaves.is_dir(): |
| 64 | + return QDir(str(steamSaves)) |
| 65 | + else: |
| 66 | + return docSaves |
| 67 | + else: |
| 68 | + return docSaves |
| 69 | + |
| 70 | + def init(self, organizer: mobase.IOrganizer) -> bool: |
| 71 | + super().init(organizer) |
| 72 | + self._register_feature(ArkhamCityModDataChecker()) |
| 73 | + self._register_feature(BasicLocalSavegames(self.savesDirectory())) |
| 74 | + return True |
| 75 | + |
| 76 | + def executables(self): |
| 77 | + return [ |
| 78 | + mobase.ExecutableInfo( |
| 79 | + "Batman: Arkham City", |
| 80 | + QFileInfo(self.gameDirectory(), "Binaries/Win32/BatmanAC.exe"), |
| 81 | + ), |
| 82 | + mobase.ExecutableInfo( |
| 83 | + "Arkham City Launcher", |
| 84 | + QFileInfo(self.gameDirectory(), "Binaries/Win32/BmLauncher.exe"), |
| 85 | + ), |
| 86 | + ] |
0 commit comments