mirror of
https://github.com/ModOrganizer2/modorganizer-basic_games.git
synced 2026-07-27 14:07:29 -07:00
Merge pull request #20 from Holt59/minor-fixes-2.4
Minor fixes. Add missing %USERPROFILE% replacement.
This commit is contained in:
+8
-1
@@ -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():
|
||||
|
||||
@@ -30,7 +30,7 @@ class BasicGameSaveGame(mobase.ISaveGame):
|
||||
return ""
|
||||
|
||||
def allFiles(self) -> List[str]:
|
||||
return [self.getFilename()]
|
||||
return [self.getFilepath()]
|
||||
|
||||
|
||||
class BasicGameSaveGameInfoWidget(mobase.ISaveGameInfoWidget):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user