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) self.launch_game(gameFiles, gameFlags)
def load_custom_games(self) -> Dict[str, dict]: def load_custom_games(self) -> Dict[str, dict]:
"""Load all custom game configurations""" """Load all custom game configurations from all available TobyCustom directories"""
customGames = {} customGames = {}
if platform.system() == "Windows": if platform.system() == "Windows":
customDir = Path.cwd() / "TobyCustom" customDirs = [Path.cwd() / "TobyCustom"]
else: else:
pathList = [ customDirs = [
Path(__file__).parent / "TobyCustom", Path(__file__).parent / "TobyCustom",
self.gamePath / "TobyCustom", self.gamePath / "TobyCustom",
Path(os.path.expanduser("~/.local/share/doom/TobyCustom")) Path(os.path.expanduser("~/.local/share/doom/TobyCustom"))
] ]
# Use first existing path or fall back to original # Search all existing TobyCustom directories
customDir = next( for customDir in customDirs:
(path for path in pathList if path.exists()), if not customDir.exists():
Path(__file__).parent / "TobyCustom" continue
)
if not customDir.exists(): for json_file in customDir.glob("*.json"):
return customGames try:
with open(json_file, 'r') as f:
for json_file in customDir.glob("*.json"): game_config = json.load(f)
try: customGames[game_config['name']] = game_config
with open(json_file, 'r') as f: except Exception as e:
game_config = json.load(f) print(f"Error loading custom game {json_file}: {e}")
customGames[game_config['name']] = game_config
except Exception as e:
print(f"Error loading custom game {json_file}: {e}")
return customGames return customGames