Skip to content

Commit

Permalink
Fix listing of save files
Browse files Browse the repository at this point in the history
  • Loading branch information
ZashIn committed Oct 4, 2023
1 parent 06ea20d commit bf51677
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions games/game_cyberpunk2077.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import typing
from pathlib import Path

import mobase

from ..basic_features.basic_save_game_info import BasicGameSaveGame
from ..basic_game import BasicGame

# MO 2.4 compatibility
Expand Down Expand Up @@ -33,10 +35,25 @@ def prepareProfile(self, profile: mobase.IProfile):
return profile.localSavesEnabled()


class CyberpunkSaveGame(BasicGameSaveGame):
_name_file = "NamedSave.txt" # from mod: Named Saves

def __init__(self, filepath: Path):
super().__init__(filepath)
try: # Custom name from Named Saves
with open(filepath / self._name_file) as file:
self._name = file.readline()
except FileNotFoundError:
self._name = ""

def getName(self) -> str:
return self._name or super().getName()


class Cyberpunk2077Game(BasicGame):
Name = "Cyberpunk 2077 Support Plugin"
Author = "6788, Zash"
Version = "1.2.0"
Version = "1.2.1"

GameName = "Cyberpunk 2077"
GameShortName = "cyberpunk2077"
Expand All @@ -53,13 +70,20 @@ class Cyberpunk2077Game(BasicGame):
"Game:-Cyberpunk-2077"
)

def iniFiles(self):
return ["UserSettings.json"]

def init(self, organizer: mobase.IOrganizer) -> bool:
super().init(organizer)

self._featureMap[mobase.LocalSavegames] = CyberpunkLocalSaves(
self.savesDirectory()
)
return True

def iniFiles(self):
return ["UserSettings.json"]

def listSaves(self, folder: QDir) -> list[mobase.ISaveGame]:
ext = self._mappings.savegameExtension.get()
return [
CyberpunkSaveGame(path.parent)
for path in Path(folder.absolutePath()).glob(f"**/*.{ext}")
]

0 comments on commit bf51677

Please sign in to comment.