add optional TobyCustom path to ~/.local/share/doom/TobyCustom.

This commit is contained in:
Storm Dragon
2025-10-10 03:58:01 -04:00
parent d8abcc4cca
commit fd8aac0de1
+14 -18
View File
@@ -2516,33 +2516,29 @@ class DoomLauncher(QMainWindow):
self.launch_game(gameFiles, gameFlags)
def load_custom_games(self) -> Dict[str, dict]:
"""Load all custom game configurations"""
"""Load all custom game configurations from all available TobyCustom directories"""
customGames = {}
if platform.system() == "Windows":
customDir = Path.cwd() / "TobyCustom"
customDirs = [Path.cwd() / "TobyCustom"]
else:
pathList = [
customDirs = [
Path(__file__).parent / "TobyCustom",
self.gamePath / "TobyCustom",
Path(os.path.expanduser("~/.local/share/doom/TobyCustom"))
]
# Use first existing path or fall back to original
customDir = next(
(path for path in pathList if path.exists()),
Path(__file__).parent / "TobyCustom"
)
# Search all existing TobyCustom directories
for customDir in customDirs:
if not customDir.exists():
continue
if not customDir.exists():
return customGames
for json_file in customDir.glob("*.json"):
try:
with open(json_file, 'r') as f:
game_config = json.load(f)
customGames[game_config['name']] = game_config
except Exception as e:
print(f"Error loading custom game {json_file}: {e}")
for json_file in customDir.glob("*.json"):
try:
with open(json_file, 'r') as f:
game_config = json.load(f)
customGames[game_config['name']] = game_config
except Exception as e:
print(f"Error loading custom game {json_file}: {e}")
return customGames