|
| 1 | +from pathlib import Path |
| 2 | +from typing import List |
| 3 | + |
| 4 | +import mobase |
| 5 | +from PyQt6.QtCore import QDir |
| 6 | + |
| 7 | +from ..basic_features import BasicGameSaveGameInfo |
| 8 | +from ..basic_features.basic_save_game_info import BasicGameSaveGame |
| 9 | +from ..basic_game import BasicGame |
| 10 | + |
| 11 | + |
| 12 | +class Witcher2SaveGame(BasicGameSaveGame): |
| 13 | + def allFiles(self): |
| 14 | + return [ |
| 15 | + self._filepath.name, |
| 16 | + self._filepath.name.replace(".sav", "_640x360.bmp"), |
| 17 | + ] |
| 18 | + |
| 19 | + |
| 20 | +class Witcher2Game(BasicGame): |
| 21 | + |
| 22 | + Name = "Witcher 2 Support Plugin" |
| 23 | + Author = "DefinitelyNotSade" |
| 24 | + Version = "1.0.0" |
| 25 | + |
| 26 | + GameName = "The Witcher 2: Assassins of Kings" |
| 27 | + GameShortName = "witcher2" |
| 28 | + GaneNexusHame = "witcher2" |
| 29 | + # GameNexusId = 952 |
| 30 | + GameSteamId = 20920 |
| 31 | + GameGogId = 1207658930 |
| 32 | + GameLauncher = "Launcher.exe" |
| 33 | + GameBinary = "bin/witcher2.exe" |
| 34 | + GameDataPath = "CookedPC" |
| 35 | + GameSaveExtension = "sav" |
| 36 | + GameDocumentsDirectory = "%DOCUMENTS%/witcher 2/Config" |
| 37 | + GameSavesDirectory = "%GAME_DOCUMENTS%/../gamesaves" |
| 38 | + |
| 39 | + def init(self, organizer: mobase.IOrganizer): |
| 40 | + super().init(organizer) |
| 41 | + self._featureMap[mobase.SaveGameInfo] = BasicGameSaveGameInfo( |
| 42 | + lambda s: Path(str(s.parent) + "\\" + s.stem + "_640x360").with_suffix( |
| 43 | + ".bmp" |
| 44 | + ) |
| 45 | + ) |
| 46 | + return True |
| 47 | + |
| 48 | + def iniFiles(self): |
| 49 | + return [ |
| 50 | + "User.ini", |
| 51 | + "Rendering.ini", |
| 52 | + "Community.ini", |
| 53 | + "UserContent.ini", |
| 54 | + "DIMapping.ini", |
| 55 | + "Input_QWERTY.ini", |
| 56 | + "Input_AZERTY.ini", |
| 57 | + "Input_QWERTZ.ini", |
| 58 | + ] |
| 59 | + |
| 60 | + def listSaves(self, folder: QDir) -> List[mobase.ISaveGame]: |
| 61 | + ext = self._mappings.savegameExtension.get() |
| 62 | + return [ |
| 63 | + Witcher2SaveGame(path) |
| 64 | + for path in Path(folder.absolutePath()).glob(f"*.{ext}") |
| 65 | + ] |
0 commit comments