Llançador inicial amb GUI PySide6: descàrrega i execució de jocs

This commit is contained in:
2026-05-29 20:50:50 +02:00
parent 9428f335de
commit b71df66e22
17 changed files with 918 additions and 2 deletions
+53
View File
@@ -0,0 +1,53 @@
"""Resolución de rutas: dónde está games.toml y dónde guardar los datos.
Cuando se compila con Nuitka (``--standalone``) el atributo global ``__compiled__``
existe, así que usamos la carpeta del ejecutable. Ejecutando desde fuente usamos la
raíz del proyecto (la carpeta que contiene el paquete ``jlauncher``).
"""
from __future__ import annotations
import sys
from pathlib import Path
CONFIG_NAME = "games.toml"
def is_compiled() -> bool:
"""True si corremos como binario Nuitka (define ``__compiled__`` en cada módulo)."""
return "__compiled__" in globals()
def base_dir() -> Path:
"""Carpeta base junto a la que viven games.toml y jlauncher_data."""
if is_compiled():
return Path(sys.executable).resolve().parent
# Desde fuente: raíz del proyecto = padre del paquete jlauncher/
return Path(__file__).resolve().parent.parent
def config_file() -> Path:
"""Ruta a games.toml (junto al ejecutable / raíz del proyecto)."""
return base_dir() / CONFIG_NAME
def data_root(data_dir: str = "jlauncher_data") -> Path:
"""Carpeta raíz de datos; se crea si no existe."""
root = base_dir() / data_dir
root.mkdir(parents=True, exist_ok=True)
return root
def game_dir(root: Path, game_id: str) -> Path:
"""Carpeta de un juego: <root>/<id>/."""
return root / game_id
def repo_dir(root: Path, game_id: str) -> Path:
"""Carpeta del clone git: <root>/<id>/repo/."""
return game_dir(root, game_id) / "repo"
def metadata_dir(root: Path, game_id: str) -> Path:
"""Carpeta de metadata cacheada: <root>/<id>/metadata/."""
return game_dir(root, game_id) / "metadata"