blob: fec834fabce84b2b8e6159089b2b1e1fc2c9a169 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
from pathlib import Path
from PyQt6.QtCore import QDir
import mobase
from ..basic_features import BasicGameSaveGameInfo
from ..basic_features.basic_save_game_info import BasicGameSaveGame
from ..basic_game import BasicGame
class KerbalSpaceProgramSaveGame(BasicGameSaveGame):
def allFiles(self):
files = [super().getFilepath()]
banner = self._filepath.joinpath("banners").joinpath(f"${self.getName()}.png")
if banner.exists():
files.append(banner.as_posix())
return files
def getName(self):
return self._filepath.stem
def getSaveGroupIdentifier(self):
return self._filepath.parent.name
class KerbalSpaceProgramGame(BasicGame):
Name = "Kerbal Space Program Support Plugin"
Author = "LaughingHyena"
Version = "1.0.0"
GameName = "Kerbal Space Program"
GameShortName = "kerbalspaceprogram"
GameNexusName = "kerbalspaceprogram"
GameSteamId = [220200, 283740, 982970]
GameBinary = "KSP_x64.exe"
GameDataPath = "GameData"
GameSavesDirectory = "%GAME_PATH%/saves"
GameSaveExtension = "sfs"
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Kerbal-Space-Program"
)
def init(self, organizer: mobase.IOrganizer):
super().init(organizer)
self._register_feature(
BasicGameSaveGameInfo(
lambda s: str(
Path(s).parent.joinpath("banners").joinpath(f"{Path(s).stem}.png")
)
)
)
return True
def listSaves(self, folder: QDir) -> list[mobase.ISaveGame]:
ext = self._mappings.savegameExtension.get()
return [
KerbalSpaceProgramSaveGame(path)
for path in Path(folder.absolutePath()).glob(f"*/*.{ext}")
]
|