Merge pull request #20 from Holt59/minor-fixes-2.4

Minor fixes. Add missing %USERPROFILE% replacement.
This commit is contained in:
Mikaël Capelle
2020-11-29 20:01:50 +01:00
committed by GitHub
3 changed files with 14 additions and 2 deletions
+8 -1
View File
@@ -32,6 +32,8 @@ for file in glob.glob(os.path.join(curpath, "games", "*.py")):
module = importlib.import_module(".games." + module_p[:-3], __package__)
except ImportError as e:
print("Failed to import module {}: {}".format(module_p, e), file=sys.stderr)
except Exception as e:
print("Failed to import module {}: {}".format(module_p, e), file=sys.stderr)
# Lookup game plugins:
for name in dir(module):
@@ -42,7 +44,12 @@ for file in glob.glob(os.path.join(curpath, "games", "*.py")):
and issubclass(obj, BasicGame)
and obj is not BasicGame
):
game_plugins.append(obj())
try:
game_plugins.append(obj())
except Exception as e:
print(
"Failed to instantiate {}: {}".format(name, e), file=sys.stderr
)
def createPlugins():
+1 -1
View File
@@ -30,7 +30,7 @@ class BasicGameSaveGame(mobase.ISaveGame):
return ""
def allFiles(self) -> List[str]:
return [self.getFilename()]
return [self.getFilepath()]
class BasicGameSaveGameInfoWidget(mobase.ISaveGameInfoWidget):
+5
View File
@@ -22,6 +22,11 @@ def replace_variables(value: str, game: "BasicGame") -> str:
"%DOCUMENTS%",
QStandardPaths.writableLocation(QStandardPaths.DocumentsLocation),
)
if value.find("%USERPROFILE%") != -1:
value = value.replace(
"%USERPROFILE%",
QStandardPaths.writableLocation(QStandardPaths.HomeLocation),
)
if value.find("%GAME_DOCUMENTS%") != -1:
value = value.replace(
"%GAME_DOCUMENTS%", game.documentsDirectory().absolutePath()