|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +from PyQt6.QtCore import QDir, QFileInfo |
| 4 | + |
| 5 | +import mobase |
| 6 | + |
| 7 | +from ..basic_features import BasicModDataChecker, GlobPatterns |
| 8 | +from ..basic_features.basic_save_game_info import BasicGameSaveGame |
| 9 | +from ..basic_game import BasicGame |
| 10 | + |
| 11 | + |
| 12 | +class SlayTheSpire2ModDataChecker(BasicModDataChecker): |
| 13 | + def __init__(self): |
| 14 | + super().__init__( |
| 15 | + GlobPatterns( |
| 16 | + valid=[ |
| 17 | + "*.pck", |
| 18 | + "*.dll", |
| 19 | + "*.json", |
| 20 | + ], |
| 21 | + move={ |
| 22 | + "*/*.pck": "", |
| 23 | + "*/*.dll": "", |
| 24 | + "*/*.json": "", |
| 25 | + }, |
| 26 | + ) |
| 27 | + ) |
| 28 | + |
| 29 | + |
| 30 | +class SlayTheSpire2Game(BasicGame): |
| 31 | + Name = "Slay the Spire 2 Support Plugin" |
| 32 | + Author = "Azlle" |
| 33 | + Version = "1.0.0" |
| 34 | + |
| 35 | + GameName = "Slay the Spire 2" |
| 36 | + GameShortName = "slaythespire2" |
| 37 | + GameNexusName = "slaythespire2" |
| 38 | + GameNexusId = 8916 |
| 39 | + GameSteamId = 2868840 |
| 40 | + GameBinary = "SlayTheSpire2.exe" |
| 41 | + GameDataPath = "mods" |
| 42 | + GameDocumentsDirectory = "%USERPROFILE%/AppData/Roaming/SlayTheSpire2" |
| 43 | + |
| 44 | + def init(self, organizer: mobase.IOrganizer) -> bool: |
| 45 | + super().init(organizer) |
| 46 | + self._register_feature(SlayTheSpire2ModDataChecker()) |
| 47 | + return True |
| 48 | + |
| 49 | + def savesDirectory(self) -> QDir: |
| 50 | + docs = QDir(self.documentsDirectory()) |
| 51 | + steam_dir = Path(docs.absoluteFilePath("steam")) |
| 52 | + if steam_dir.exists(): |
| 53 | + entries = [e for e in steam_dir.iterdir() if e.is_dir()] |
| 54 | + if entries: |
| 55 | + return QDir(str(entries[0])) |
| 56 | + return QDir(str(steam_dir)) |
| 57 | + |
| 58 | + def listSaves(self, folder: QDir) -> list[mobase.ISaveGame]: |
| 59 | + base = Path(folder.absolutePath()) |
| 60 | + return [ |
| 61 | + BasicGameSaveGame(save) |
| 62 | + for save in base.rglob("*") |
| 63 | + if save.is_file() and save.suffix in (".save", ".run") |
| 64 | + ] |
| 65 | + |
| 66 | + def executables(self): |
| 67 | + return [ |
| 68 | + mobase.ExecutableInfo( |
| 69 | + "Slay the Spire 2", |
| 70 | + QFileInfo(self.gameDirectory().absoluteFilePath(self.binaryName())), |
| 71 | + ), |
| 72 | + mobase.ExecutableInfo( |
| 73 | + "Slay the Spire 2 (OpenGL)", |
| 74 | + QFileInfo(self.gameDirectory().absoluteFilePath(self.binaryName())), |
| 75 | + ).withArgument("--rendering-driver opengl3"), |
| 76 | + ] |
0 commit comments