Compare commits

..

14 Commits

Author SHA1 Message Date
skymike03
e9a610b5dd v2.3.3.3
- Enhance download queue functionality to stop download, continue queue, remove games  and update related UI options
2025-11-25 19:21:12 +01:00
skymike03
bd3b885736 v2.3.3.2
- Fix French print statements for consistency in output messages
- improve filtering  in game list to be permanent, even in search mode, and more efficient for games that have foreign language on other region
2025-11-25 18:40:13 +01:00
skymike03
1592671ddc v2.3.3.1 (2025.11.24)
- correct menu control handling bug
- enhance UI elements for improved user experience
2025-11-24 22:31:53 +01:00
skymike03
4e029aabf1 Remove unnecessary files from RGSX package builds to streamline release process 2025-11-24 13:16:52 +01:00
skymike03
970fcaf197 Update installation instructions for clarity and add manual update notes 2025-11-24 13:14:30 +01:00
skymike03
ff30e6d297 v2.3.3.0 (2025.11.23)
- add a workaround to github update checking
2025-11-23 16:00:38 +01:00
skymike03
5c7fa0484f v2.3.2.9 (2025.11.23)
- Enhance UI with modern effects and improve PSVita game handling (auto extract and create .psvita file for batocera)
- add text file viewer for game txt informations (windows)
2025-11-23 01:25:15 +01:00
skymike03
814861e9ee - add text file viewer for game txt informations 2025-11-21 00:28:46 +01:00
skymike03
56c87ab05f v2.3.2.8 (2025.11.20)
- Improving virtual keyboard navigation when filtering game list (thanks elieserdejesus)
- web interface : Add modal for displaying support messages
- normalize sizes in bytes when not in french
- Refactor control navigation and improve button rendering in UI
2025-11-20 23:19:31 +01:00
skymike03
b12d645fbf Add support modal for displaying formatted support messages 2025-11-20 18:20:12 +01:00
skymike03
04e68adef0 Merge branch 'main' of https://github.com/RetroGameSets/RGSX 2025-11-20 18:02:29 +01:00
skymike03
52f2b960c2 Refactor control navigation and improve button rendering in UI 2025-11-20 18:02:26 +01:00
RGS
1ea604840e Merge pull request #33 from elieserdejesus/main
Improving virtual keyboard navigation when filtering game list to circular navigate
2025-11-20 17:37:59 +01:00
Elieser de Jesus
802696e78f Improving virtual keyboard navigation when filtering game list
The general idea is allow something like "circular buffer" logic when selecting a key in the virtual keyboard.

When the virtual keyboard is displayed:
 - If you are in the first line and press UP jump to last line
 - If you are in the last line and press DOWN jump to first line
 - If you are in the first col and press LEFT jump to last col
 - If you are in the last col and press RIGHT jump to first col
2025-11-20 12:55:30 -03:00
19 changed files with 1805 additions and 452 deletions

View File

@@ -30,16 +30,9 @@ jobs:
zip -r "../../dist/RGSX_update_latest.zip" . \
-x "logs/*" \
"logs/**" \
"images/*" \
"images/**" \
"games/*" \
"games/**" \
"scripts/*" \
"scripts/**" \
"__pycache__/*" \
"__pycache__/**" \
"*.pyc" \
"sources.json" \
"*.log"
cd ../..
@@ -52,16 +45,9 @@ jobs:
zip -r "dist/RGSX_full_latest.zip" ports windows \
-x "ports/RGSX/logs/*" \
"ports/RGSX/logs/**" \
"ports/RGSX/images/*" \
"ports/RGSX/images/**" \
"ports/RGSX/games/*" \
"ports/RGSX/games/**" \
"ports/RGSX/scripts/*" \
"ports/RGSX/scripts/**" \
"ports/RGSX/__pycache__/*" \
"ports/RGSX/__pycache__/**" \
"ports/RGSX/*.pyc" \
"ports/RGSX/sources.json" \
"ports/RGSX/*.log" \
"windows/logs/*" \
"windows/*.xml" \
@@ -88,12 +74,12 @@ jobs:
## 📥 Automatic Installation (Only for batocera Knulli)
### ON PC :
### ON PC , NUC, SteamDeck or any x86_64 based:
1. Open File Manager (F1) then "Applications" and launch xterm
2. Use the command line `curl -L bit.ly/rgsx-install | sh`
3. Launch RGSX from "Ports" menu
### ON RASPBERRY/ARM SBC / HANDHELD :
### ON RASPBERRY/ ARM based SBC / HANDHELD :
1. Connect your device with SSH on a computer/smartphone connected to same network (ssh root@IPADDRESS , pass:linux)
2. Use the command line `curl -L bit.ly/rgsx-install | sh`
3. Launch RGSX from "Ports" menu
@@ -111,17 +97,12 @@ jobs:
3. Launch RGSX from system "Windows"
## 📥 Manual Update (you shouldn't need to do this as RGSX updates automatically on each start)
#### Batocera/Knulli
## 📥 Manual Update (only if automatic doesn't work for some obcure reason)
#### Batocera/Knulli/Retrobat
1. Download latest update : https://github.com/RetroGameSets/RGSX/releases/latest/download/RGSX_update_latest.zip
2. Extract only PORTS folder in `/userdata/roms/`
3. Launch RGSX from the Ports menu
#### Retrobat
1. Download latest update : https://github.com/RetroGameSets/RGSX/releases/latest/download/RGSX_update_latest.zip
2. Extract all folders in your Retrobat\roms folder
3. Launch RGSX from system "Windows"
2. Extract zip content on in `/userdata/roms/ports/RGSX`
3. Launch RGSX
### 📖 Documentation

View File

@@ -28,7 +28,7 @@ from display import (
draw_toast, show_toast, THEME_COLORS
)
from language import _
from network import test_internet, download_rom, is_1fichier_url, download_from_1fichier, check_for_updates, cancel_all_downloads
from network import test_internet, download_rom, is_1fichier_url, download_from_1fichier, check_for_updates, cancel_all_downloads, download_queue_worker
from controls import handle_controls, validate_menu_state, process_key_repeats, get_emergency_controls
from controls_mapper import map_controls, draw_controls_mapping, get_actions
from controls import load_controls_config
@@ -213,7 +213,7 @@ except Exception:
normalized_names = [n.lower() for n in joystick_names]
if not joystick_names:
joystick_names = ["Clavier"]
print("Aucun joystick détecté, utilisation du clavier par défaut")
print("Aucun joystick detecte, utilisation du clavier par defaut")
logger.debug("Aucun joystick détecté, utilisation du clavier par défaut.")
config.joystick = False
config.keyboard = True
@@ -438,6 +438,11 @@ async def main():
# Démarrer le serveur web en arrière-plan
start_web_server()
# Démarrer le worker de la queue de téléchargement
queue_worker_thread = threading.Thread(target=download_queue_worker, daemon=True)
queue_worker_thread.start()
logger.info("Worker de la queue de téléchargement démarré")
running = True
loading_step = "none"
sources = []
@@ -473,7 +478,7 @@ async def main():
config.needs_redraw = True
last_redraw_time = current_time
# Forcer redraw toutes les 100 ms dans history avec téléchargement actif
if config.menu_state == "history" and any(entry["status"] == "Téléchargement" for entry in config.history):
if config.menu_state == "history" and any(entry["status"] in ["Downloading", "Téléchargement"] for entry in config.history):
if current_time - last_redraw_time >= 100:
config.needs_redraw = True
last_redraw_time = current_time
@@ -687,6 +692,7 @@ async def main():
"history_error_details",
"history_confirm_delete",
"history_extract_archive",
"text_file_viewer", # Visualiseur de fichiers texte
# Menus filtrage avancé
"filter_menu_choice",
"filter_advanced",
@@ -1115,6 +1121,9 @@ async def main():
elif config.menu_state == "history_error_details":
from display import draw_history_error_details
draw_history_error_details(screen)
elif config.menu_state == "text_file_viewer":
from display import draw_text_file_viewer
draw_text_file_viewer(screen)
elif config.menu_state == "history_confirm_delete":
from display import draw_history_confirm_delete
draw_history_confirm_delete(screen)

View File

@@ -13,7 +13,7 @@ except Exception:
pygame = None # type: ignore
# Version actuelle de l'application
app_version = "2.3.2.7"
app_version = "2.3.3.3"
def get_application_root():
@@ -133,6 +133,7 @@ logger = logging.getLogger(__name__)
# File d'attente de téléchargements (jobs en attente)
download_queue = [] # Liste de dicts: {url, platform, game_name, ...}
pending_download_is_queue = False # Indique si pending_download doit être ajouté à la queue
# Indique si un téléchargement est en cours
download_active = False

View File

@@ -59,6 +59,7 @@ VALID_STATES = [
"history_error_details", # détails de l'erreur
"history_confirm_delete", # confirmation suppression jeu
"history_extract_archive", # extraction d'archive
"text_file_viewer", # visualiseur de fichiers texte
# Nouveaux menus filtrage avancé
"filter_menu_choice", # menu de choix entre recherche et filtrage avancé
"filter_search", # recherche par nom (existant, mais renommé)
@@ -158,7 +159,7 @@ def load_controls_config(path=CONTROLS_CONFIG_PATH):
dev_field = preset.get('device') if isinstance(preset, dict) else None
if isinstance(dev_field, str) and _sanitize(dev_field) == target_norm:
logging.getLogger(__name__).info(f"Chargement préréglage (device) depuis le fichier: {fname}")
print(f"Chargement préréglage (device) depuis le fichier: {fname}")
print(f"Chargement prereglage (device) depuis le fichier: {fname}")
return preset
except Exception as e:
logging.getLogger(__name__).warning(f"Échec scan préréglages par device: {e}")
@@ -517,6 +518,8 @@ def handle_controls(event, sources, joystick, screen):
max_row = len(keyboard_layout) - 1
max_col = len(keyboard_layout[row]) - 1
if is_input_matched(event, "up"):
if row == 0: # if you are in the first row and press UP jump to last row
row = max_row + (1 if col <= 5 else 0)
if row > 0:
config.selected_key = (row - 1, min(col, len(keyboard_layout[row - 1]) - 1))
config.repeat_action = "up"
@@ -525,6 +528,8 @@ def handle_controls(event, sources, joystick, screen):
config.repeat_key = event.key if event.type == pygame.KEYDOWN else event.button if event.type == pygame.JOYBUTTONDOWN else (event.axis, 1 if event.value > 0 else -1) if event.type == pygame.JOYAXISMOTION else event.value
config.needs_redraw = True
elif is_input_matched(event, "down"):
if (col <= 5 and row == max_row) or (col > 5 and row == max_row-1): # if you are in the last row and press DOWN jump to first row
row = -1
if row < max_row:
config.selected_key = (row + 1, min(col, len(keyboard_layout[row + 1]) - 1))
config.repeat_action = "down"
@@ -533,6 +538,8 @@ def handle_controls(event, sources, joystick, screen):
config.repeat_key = event.key if event.type == pygame.KEYDOWN else event.button if event.type == pygame.JOYBUTTONDOWN else (event.axis, 1 if event.value > 0 else -1) if event.type == pygame.JOYAXISMOTION else event.value
config.needs_redraw = True
elif is_input_matched(event, "left"):
if col == 0: # if you are in the first col and press LEFT jump to last col
col = max_col + 1
if col > 0:
config.selected_key = (row, col - 1)
config.repeat_action = "left"
@@ -541,6 +548,8 @@ def handle_controls(event, sources, joystick, screen):
config.repeat_key = event.key if event.type == pygame.KEYDOWN else event.button if event.type == pygame.JOYBUTTONDOWN else (event.axis, 1 if event.value > 0 else -1) if event.type == pygame.JOYAXISMOTION else event.value
config.needs_redraw = True
elif is_input_matched(event, "right"):
if col == max_col: # if you are in the last col and press RIGHT jump to first col
col = -1
if col < max_col:
config.selected_key = (row, col + 1)
config.repeat_action = "right"
@@ -550,7 +559,11 @@ def handle_controls(event, sources, joystick, screen):
config.needs_redraw = True
elif is_input_matched(event, "confirm"):
config.search_query += keyboard_layout[row][col]
config.filtered_games = [game for game in config.games if config.search_query.lower() in game[0].lower()]
# Appliquer d'abord les filtres avancés si actifs, puis le filtre par nom
base_games = config.games
if config.game_filter_obj and config.game_filter_obj.is_active():
base_games = config.game_filter_obj.apply_filters(config.games)
config.filtered_games = [game for game in base_games if config.search_query.lower() in game[0].lower()]
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
@@ -558,14 +571,22 @@ def handle_controls(event, sources, joystick, screen):
elif is_input_matched(event, "delete"):
if config.search_query:
config.search_query = config.search_query[:-1]
config.filtered_games = [game for game in config.games if config.search_query.lower() in game[0].lower()]
# Appliquer d'abord les filtres avancés si actifs, puis le filtre par nom
base_games = config.games
if config.game_filter_obj and config.game_filter_obj.is_active():
base_games = config.game_filter_obj.apply_filters(config.games)
config.filtered_games = [game for game in base_games if config.search_query.lower() in game[0].lower()]
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
#logger.debug(f"Suppression caractère: query={config.search_query}, jeux filtrés={len(config.filtered_games)}")
elif is_input_matched(event, "space"):
config.search_query += " "
config.filtered_games = [game for game in config.games if config.search_query.lower() in game[0].lower()]
# Appliquer d'abord les filtres avancés si actifs, puis le filtre par nom
base_games = config.games
if config.game_filter_obj and config.game_filter_obj.is_active():
base_games = config.game_filter_obj.apply_filters(config.games)
config.filtered_games = [game for game in base_games if config.search_query.lower() in game[0].lower()]
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
@@ -574,7 +595,13 @@ def handle_controls(event, sources, joystick, screen):
config.search_mode = False
config.search_query = ""
config.selected_key = (0, 0)
config.filtered_games = config.games
# Restaurer les jeux filtrés par les filtres avancés si actifs
if hasattr(config, 'game_filter_obj') and config.game_filter_obj and config.game_filter_obj.is_active():
config.filtered_games = config.game_filter_obj.apply_filters(config.games)
config.filter_active = True
else:
config.filtered_games = config.games
config.filter_active = False
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
@@ -596,8 +623,13 @@ def handle_controls(event, sources, joystick, screen):
elif is_input_matched(event, "cancel"):
config.search_mode = False
config.search_query = ""
config.filtered_games = config.games
config.filter_active = False
# Restaurer les jeux filtrés par les filtres avancés si actifs
if hasattr(config, 'game_filter_obj') and config.game_filter_obj and config.game_filter_obj.is_active():
config.filtered_games = config.game_filter_obj.apply_filters(config.games)
config.filter_active = True
else:
config.filtered_games = config.games
config.filter_active = False
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
@@ -606,7 +638,11 @@ def handle_controls(event, sources, joystick, screen):
# Saisie de texte alphanumérique
if event.unicode.isalnum() or event.unicode == ' ':
config.search_query += event.unicode
config.filtered_games = [game for game in config.games if config.search_query.lower() in game[0].lower()]
# Appliquer d'abord les filtres avancés si actifs, puis le filtre par nom
base_games = config.games
if config.game_filter_obj and config.game_filter_obj.is_active():
base_games = config.game_filter_obj.apply_filters(config.games)
config.filtered_games = [game for game in base_games if config.search_query.lower() in game[0].lower()]
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
@@ -615,7 +651,11 @@ def handle_controls(event, sources, joystick, screen):
elif is_input_matched(event, "delete"):
if config.search_query:
config.search_query = config.search_query[:-1]
config.filtered_games = [game for game in config.games if config.search_query.lower() in game[0].lower()]
# Appliquer d'abord les filtres avancés si actifs, puis le filtre par nom
base_games = config.games
if config.game_filter_obj and config.game_filter_obj.is_active():
base_games = config.game_filter_obj.apply_filters(config.games)
config.filtered_games = [game for game in base_games if config.search_query.lower() in game[0].lower()]
config.current_game = 0
config.scroll_offset = 0
config.needs_redraw = True
@@ -700,6 +740,7 @@ def handle_controls(event, sources, joystick, screen):
# Si extension non supportée ET pas en archive connu, afficher avertissement
if (not is_supported and not zip_ok) and not allow_unknown:
config.pending_download = pending_download
config.pending_download_is_queue = True # Marquer comme action queue
config.previous_menu_state = config.menu_state
config.menu_state = "extension_warning"
config.extension_confirm_selection = 0
@@ -773,29 +814,69 @@ def handle_controls(event, sources, joystick, screen):
if config.extension_confirm_selection == 0: # 0 = Oui, 1 = Non
if config.pending_download and len(config.pending_download) == 4:
url, platform, game_name, is_zip_non_supported = config.pending_download
if is_1fichier_url(url):
ensure_download_provider_keys(False)
# Avertissement si pas de clé (utilisation mode gratuit)
if missing_all_provider_keys():
logger.warning("Aucune clé API - Mode gratuit 1fichier sera utilisé (attente requise)")
# Vérifier si c'est une action queue
is_queue_action = getattr(config, 'pending_download_is_queue', False)
if is_queue_action:
# Ajouter à la queue au lieu de télécharger immédiatement
task_id = str(pygame.time.get_ticks())
task = asyncio.create_task(download_from_1fichier(url, platform, game_name, is_zip_non_supported, task_id))
queue_item = {
'url': url,
'platform': platform,
'game_name': game_name,
'is_zip_non_supported': is_zip_non_supported,
'is_1fichier': is_1fichier_url(url),
'task_id': task_id,
'status': 'Queued'
}
config.download_queue.append(queue_item)
# Ajouter une entrée à l'historique avec status "Queued"
config.history.append({
'platform': platform,
'game_name': game_name,
'status': 'Queued',
'url': url,
'progress': 0,
'message': _("download_queued"),
'timestamp': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'downloaded_size': 0,
'total_size': 0,
'task_id': task_id
})
save_history(config.history)
# Afficher un toast de notification
show_toast(f"{game_name}\n{_('download_queued')}")
# Le worker de la queue détectera automatiquement le nouvel élément
logger.debug(f"{game_name} ajouté à la file d'attente après confirmation. Queue size: {len(config.download_queue)}")
else:
task_id = str(pygame.time.get_ticks())
task = asyncio.create_task(download_rom(url, platform, game_name, is_zip_non_supported, task_id))
config.download_tasks[task_id] = (task, url, game_name, platform)
# Afficher un toast de notification
show_toast(f"{_('download_started')}: {game_name}")
# Téléchargement immédiat
if is_1fichier_url(url):
ensure_download_provider_keys(False)
# Avertissement si pas de clé (utilisation mode gratuit)
if missing_all_provider_keys():
logger.warning("Aucune clé API - Mode gratuit 1fichier sera utilisé (attente requise)")
task_id = str(pygame.time.get_ticks())
task = asyncio.create_task(download_from_1fichier(url, platform, game_name, is_zip_non_supported, task_id))
else:
task_id = str(pygame.time.get_ticks())
task = asyncio.create_task(download_rom(url, platform, game_name, is_zip_non_supported, task_id))
config.download_tasks[task_id] = (task, url, game_name, platform)
# Afficher un toast de notification
show_toast(f"{_('download_started')}: {game_name}")
logger.debug(f"[CONTROLS_EXT_WARNING] Téléchargement confirmé après avertissement: {game_name} pour {platform} depuis {url}, task_id={task_id}")
config.previous_menu_state = validate_menu_state(config.previous_menu_state)
config.needs_redraw = True
logger.debug(f"[CONTROLS_EXT_WARNING] Téléchargement confirmé après avertissement: {game_name} pour {platform} depuis {url}, task_id={task_id}")
config.pending_download = None
config.pending_download_is_queue = False
config.extension_confirm_selection = 0 # Réinitialiser la sélection
action = "download"
# Téléchargement simple - retourner au menu précédent
# Retourner au menu précédent
config.menu_state = config.previous_menu_state if config.previous_menu_state else "game"
logger.debug(f"[CONTROLS_EXT_WARNING] Retour au menu {config.menu_state} après confirmation")
else:
@@ -903,22 +984,35 @@ def handle_controls(event, sources, joystick, screen):
if is_input_matched(event, "confirm"):
if config.confirm_cancel_selection == 1: # Oui
entry = config.history[config.current_history_item]
task_id = entry.get("task_id")
url = entry.get("url")
# Annuler la tâche correspondante
for task_id, (task, task_url, game_name, platform) in list(config.download_tasks.items()):
if task_url == url:
game_name = entry.get("game_name", "Unknown")
# Annuler via cancel_events (pour les threads de téléchargement)
try:
request_cancel(task_id)
logger.debug(f"Signal d'annulation envoyé pour task_id={task_id}")
except Exception as e:
logger.debug(f"Erreur lors de l'envoi du signal d'annulation: {e}")
# Annuler aussi la tâche asyncio si elle existe (pour les téléchargements directs)
for tid, (task, task_url, tname, tplatform) in list(config.download_tasks.items()):
if tid == task_id or task_url == url:
try:
request_cancel(task_id)
except Exception:
pass
task.cancel()
del config.download_tasks[task_id]
entry["status"] = "Canceled"
entry["progress"] = 0
entry["message"] = _("download_canceled") if _ else "Download canceled"
save_history(config.history)
logger.debug(f"Téléchargement annulé: {game_name}")
task.cancel()
del config.download_tasks[tid]
logger.debug(f"Tâche asyncio annulée: {tname}")
except Exception as e:
logger.debug(f"Erreur lors de l'annulation de la tâche asyncio: {e}")
break
# Mettre à jour l'entrée historique
entry["status"] = "Canceled"
entry["progress"] = 0
entry["message"] = _("download_canceled") if _ else "Download canceled"
save_history(config.history)
logger.debug(f"Téléchargement annulé: {game_name}")
config.menu_state = "history"
config.needs_redraw = True
else: # Non
@@ -994,12 +1088,20 @@ def handle_controls(event, sources, joystick, screen):
options.append("scraper")
# Options selon statut
if status == "Download_OK" or status == "Completed":
if status == "Queued":
# En attente dans la queue
options.append("remove_from_queue")
elif status in ["Downloading", "Téléchargement", "Extracting"]:
# Téléchargement en cours
options.append("cancel_download")
elif status == "Download_OK" or status == "Completed":
# Vérifier si c'est une archive ET si le fichier existe
if actual_filename and file_exists:
ext = os.path.splitext(actual_filename)[1].lower()
if ext in ['.zip', '.rar']:
options.append("extract_archive")
elif ext == '.txt':
options.append("open_file")
elif status in ["Erreur", "Error", "Canceled"]:
options.append("error_info")
options.append("retry")
@@ -1035,13 +1137,67 @@ def handle_controls(event, sources, joystick, screen):
selected_option = options[sel]
logger.debug(f"history_game_options: CONFIRM option={selected_option}")
if selected_option == "download_folder":
if selected_option == "remove_from_queue":
# Retirer de la queue
task_id = entry.get("task_id")
url = entry.get("url")
# Chercher et retirer de la queue
for i, queue_item in enumerate(config.download_queue):
if queue_item.get("task_id") == task_id or queue_item.get("url") == url:
config.download_queue.pop(i)
logger.debug(f"Jeu retiré de la queue: {game_name}")
break
# Mettre à jour l'entrée historique avec status Canceled
entry["status"] = "Canceled"
entry["progress"] = 0
entry["message"] = _("download_canceled") if _ else "Download canceled"
save_history(config.history)
# Retour à l'historique
config.menu_state = "history"
config.needs_redraw = True
elif selected_option == "cancel_download":
# Rediriger vers le dialogue de confirmation (même que bouton cancel)
config.previous_menu_state = "history"
config.menu_state = "confirm_cancel_download"
config.confirm_cancel_selection = 0
config.needs_redraw = True
logger.debug("Redirection vers confirm_cancel_download depuis history_game_options")
elif selected_option == "download_folder":
# Afficher le chemin de destination
config.previous_menu_state = "history_game_options"
config.menu_state = "history_show_folder"
config.needs_redraw = True
logger.debug(f"Affichage du dossier de téléchargement pour {game_name}")
elif selected_option == "open_file":
# Ouvrir le fichier texte
if actual_path and os.path.exists(actual_path):
try:
with open(actual_path, 'r', encoding='utf-8', errors='replace') as f:
content = f.read()
config.text_file_content = content
config.text_file_name = actual_filename
config.text_file_scroll_offset = 0
config.previous_menu_state = "history_game_options"
config.menu_state = "text_file_viewer"
config.needs_redraw = True
logger.debug(f"Ouverture du fichier texte: {actual_filename}")
except Exception as e:
logger.error(f"Erreur lors de l'ouverture du fichier texte: {e}")
config.menu_state = "error"
config.error_message = f"Erreur lors de l'ouverture du fichier: {str(e)}"
config.needs_redraw = True
else:
logger.error(f"Fichier texte introuvable: {actual_path}")
config.menu_state = "error"
config.error_message = "Fichier introuvable"
config.needs_redraw = True
elif selected_option == "extract_archive":
# L'option n'apparaît que si le fichier existe, pas besoin de re-vérifier
config.previous_menu_state = "history_game_options"
@@ -1193,6 +1349,128 @@ def handle_controls(event, sources, joystick, screen):
config.needs_redraw = True
# Affichage détails erreur
# Visualiseur de fichiers texte
elif config.menu_state == "text_file_viewer":
content = getattr(config, 'text_file_content', '')
if content:
lines = content.split('\n')
line_height = config.small_font.get_height() + 2
# Calculer le nombre de lignes visibles (approximation)
controls_y = config.screen_height - int(config.screen_height * 0.037)
margin = 40
header_height = 60
content_area_height = controls_y - 2 * margin - 10 - header_height - 20
visible_lines = int(content_area_height / line_height)
scroll_offset = getattr(config, 'text_file_scroll_offset', 0)
max_scroll = max(0, len(lines) - visible_lines)
if is_input_matched(event, "up"):
config.text_file_scroll_offset = max(0, scroll_offset - 1)
update_key_state("up", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "down"):
config.text_file_scroll_offset = min(max_scroll, scroll_offset + 1)
update_key_state("down", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "page_up"):
config.text_file_scroll_offset = max(0, scroll_offset - visible_lines)
update_key_state("page_up", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "page_down"):
config.text_file_scroll_offset = min(max_scroll, scroll_offset + visible_lines)
update_key_state("page_down", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "cancel") or is_input_matched(event, "confirm"):
config.menu_state = validate_menu_state(config.previous_menu_state)
config.needs_redraw = True
else:
# Si pas de contenu, retourner au menu précédent
if is_input_matched(event, "cancel") or is_input_matched(event, "confirm"):
config.menu_state = validate_menu_state(config.previous_menu_state)
config.needs_redraw = True
# Visualiseur de fichiers texte
elif config.menu_state == "text_file_viewer":
content = getattr(config, 'text_file_content', '')
if content:
from utils import wrap_text
# Calculer les dimensions
controls_y = config.screen_height - int(config.screen_height * 0.037)
margin = 40
header_height = 60
rect_width = config.screen_width - 2 * margin
content_area_height = controls_y - 2 * margin - 10 - header_height - 20
max_width = rect_width - 60
# Diviser le contenu en lignes et appliquer le word wrap
original_lines = content.split('\n')
wrapped_lines = []
for original_line in original_lines:
if original_line.strip(): # Si la ligne n'est pas vide
wrapped = wrap_text(original_line, config.small_font, max_width)
wrapped_lines.extend(wrapped)
else: # Ligne vide
wrapped_lines.append('')
line_height = config.small_font.get_height() + 2
visible_lines = int(content_area_height / line_height)
scroll_offset = getattr(config, 'text_file_scroll_offset', 0)
max_scroll = max(0, len(wrapped_lines) - visible_lines)
if is_input_matched(event, "up"):
config.text_file_scroll_offset = max(0, scroll_offset - 1)
update_key_state("up", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "down"):
config.text_file_scroll_offset = min(max_scroll, scroll_offset + 1)
update_key_state("down", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "page_up"):
config.text_file_scroll_offset = max(0, scroll_offset - visible_lines)
update_key_state("page_up", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "page_down"):
config.text_file_scroll_offset = min(max_scroll, scroll_offset + visible_lines)
update_key_state("page_down", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
config.needs_redraw = True
elif is_input_matched(event, "cancel") or is_input_matched(event, "confirm"):
config.menu_state = validate_menu_state(config.previous_menu_state)
config.needs_redraw = True
else:
# Si pas de contenu, retourner au menu précédent
if is_input_matched(event, "cancel") or is_input_matched(event, "confirm"):
config.menu_state = validate_menu_state(config.previous_menu_state)
config.needs_redraw = True
elif config.menu_state == "history_error_details":
if is_input_matched(event, "confirm") or is_input_matched(event, "cancel"):
config.menu_state = validate_menu_state(config.previous_menu_state)
@@ -1325,8 +1603,15 @@ def handle_controls(event, sources, joystick, screen):
# Confirmation quitter
elif config.menu_state == "confirm_exit":
if is_input_matched(event, "confirm"):
if config.confirm_selection == 1:
# Sous-menu Quit: 0=Quit RGSX, 1=Restart RGSX, 2=Back
if is_input_matched(event, "up"):
config.confirm_selection = max(0, config.confirm_selection - 1)
config.needs_redraw = True
elif is_input_matched(event, "down"):
config.confirm_selection = min(2, config.confirm_selection + 1)
config.needs_redraw = True
elif is_input_matched(event, "confirm"):
if config.confirm_selection == 0: # Quit RGSX
# Mark all in-progress downloads as canceled in history
try:
for entry in getattr(config, 'history', []) or []:
@@ -1338,7 +1623,9 @@ def handle_controls(event, sources, joystick, screen):
except Exception:
pass
return "quit"
else:
elif config.confirm_selection == 1: # Restart RGSX
restart_application(2000)
elif config.confirm_selection == 2: # Back
# Retour à l'état capturé (confirm_exit_origin) sinon previous_menu_state sinon platform
target = getattr(config, 'confirm_exit_origin', getattr(config, 'previous_menu_state', 'platform'))
config.menu_state = validate_menu_state(target)
@@ -1348,11 +1635,18 @@ def handle_controls(event, sources, joystick, screen):
except Exception:
pass
config.needs_redraw = True
logger.debug(f"Retour à {config.menu_state} depuis confirm_exit (annulation)")
elif is_input_matched(event, "left") or is_input_matched(event, "right"):
config.confirm_selection = 1 - config.confirm_selection
logger.debug(f"Retour à {config.menu_state} depuis confirm_exit (back)")
elif is_input_matched(event, "cancel"):
# Retour à l'état capturé
target = getattr(config, 'confirm_exit_origin', getattr(config, 'previous_menu_state', 'platform'))
config.menu_state = validate_menu_state(target)
if hasattr(config, 'confirm_exit_origin'):
try:
delattr(config, 'confirm_exit_origin')
except Exception:
pass
config.needs_redraw = True
#logger.debug(f"Changement sélection confirm_exit: {config.confirm_selection}")
logger.debug(f"Retour à {config.menu_state} depuis confirm_exit (cancel)")
# Menu pause
elif config.menu_state == "pause_menu":
@@ -1372,38 +1666,36 @@ def handle_controls(event, sources, joystick, screen):
config.selected_option = min(total - 1, config.selected_option + 1)
config.needs_redraw = True
elif is_input_matched(event, "confirm"):
if config.selected_option == 0: # Language selector direct
if config.selected_option == 0: # Games submenu
config.menu_state = "pause_games_menu"
if not hasattr(config, 'pause_games_selection'):
config.pause_games_selection = 0
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 1: # Language selector direct
config.menu_state = "language_select"
config.previous_menu_state = "pause_menu"
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 1: # Controls submenu
elif config.selected_option == 2: # Controls submenu
config.menu_state = "pause_controls_menu"
if not hasattr(config, 'pause_controls_selection'):
config.pause_controls_selection = 0
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 2: # Display submenu
elif config.selected_option == 3: # Display submenu
config.menu_state = "pause_display_menu"
if not hasattr(config, 'pause_display_selection'):
config.pause_display_selection = 0
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 3: # Games submenu
config.menu_state = "pause_games_menu"
if not hasattr(config, 'pause_games_selection'):
config.pause_games_selection = 0
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 4: # Settings submenu
config.menu_state = "pause_settings_menu"
if not hasattr(config, 'pause_settings_selection'):
config.pause_settings_selection = 0
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 5: # Restart
restart_application(2000)
elif config.selected_option == 6: # Support
elif config.selected_option == 5: # Support
success, message, zip_path = generate_support_zip()
if success:
config.support_zip_path = zip_path
@@ -1414,7 +1706,7 @@ def handle_controls(event, sources, joystick, screen):
config.menu_state = "support_dialog"
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
elif config.selected_option == 7: # Quit
elif config.selected_option == 6: # Quit submenu
# Capturer l'origine pause_menu pour retour si annulation
config.confirm_exit_origin = "pause_menu"
config.previous_menu_state = validate_menu_state(config.previous_menu_state)
@@ -1579,7 +1871,7 @@ def handle_controls(event, sources, joystick, screen):
# Sous-menu Games
elif config.menu_state == "pause_games_menu":
sel = getattr(config, 'pause_games_selection', 0)
total = 7 # history, source, redownload, unsupported, hide premium, filter, back
total = 7 # update cache, history, source, unsupported, hide premium, filter, back
if is_input_matched(event, "up"):
config.pause_games_selection = (sel - 1) % total
config.needs_redraw = True
@@ -1587,14 +1879,19 @@ def handle_controls(event, sources, joystick, screen):
config.pause_games_selection = (sel + 1) % total
config.needs_redraw = True
elif is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right"):
if sel == 0 and is_input_matched(event, "confirm"): # history
if sel == 0 and is_input_matched(event, "confirm"): # update cache
config.previous_menu_state = "pause_games_menu"
config.menu_state = "reload_games_data"
config.redownload_confirm_selection = 0
config.needs_redraw = True
elif sel == 1 and is_input_matched(event, "confirm"): # history
config.history = load_history()
config.current_history_item = 0
config.history_scroll_offset = 0
config.previous_menu_state = "pause_games_menu"
config.menu_state = "history"
config.needs_redraw = True
elif sel == 1 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")):
elif sel == 2 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")): # source mode
try:
current_mode = get_sources_mode()
new_mode = set_sources_mode('custom' if current_mode == 'rgsx' else 'rgsx')
@@ -1609,11 +1906,6 @@ def handle_controls(event, sources, joystick, screen):
logger.info(f"Changement du mode des sources vers {new_mode}")
except Exception as e:
logger.error(f"Erreur changement mode sources: {e}")
elif sel == 2 and is_input_matched(event, "confirm"): # redownload cache
config.previous_menu_state = "pause_games_menu"
config.menu_state = "reload_games_data"
config.redownload_confirm_selection = 0
config.needs_redraw = True
elif sel == 3 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")): # unsupported toggle
try:
current = get_show_unsupported_platforms()
@@ -1652,11 +1944,19 @@ def handle_controls(event, sources, joystick, screen):
elif config.menu_state == "pause_settings_menu":
sel = getattr(config, 'pause_settings_selection', 0)
# Calculer le nombre total d'options selon le système
total = 4 # music, symlink, api keys, back
# Liste des options : music, symlink, [web_service], [custom_dns], api keys, back
total = 4 # music, symlink, api keys, back (Windows)
web_service_index = -1
custom_dns_index = -1
api_keys_index = 2
back_index = 3
if config.OPERATING_SYSTEM == "Linux":
total = 5 # music, symlink, web_service, api keys, back
total = 6 # music, symlink, web_service, custom_dns, api keys, back
web_service_index = 2
custom_dns_index = 3
api_keys_index = 4
back_index = 5
if is_input_matched(event, "up"):
config.pause_settings_selection = (sel - 1) % total
@@ -1705,12 +2005,31 @@ def handle_controls(event, sources, joystick, screen):
else:
logger.error(f"Erreur toggle service web: {message}")
threading.Thread(target=toggle_service, daemon=True).start()
# Option API Keys (index varie selon Linux ou pas)
elif sel == (web_service_index + 1 if web_service_index >= 0 else 2) and is_input_matched(event, "confirm"):
# Option 3: Custom DNS toggle (seulement si Linux)
elif sel == custom_dns_index and custom_dns_index >= 0 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")):
from utils import check_custom_dns_status, toggle_custom_dns_at_boot
current_status = check_custom_dns_status()
# Afficher un message de chargement
config.popup_message = _("settings_custom_dns_enabling") if not current_status else _("settings_custom_dns_disabling")
config.popup_timer = 1000
config.needs_redraw = True
# Exécuter en thread pour ne pas bloquer l'UI
def toggle_dns():
success, message = toggle_custom_dns_at_boot(not current_status)
config.popup_message = message
config.popup_timer = 5000 if success else 7000
config.needs_redraw = True
if success:
logger.info(f"Custom DNS {'activé' if not current_status else 'désactivé'} au démarrage")
else:
logger.error(f"Erreur toggle custom DNS: {message}")
threading.Thread(target=toggle_dns, daemon=True).start()
# Option API Keys
elif sel == api_keys_index and is_input_matched(event, "confirm"):
config.menu_state = "pause_api_keys_status"
config.needs_redraw = True
# Option Back (dernière option)
elif sel == (total - 1) and is_input_matched(event, "confirm"):
elif sel == back_index and is_input_matched(event, "confirm"):
config.menu_state = "pause_menu"
config.last_state_change_time = pygame.time.get_ticks()
config.needs_redraw = True
@@ -1942,7 +2261,11 @@ def handle_controls(event, sources, joystick, screen):
# Recherche par nom (mode existant)
config.search_mode = True
config.search_query = ""
config.filtered_games = config.games
# Initialiser avec les jeux déjà filtrés par les filtres avancés si actifs
if hasattr(config, 'game_filter_obj') and config.game_filter_obj and config.game_filter_obj.is_active():
config.filtered_games = config.game_filter_obj.apply_filters(config.games)
else:
config.filtered_games = config.games
config.current_game = 0
config.scroll_offset = 0
config.selected_key = (0, 0)
@@ -1983,69 +2306,89 @@ def handle_controls(event, sources, joystick, screen):
if filter_dict:
config.game_filter_obj.load_from_dict(filter_dict)
# Construire la liste des options (comme dans draw_filter_advanced)
options = []
options.append(('header', 'region_title'))
for region in GameFilters.REGIONS:
options.append(('region', region))
options.append(('separator', ''))
options.append(('header', 'other_options'))
options.append(('toggle', 'hide_non_release'))
options.append(('toggle', 'one_rom_per_game'))
options.append(('button_inline', 'priority_config'))
# Construire la liste linéaire des éléments sélectionnables (pour simplifier l'indexation)
# Régions individuelles
num_regions = len(GameFilters.REGIONS)
# Options toggle/button
num_other_options = 3 # hide_non_release, one_rom_per_game, priority_config
# Boutons en bas
num_buttons = 3 # apply, reset, back
# Boutons séparés (3 boutons au total)
buttons = [
('button', 'apply'),
('button', 'reset'),
('button', 'back')
]
# Total d'éléments sélectionnables
total_items = len(options) + len(buttons)
total_items = num_regions + num_other_options + num_buttons
if is_input_matched(event, "up"):
# Chercher l'option sélectionnable précédente
config.selected_filter_option = (config.selected_filter_option - 1) % total_items
while config.selected_filter_option < len(options) and options[config.selected_filter_option][0] in ['header', 'separator']:
# Navigation verticale dans la grille ou entre sections
if config.selected_filter_option < num_regions:
# Dans la grille des régions (3 colonnes)
if config.selected_filter_option >= 3:
# Monter d'une ligne
config.selected_filter_option -= 3
else:
# Déjà en haut, aller aux boutons
config.selected_filter_option = total_items - 2 # Bouton du milieu (reset)
else:
# Dans les options ou boutons, monter normalement
config.selected_filter_option = (config.selected_filter_option - 1) % total_items
config.needs_redraw = True
update_key_state("up", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
elif is_input_matched(event, "down"):
# Chercher l'option sélectionnable suivante
config.selected_filter_option = (config.selected_filter_option + 1) % total_items
while config.selected_filter_option < len(options) and options[config.selected_filter_option][0] in ['header', 'separator']:
# Navigation verticale
if config.selected_filter_option < num_regions:
# Dans la grille des régions
if config.selected_filter_option + 3 < num_regions:
# Descendre d'une ligne
config.selected_filter_option += 3
else:
# Aller aux autres options
config.selected_filter_option = num_regions
else:
# Dans les options ou boutons, descendre normalement
config.selected_filter_option = (config.selected_filter_option + 1) % total_items
config.needs_redraw = True
update_key_state("down", True, event.type, event.key if event.type == pygame.KEYDOWN else
event.button if event.type == pygame.JOYBUTTONDOWN else
(event.axis, event.value) if event.type == pygame.JOYAXISMOTION else
event.value)
elif is_input_matched(event, "left") or is_input_matched(event, "right"):
# Navigation gauche/droite uniquement pour les boutons en bas
if config.selected_filter_option >= len(options):
button_index = config.selected_filter_option - len(options)
if is_input_matched(event, "left"):
button_index = (button_index - 1) % len(buttons)
else:
button_index = (button_index + 1) % len(buttons)
config.selected_filter_option = len(options) + button_index
elif is_input_matched(event, "left"):
# Navigation horizontale
if config.selected_filter_option < num_regions:
# Dans la grille des régions
if config.selected_filter_option % 3 > 0:
config.selected_filter_option -= 1
config.needs_redraw = True
elif config.selected_filter_option >= num_regions + num_other_options:
# Dans les boutons en bas
button_idx = config.selected_filter_option - (num_regions + num_other_options)
button_idx = (button_idx - 1) % num_buttons
config.selected_filter_option = num_regions + num_other_options + button_idx
config.needs_redraw = True
elif is_input_matched(event, "right"):
# Navigation horizontale
if config.selected_filter_option < num_regions:
# Dans la grille des régions
if config.selected_filter_option % 3 < 2 and config.selected_filter_option + 1 < num_regions:
config.selected_filter_option += 1
config.needs_redraw = True
elif config.selected_filter_option >= num_regions + num_other_options:
# Dans les boutons en bas
button_idx = config.selected_filter_option - (num_regions + num_other_options)
button_idx = (button_idx + 1) % num_buttons
config.selected_filter_option = num_regions + num_other_options + button_idx
config.needs_redraw = True
elif is_input_matched(event, "confirm"):
# Déterminer si c'est une option ou un bouton
if config.selected_filter_option < len(options):
option_type, *option_data = options[config.selected_filter_option]
else:
# C'est un bouton
button_index = config.selected_filter_option - len(options)
option_type, *option_data = buttons[button_index]
if option_type == 'region':
# Basculer filtre région: include ↔ exclude (include par défaut)
region = option_data[0]
# Déterminer quel élément a été sélectionné
if config.selected_filter_option < num_regions:
# C'est une région
region = GameFilters.REGIONS[config.selected_filter_option]
current_state = config.game_filter_obj.region_filters.get(region, 'include')
if current_state == 'include':
config.game_filter_obj.region_filters[region] = 'exclude'
@@ -2054,28 +2397,31 @@ def handle_controls(event, sources, joystick, screen):
config.needs_redraw = True
logger.debug(f"Filtre région {region} modifié: {config.game_filter_obj.region_filters[region]}")
elif option_type == 'toggle':
toggle_name = option_data[0]
if toggle_name == 'hide_non_release':
elif config.selected_filter_option < num_regions + num_other_options:
# C'est une autre option
option_idx = config.selected_filter_option - num_regions
if option_idx == 0:
# hide_non_release
config.game_filter_obj.hide_non_release = not config.game_filter_obj.hide_non_release
elif toggle_name == 'one_rom_per_game':
config.needs_redraw = True
logger.debug("Toggle hide_non_release modifié")
elif option_idx == 1:
# one_rom_per_game
config.game_filter_obj.one_rom_per_game = not config.game_filter_obj.one_rom_per_game
config.needs_redraw = True
logger.debug(f"Toggle {toggle_name} modifié")
elif option_type == 'button_inline':
button_name = option_data[0]
if button_name == 'priority_config':
# Ouvrir le menu de configuration de priorité
config.needs_redraw = True
logger.debug("Toggle one_rom_per_game modifié")
elif option_idx == 2:
# priority_config
config.menu_state = "filter_priority_config"
config.selected_priority_index = 0
config.needs_redraw = True
logger.debug("Ouverture configuration priorité régions")
elif option_type == 'button':
button_name = option_data[0]
if button_name == 'apply':
# Appliquer les filtres
else:
# C'est un bouton
button_idx = config.selected_filter_option - (num_regions + num_other_options)
if button_idx == 0:
# Apply
save_game_filters(config.game_filter_obj.to_dict())
# Appliquer aux jeux actuels
@@ -2092,8 +2438,8 @@ def handle_controls(event, sources, joystick, screen):
config.needs_redraw = True
logger.debug("Filtres appliqués")
elif button_name == 'reset':
# Réinitialiser les filtres
elif button_idx == 1:
# Reset
config.game_filter_obj.reset()
save_game_filters(config.game_filter_obj.to_dict())
config.filtered_games = config.games
@@ -2101,8 +2447,8 @@ def handle_controls(event, sources, joystick, screen):
config.needs_redraw = True
logger.debug("Filtres réinitialisés")
elif button_name == 'back':
# Retour sans appliquer
elif button_idx == 2:
# Back
config.menu_state = "game"
config.needs_redraw = True
logger.debug("Retour sans appliquer les filtres")
@@ -2593,4 +2939,4 @@ def get_emergency_controls():
# manette basique
"confirm_joy": {"type": "button", "button": 0},
"cancel_joy": {"type": "button", "button": 1},
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -69,30 +69,67 @@ class GameFilters:
name = game_name.upper()
regions = []
# Patterns de région communs
if 'USA' in name or 'US)' in name:
regions.append('USA')
# Patterns de région communs - chercher les codes entre parenthèses d'abord
# Codes de région/langue dans les parenthèses (Ex: (Fr,De) ou (En,Nl))
paren_content = re.findall(r'\(([^)]+)\)', name)
for content in paren_content:
# Codes de langue/région séparés par virgules
codes = [c.strip() for c in content.split(',')]
for code in codes:
if code in ['FR', 'FRA']:
if 'France' not in regions:
regions.append('France')
elif code in ['DE', 'GER', 'DEU']:
if 'Germany' not in regions:
regions.append('Germany')
elif code in ['EN', 'ENG'] or code.startswith('EN-'):
# EN peut être USA, Europe ou autre - on vérifie le contexte
if 'EU' in codes or 'EUR' in codes:
if 'Europe' not in regions:
regions.append('Europe')
elif code in ['ES', 'ESP', 'SPA']:
if 'Other' not in regions:
regions.append('Other')
elif code in ['IT', 'ITA']:
if 'Other' not in regions:
regions.append('Other')
elif code in ['NL', 'NLD', 'DU', 'DUT']:
if 'Europe' not in regions:
regions.append('Europe')
elif code in ['PT', 'POR']:
if 'Other' not in regions:
regions.append('Other')
# Patterns de région complets (mots entiers)
if 'USA' in name or 'US)' in name or re.search(r'\bUS\b', name):
if 'USA' not in regions:
regions.append('USA')
if 'CANADA' in name or 'CA)' in name:
regions.append('Canada')
if 'EUROPE' in name or 'EU)' in name:
regions.append('Europe')
if 'Canada' not in regions:
regions.append('Canada')
if 'EUROPE' in name or 'EU)' in name or re.search(r'\bEU\b', name):
if 'Europe' not in regions:
regions.append('Europe')
if 'FRANCE' in name or 'FR)' in name:
regions.append('France')
if 'France' not in regions:
regions.append('France')
if 'GERMANY' in name or 'DE)' in name or 'GER)' in name:
regions.append('Germany')
if 'JAPAN' in name or 'JP)' in name or 'JPN)' in name:
regions.append('Japan')
if 'Germany' not in regions:
regions.append('Germany')
if 'JAPAN' in name or 'JP)' in name or 'JPN)' in name or re.search(r'\bJP\b', name):
if 'Japan' not in regions:
regions.append('Japan')
if 'KOREA' in name or 'KR)' in name or 'KOR)' in name:
regions.append('Korea')
if 'Korea' not in regions:
regions.append('Korea')
if 'WORLD' in name:
regions.append('World')
if 'World' not in regions:
regions.append('World')
# Autres régions
if re.search(r'\b(AUSTRALIA|ASIA|KOREA|BRAZIL|CHINA|RUSSIA|SCANDINAVIA|'
r'SPAIN|FRANCE|GERMANY|ITALY|CANADA)\b', name):
if 'CANADA' in name:
regions.append('Canada')
else:
if re.search(r'\b(AUSTRALIA|ASIA|BRAZIL|CHINA|RUSSIA|SCANDINAVIA|'
r'SPAIN|ITALY)\b', name):
if 'Other' not in regions:
regions.append('Other')
# Si aucune région trouvée
@@ -157,14 +194,22 @@ class GameFilters:
def get_region_priority(self, game_name: str) -> int:
"""Obtient la priorité de région pour un jeu (pour one-rom-per-game)"""
name = game_name.upper()
# Utiliser la fonction de détection de régions pour être cohérent
game_regions = self.get_game_regions(game_name)
for i, region in enumerate(self.region_priority):
region_upper = region.upper()
if region_upper in name:
return i
# Trouver la meilleure priorité parmi toutes les régions détectées
best_priority = len(self.region_priority) # Par défaut: priorité la plus basse
return len(self.region_priority) # Autres régions (priorité la plus basse)
for region in game_regions:
try:
priority = self.region_priority.index(region)
if priority < best_priority:
best_priority = priority
except ValueError:
# La région n'est pas dans la liste de priorité
continue
return best_priority
def apply_filters(self, games: List[Tuple]) -> List[Tuple]:
"""

View File

@@ -44,6 +44,7 @@
"free_mode_completed": "[Kostenloser Modus] Abgeschlossen: {0}",
"download_status": "{0}: {1}",
"download_canceled": "Download vom Benutzer abgebrochen.",
"download_removed_from_queue": "Aus der Download-Warteschlange entfernt",
"extension_warning_zip": "Die Datei '{0}' ist ein Archiv und Batocera unterstützt keine Archive für dieses System. Die automatische Extraktion der Datei erfolgt nach dem Download, fortfahren?",
"extension_warning_unsupported": "Die Dateierweiterung für '{0}' wird laut der Konfiguration es_systems.cfg von Batocera nicht unterstützt. Möchtest du fortfahren?",
"extension_warning_enable_unknown_hint": "\nUm diese Meldung auszublenden: \"Warnung bei unbekannter Erweiterung ausblenden\" in Pausenmenü > Anzeige aktivieren",
@@ -67,7 +68,7 @@
"menu_redownload_cache": "Spieleliste aktualisieren",
"menu_music_enabled": "Musik aktiviert: {0}",
"menu_music_disabled": "Musik deaktiviert",
"menu_restart": "Neustart",
"menu_restart": "RGSX neu starten",
"menu_support": "Unterstützung",
"menu_filter_platforms": "Systeme filtern",
"filter_platforms_title": "Systemsichtbarkeit",
@@ -80,6 +81,7 @@
"menu_allow_unknown_ext_enabled": "Ausblenden der Warnung bei unbekannter Erweiterung aktiviert",
"menu_allow_unknown_ext_disabled": "Ausblenden der Warnung bei unbekannter Erweiterung deaktiviert",
"menu_quit": "Beenden",
"menu_quit_app": "RGSX beenden",
"support_dialog_title": "Support-Datei",
"support_dialog_message": "Eine Support-Datei wurde mit allen Ihren Konfigurations- und Protokolldateien erstellt.\n\nDatei: {0}\n\nUm Hilfe zu erhalten:\n1. Treten Sie dem RGSX Discord-Server bei\n2. Beschreiben Sie Ihr Problem\n3. Teilen Sie diese ZIP-Datei\n\nDrücken Sie {1}, um zum Menü zurückzukehren.",
"support_dialog_error": "Fehler beim Erstellen der Support-Datei:\n{0}\n\nDrücken Sie {1}, um zum Menü zurückzukehren.",
@@ -184,7 +186,9 @@
"instruction_pause_settings": "Musik, Symlink-Option & API-Schlüsselstatus",
"instruction_pause_restart": "RGSX neu starten um Konfiguration neu zu laden",
"instruction_pause_support": "Eine Diagnose-ZIP-Datei für den Support erstellen",
"instruction_pause_quit": "RGSX Anwendung beenden",
"instruction_pause_quit": "Menü für Beenden oder Neustart aufrufen",
"instruction_quit_app": "RGSX Anwendung beenden",
"instruction_quit_restart": "RGSX Anwendung neu starten",
"instruction_controls_help": "Komplette Referenz für Controller & Tastatur anzeigen",
"instruction_controls_remap": "Tasten / Buttons neu zuordnen",
"instruction_generic_back": "Zum vorherigen Menü zurückkehren",
@@ -242,7 +246,10 @@
"history_game_options_title": "Spiel Optionen",
"history_option_download_folder": "Datei lokalisieren",
"history_option_extract_archive": "Archiv extrahieren",
"history_option_scraper": "Metadaten scrapen",
"history_option_open_file": "Datei öffnen",
"history_option_scraper": "Metadaten abrufen",
"history_option_remove_from_queue": "Aus Warteschlange entfernen",
"history_option_cancel_download": "Download abbrechen",
"history_option_delete_game": "Spiel löschen",
"history_option_error_info": "Fehlerdetails",
"history_option_retry": "Download wiederholen",
@@ -339,7 +346,7 @@
"web_restart_error": "Fehler beim Neustart: {0}",
"web_support": "Support",
"web_support_title": "📦 Support-Datei erstellt",
"web_support_message": "Support-Datei erfolgreich erstellt!\\n\\n📁 Inhalt:\\n• Steuerungskonfiguration\\n• Download-Verlauf\\n• RGSX-Einstellungen\\n• Anwendungsprotokolle\\n• Webserver-Protokolle\\n\\n💬 Um Hilfe zu erhalten:\\n1. Trete dem RGSX Discord bei\\n2. Beschreibe dein Problem\\n3. Teile diese ZIP-Datei\\n\\nDownload startet...",
"web_support_message": "Support-Datei erfolgreich erstellt!\n\n📁 Inhalt:\n• Steuerungskonfiguration\n• Download-Verlauf\n• RGSX-Einstellungen\n• Anwendungsprotokolle\n• Webserver-Protokolle\n\n💬 Um Hilfe zu erhalten:\n1. Trete dem RGSX Discord bei\n2. Beschreibe dein Problem\n3. Teile diese ZIP-Datei\n\nDownload startet...",
"web_support_generating": "Support-Datei wird generiert...",
"web_support_download": "Support-Datei herunterladen",
"web_support_error": "Fehler beim Erstellen der Support-Datei: {0}",

View File

@@ -44,6 +44,7 @@
"free_mode_completed": "[Free mode] Completed: {0}",
"download_status": "{0}: {1}",
"download_canceled": "Download canceled by user.",
"download_removed_from_queue": "Removed from download queue",
"extension_warning_zip": "The file '{0}' is an archive and Batocera does not support archives for this system. Automatic extraction will occur after download, continue?",
"extension_warning_unsupported": "The file extension for '{0}' is not supported by Batocera according to the es_systems.cfg configuration. Do you want to continue?",
"extension_warning_enable_unknown_hint": "\nTo hide this message: enable \"Hide unknown extension warning\" in Pause Menu > Display",
@@ -67,7 +68,7 @@
"menu_redownload_cache": "Update games list",
"menu_music_enabled": "Music enabled: {0}",
"menu_music_disabled": "Music disabled",
"menu_restart": "Restart",
"menu_restart": "Restart RGSX",
"menu_filter_platforms": "Filter systems",
"filter_platforms_title": "Systems visibility",
"filter_platforms_info": "Visible: {0} | Hidden: {1} / Total: {2}",
@@ -80,6 +81,7 @@
"menu_allow_unknown_ext_disabled": "Hide unknown extension warning disabled",
"menu_support": "Support",
"menu_quit": "Quit",
"menu_quit_app": "Quit RGSX",
"button_yes": "Yes",
"button_no": "No",
"button_OK": "OK",
@@ -186,7 +188,9 @@
"instruction_pause_settings": "Music, symlink option & API keys status",
"instruction_pause_restart": "Restart RGSX to reload configuration",
"instruction_pause_support": "Generate a diagnostic ZIP file for support",
"instruction_pause_quit": "Exit the RGSX application",
"instruction_pause_quit": "Access menu to quit or restart",
"instruction_quit_app": "Exit the RGSX application",
"instruction_quit_restart": "Restart the RGSX application",
"instruction_controls_help": "Show full controller & keyboard reference",
"instruction_controls_remap": "Change button / key bindings",
"instruction_generic_back": "Return to the previous menu",
@@ -244,7 +248,10 @@
"history_game_options_title": "Game Options",
"history_option_download_folder": "Locate file",
"history_option_extract_archive": "Extract archive",
"history_option_open_file": "Open file",
"history_option_scraper": "Scrape metadata",
"history_option_remove_from_queue": "Remove from queue",
"history_option_cancel_download": "Cancel download",
"history_option_delete_game": "Delete game",
"history_option_error_info": "Error details",
"history_option_retry": "Retry download",
@@ -341,7 +348,7 @@
"web_restart_error": "Restart error: {0}",
"web_support": "Support",
"web_support_title": "📦 Support File Generated",
"web_support_message": "Support file created successfully!\\n\\n📁 Contents:\\n• Controls configuration\\n• Download history\\n• RGSX settings\\n• Application logs\\n• Web server logs\\n\\n💬 To get help:\\n1. Join RGSX Discord\\n2. Describe your issue\\n3. Share this ZIP file\\n\\nDownload will start...",
"web_support_message": "Support file created successfully!\n\n📁 Contents:\n• Controls configuration\n• Download history\n• RGSX settings\n• Application logs\n• Web server logs\n\n💬 To get help:\n1. Join RGSX Discord\n2. Describe your issue\n3. Share this ZIP file\n\nDownload will start...",
"web_support_generating": "Generating support file...",
"web_support_download": "Download support file",
"web_support_error": "Error generating support file: {0}",

View File

@@ -44,6 +44,7 @@
"free_mode_completed": "[Modo gratuito] Completado: {0}",
"download_status": "{0}: {1}",
"download_canceled": "Descarga cancelada por el usuario.",
"download_removed_from_queue": "Eliminado de la cola de descarga",
"extension_warning_zip": "El archivo '{0}' es un archivo comprimido y Batocera no soporta archivos comprimidos para este sistema. La extracción automática del archivo se realizará después de la descarga, ¿continuar?",
"extension_warning_unsupported": "La extensión del archivo '{0}' no está soportada por Batocera según la configuración es_systems.cfg. ¿Deseas continuar?",
"extension_warning_enable_unknown_hint": "\nPara no mostrar este mensaje: activa \"Ocultar aviso de extensión desconocida\" en Menú de pausa > Pantalla",
@@ -67,7 +68,7 @@
"menu_redownload_cache": "Actualizar lista de juegos",
"menu_music_enabled": "Música activada: {0}",
"menu_music_disabled": "Música desactivada",
"menu_restart": "Reiniciar",
"menu_restart": "Reiniciar RGSX",
"menu_support": "Soporte",
"menu_filter_platforms": "Filtrar sistemas",
"filter_platforms_title": "Visibilidad de sistemas",
@@ -80,6 +81,7 @@
"menu_allow_unknown_ext_enabled": "Aviso de extensión desconocida oculto (activado)",
"menu_allow_unknown_ext_disabled": "Aviso de extensión desconocida visible (desactivado)",
"menu_quit": "Salir",
"menu_quit_app": "Salir de RGSX",
"support_dialog_title": "Archivo de soporte",
"support_dialog_message": "Se ha creado un archivo de soporte con todos sus archivos de configuración y registros.\n\nArchivo: {0}\n\nPara obtener ayuda:\n1. Únete al servidor Discord de RGSX\n2. Describe tu problema\n3. Comparte este archivo ZIP\n\nPresiona {1} para volver al menú.",
"support_dialog_error": "Error al generar el archivo de soporte:\n{0}\n\nPresiona {1} para volver al menú.",
@@ -186,7 +188,9 @@
"instruction_pause_settings": "Música, opción symlink y estado de claves API",
"instruction_pause_restart": "Reiniciar RGSX para recargar configuración",
"instruction_pause_support": "Generar un archivo ZIP de diagnóstico para soporte",
"instruction_pause_quit": "Salir de la aplicación RGSX",
"instruction_pause_quit": "Acceder al menú para salir o reiniciar",
"instruction_quit_app": "Salir de la aplicación RGSX",
"instruction_quit_restart": "Reiniciar la aplicación RGSX",
"instruction_controls_help": "Mostrar referencia completa de mando y teclado",
"instruction_controls_remap": "Cambiar asignación de botones / teclas",
"instruction_generic_back": "Volver al menú anterior",
@@ -244,7 +248,10 @@
"history_game_options_title": "Opciones del juego",
"history_option_download_folder": "Localizar archivo",
"history_option_extract_archive": "Extraer archivo",
"history_option_scraper": "Scraper metadatos",
"history_option_open_file": "Abrir archivo",
"history_option_scraper": "Obtener metadatos",
"history_option_remove_from_queue": "Quitar de la cola",
"history_option_cancel_download": "Cancelar descarga",
"history_option_delete_game": "Eliminar juego",
"history_option_error_info": "Detalles del error",
"history_option_retry": "Reintentar descarga",
@@ -341,7 +348,7 @@
"web_restart_error": "Error al reiniciar: {0}",
"web_support": "Soporte",
"web_support_title": "📦 Archivo de soporte generado",
"web_support_message": "¡Archivo de soporte creado con éxito!\\n\\n📁 Contenido:\\n• Configuración de controles\\n• Historial de descargas\\n• Configuración RGSX\\n• Registros de la aplicación\\n• Registros del servidor web\\n\\n💬 Para obtener ayuda:\\n1. Únete al Discord de RGSX\\n2. Describe tu problema\\n3. Comparte este archivo ZIP\\n\\nLa descarga comenzará...",
"web_support_message": "¡Archivo de soporte creado con éxito!\n\n📁 Contenido:\n• Configuración de controles\n• Historial de descargas\n• Configuración RGSX\n• Registros de la aplicación\n• Registros del servidor web\n\n💬 Para obtener ayuda:\n1. Únete al Discord de RGSX\n2. Describe tu problema\n3. Comparte este archivo ZIP\n\nLa descarga comenzará...",
"web_support_generating": "Generando archivo de soporte...",
"web_support_download": "Descargar archivo de soporte",
"web_support_error": "Error al generar el archivo de soporte: {0}",

View File

@@ -44,6 +44,7 @@
"free_mode_completed": "[Mode gratuit] Terminé: {0}",
"download_status": "{0} : {1}",
"download_canceled": "Téléchargement annulé par l'utilisateur.",
"download_removed_from_queue": "Retiré de la file de téléchargement",
"extension_warning_zip": "Le fichier '{0}' est une archive et Batocera ne prend pas en charge les archives pour ce système. L'extraction automatique du fichier aura lieu après le téléchargement, continuer ?",
"extension_warning_unsupported": "L'extension du fichier '{0}' n'est pas supportée par Batocera d'après la configuration es_systems.cfg. Voulez-vous continuer ?",
"extension_warning_enable_unknown_hint": "\nPour ne plus afficher ce messager : Activer l'option \"Masquer avertissement\" dans le Menu Pause>Display",
@@ -67,9 +68,10 @@
"menu_redownload_cache": "Mettre à jour la liste des jeux",
"menu_support": "Support",
"menu_quit": "Quitter",
"menu_quit_app": "Quitter RGSX",
"menu_music_enabled": "Musique activée : {0}",
"menu_music_disabled": "Musique désactivée",
"menu_restart": "Redémarrer",
"menu_restart": "Redémarrer RGSX",
"menu_filter_platforms": "Filtrer les systèmes",
"filter_platforms_title": "Affichage des systèmes",
"filter_platforms_info": "Visibles: {0} | Masqués: {1} / Total: {2}",
@@ -186,7 +188,9 @@
"instruction_pause_settings": "Musique, option symlink & statut des clés API",
"instruction_pause_restart": "Redémarrer RGSX pour recharger la configuration",
"instruction_pause_support": "Générer un fichier ZIP de diagnostic pour l'assistance",
"instruction_pause_quit": "Quitter l'application RGSX",
"instruction_pause_quit": "Accéder au menu pour quitter ou redémarrer",
"instruction_quit_app": "Quitter l'application RGSX",
"instruction_quit_restart": "Redémarrer l'application RGSX",
"instruction_controls_help": "Afficher la référence complète manette & clavier",
"instruction_controls_remap": "Modifier l'association boutons / touches",
"instruction_generic_back": "Revenir au menu précédent",
@@ -244,10 +248,11 @@
"history_game_options_title": "Options du jeu",
"history_option_download_folder": "Localiser le fichier",
"history_option_extract_archive": "Extraire l'archive",
"history_option_scraper": "Scraper métadonnées",
"history_option_open_file": "Ouvrir le fichier",
"history_option_scraper": "Récupérer métadonnées",
"history_option_delete_game": "Supprimer le jeu",
"history_option_error_info": "Détails de l'erreur",
"history_option_retry": "Réessayer le téléchargement",
"history_option_retry": "Retenter le téléchargement",
"history_option_back": "Retour",
"history_folder_path_label": "Chemin de destination :",
"history_scraper_not_implemented": "Scraper pas encore implémenté",
@@ -341,7 +346,7 @@
"web_restart_error": "Erreur lors du redémarrage : {0}",
"web_support": "Support",
"web_support_title": "📦 Fichier de support généré",
"web_support_message": "Le fichier de support a été créé avec succès !\\n\\n📁 Contenu :\\n• Configuration des contrôles\\n• Historique des téléchargements\\n• Paramètres RGSX\\n• Logs de l'application\\n• Logs du serveur web\\n\\n💬 Pour obtenir de l'aide :\\n1. Rejoignez le Discord RGSX\\n2. Décrivez votre problème\\n3. Partagez ce fichier ZIP\\n\\nLe téléchargement va démarrer...",
"web_support_message": "Le fichier de support a été créé avec succès !\n\n📁 Contenu :\n• Configuration des contrôles\n• Historique des téléchargements\n• Paramètres RGSX\n• Logs de l'application\n• Logs du serveur web\n\n💬 Pour obtenir de l'aide :\n1. Rejoignez le Discord RGSX\n2. Décrivez votre problème\n3. Partagez ce fichier ZIP\n\nLe téléchargement va démarrer...",
"web_support_generating": "Génération du fichier de support...",
"web_support_download": "Télécharger le fichier de support",
"web_support_error": "Erreur lors de la génération du fichier de support : {0}",

View File

@@ -44,6 +44,7 @@
"free_mode_completed": "[Modalità gratuita] Completato: {0}",
"download_status": "{0}: {1}",
"download_canceled": "Download annullato dall'utente.",
"download_removed_from_queue": "Rimosso dalla coda di download",
"extension_warning_zip": "Il file '{0}' è un archivio e Batocera non supporta archivi per questo sistema. L'estrazione automatica avverrà dopo il download, continuare?",
"extension_warning_unsupported": "L'estensione del file '{0}' non è supportata da Batocera secondo la configurazione di es_systems.cfg. Vuoi continuare?",
"extension_warning_enable_unknown_hint": "\nPer non visualizzare questo messaggio: abilita \"Nascondi avviso estensione sconosciuta\" in Menu Pausa > Schermo",
@@ -67,7 +68,7 @@
"menu_redownload_cache": "Aggiorna elenco giochi",
"menu_music_enabled": "Musica attivata: {0}",
"menu_music_disabled": "Musica disattivata",
"menu_restart": "Riavvia",
"menu_restart": "Riavvia RGSX",
"menu_support": "Supporto",
"menu_filter_platforms": "Filtra sistemi",
"filter_platforms_title": "Visibilità sistemi",
@@ -80,6 +81,7 @@
"menu_allow_unknown_ext_enabled": "Nascondi avviso estensione sconosciuta abilitato",
"menu_allow_unknown_ext_disabled": "Nascondi avviso estensione sconosciuta disabilitato",
"menu_quit": "Esci",
"menu_quit_app": "Esci da RGSX",
"support_dialog_title": "File di supporto",
"support_dialog_message": "È stato creato un file di supporto con tutti i file di configurazione e di registro.\n\nFile: {0}\n\nPer ottenere aiuto:\n1. Unisciti al server Discord RGSX\n2. Descrivi il tuo problema\n3. Condividi questo file ZIP\n\nPremi {1} per tornare al menu.",
"support_dialog_error": "Errore durante la generazione del file di supporto:\n{0}\n\nPremi {1} per tornare al menu.",
@@ -183,7 +185,9 @@
"instruction_pause_settings": "Musica, opzione symlink e stato chiavi API",
"instruction_pause_restart": "Riavvia RGSX per ricaricare la configurazione",
"instruction_pause_support": "Genera un file ZIP diagnostico per il supporto",
"instruction_pause_quit": "Uscire dall'applicazione RGSX",
"instruction_pause_quit": "Accedere al menu per uscire o riavviare",
"instruction_quit_app": "Uscire dall'applicazione RGSX",
"instruction_quit_restart": "Riavviare l'applicazione RGSX",
"instruction_controls_help": "Mostrare riferimento completo controller & tastiera",
"instruction_controls_remap": "Modificare associazione pulsanti / tasti",
"instruction_generic_back": "Tornare al menu precedente",
@@ -241,6 +245,7 @@
"history_game_options_title": "Opzioni gioco",
"history_option_download_folder": "Localizza file",
"history_option_extract_archive": "Estrai archivio",
"history_option_open_file": "Apri file",
"history_option_scraper": "Scraper metadati",
"history_option_delete_game": "Elimina gioco",
"history_option_error_info": "Dettagli errore",
@@ -338,7 +343,7 @@
"web_restart_error": "Errore durante il riavvio: {0}",
"web_support": "Supporto",
"web_support_title": "📦 File di supporto generato",
"web_support_message": "File di supporto creato con successo!\\n\\n📁 Contenuto:\\n• Configurazione controlli\\n• Cronologia download\\n• Impostazioni RGSX\\n• Log dell'applicazione\\n• Log del server web\\n\\n💬 Per ottenere aiuto:\\n1. Unisciti al Discord RGSX\\n2. Descrivi il tuo problema\\n3. Condividi questo file ZIP\\n\\nIl download inizierà...",
"web_support_message": "File di supporto creato con successo!\n\n📁 Contenuto:\n• Configurazione controlli\n• Cronologia download\n• Impostazioni RGSX\n• Log dell'applicazione\n• Log del server web\n\n💬 Per ottenere aiuto:\n1. Unisciti al Discord RGSX\n2. Descrivi il tuo problema\n3. Condividi questo file ZIP\n\nIl download inizierà...",
"web_support_generating": "Generazione file di supporto...",
"web_support_download": "Scarica file di supporto",
"web_support_error": "Errore nella generazione del file di supporto: {0}",

View File

@@ -44,6 +44,7 @@
"free_mode_completed": "[Modo gratuito] Concluído: {0}",
"download_status": "{0}: {1}",
"download_canceled": "Download cancelado pelo usuário.",
"download_removed_from_queue": "Removido da fila de download",
"extension_warning_zip": "O arquivo '{0}' é um arquivo compactado e o Batocera não suporta arquivos compactados para este sistema. A extração automática ocorrerá após o download, continuar?",
"extension_warning_unsupported": "A extensão do arquivo '{0}' não é suportada pelo Batocera segundo a configuração es_systems.cfg. Deseja continuar?",
"extension_warning_enable_unknown_hint": "\nPara não ver esta mensagem: ative \"Ocultar aviso de extensão desconhecida\" em Menu de Pausa > Exibição",
@@ -67,7 +68,7 @@
"menu_redownload_cache": "Atualizar lista de jogos",
"menu_music_enabled": "Música ativada: {0}",
"menu_music_disabled": "Música desativada",
"menu_restart": "Reiniciar",
"menu_restart": "Reiniciar RGSX",
"menu_support": "Suporte",
"menu_filter_platforms": "Filtrar sistemas",
"filter_platforms_title": "Visibilidade dos sistemas",
@@ -80,6 +81,7 @@
"menu_allow_unknown_ext_enabled": "Aviso de extensão desconhecida oculto (ativado)",
"menu_allow_unknown_ext_disabled": "Aviso de extensão desconhecida visível (desativado)",
"menu_quit": "Sair",
"menu_quit_app": "Sair do RGSX",
"support_dialog_title": "Arquivo de suporte",
"support_dialog_message": "Foi criado um arquivo de suporte com todos os seus arquivos de configuração e logs.\n\nArquivo: {0}\n\nPara obter ajuda:\n1. Junte-se ao servidor Discord RGSX\n2. Descreva seu problema\n3. Compartilhe este arquivo ZIP\n\nPressione {1} para voltar ao menu.",
"support_dialog_error": "Erro ao gerar o arquivo de suporte:\n{0}\n\nPressione {1} para voltar ao menu.",
@@ -185,7 +187,9 @@
"instruction_pause_settings": "Música, opção symlink e status das chaves API",
"instruction_pause_restart": "Reiniciar RGSX para recarregar configuração",
"instruction_pause_support": "Gerar um arquivo ZIP de diagnóstico para suporte",
"instruction_pause_quit": "Sair da aplicação RGSX",
"instruction_pause_quit": "Acessar menu para sair ou reiniciar",
"instruction_quit_app": "Sair da aplicação RGSX",
"instruction_quit_restart": "Reiniciar a aplicação RGSX",
"instruction_controls_help": "Mostrar referência completa de controle e teclado",
"instruction_controls_remap": "Modificar associação de botões / teclas",
"instruction_generic_back": "Voltar ao menu anterior",
@@ -243,7 +247,10 @@
"history_game_options_title": "Opções do jogo",
"history_option_download_folder": "Localizar arquivo",
"history_option_extract_archive": "Extrair arquivo",
"history_option_scraper": "Scraper metadados",
"history_option_open_file": "Abrir arquivo",
"history_option_scraper": "Obter metadados",
"history_option_remove_from_queue": "Remover da fila",
"history_option_cancel_download": "Cancelar download",
"history_option_delete_game": "Excluir jogo",
"history_option_error_info": "Detalhes do erro",
"history_option_retry": "Tentar novamente",
@@ -340,7 +347,7 @@
"web_restart_error": "Erro ao reiniciar: {0}",
"web_support": "Suporte",
"web_support_title": "📦 Arquivo de suporte gerado",
"web_support_message": "Arquivo de suporte criado com sucesso!\\n\\n📁 Conteúdo:\\n• Configuração de controles\\n• Histórico de downloads\\n• Configurações RGSX\\n• Logs da aplicação\\n• Logs do servidor web\\n\\n💬 Para obter ajuda:\\n1. Entre no Discord RGSX\\n2. Descreva seu problema\\n3. Compartilhe este arquivo ZIP\\n\\nO download vai começar...",
"web_support_message": "Arquivo de suporte criado com sucesso!\n\n📁 Conteúdo:\n• Configuração de controles\n• Histórico de downloads\n• Configurações RGSX\n• Logs da aplicação\n• Logs do servidor web\n\n💬 Para obter ajuda:\n1. Entre no Discord RGSX\n2. Descreva seu problema\n3. Compartilhe este arquivo ZIP\n\nO download vai começar...",
"web_support_generating": "Gerando arquivo de suporte...",
"web_support_download": "Baixar arquivo de suporte",
"web_support_error": "Erro ao gerar arquivo de suporte: {0}",

View File

@@ -453,8 +453,102 @@ async def check_for_updates():
config.loading_progress = 5.0
config.needs_redraw = True
response = requests.get(OTA_VERSION_ENDPOINT, timeout=5)
response.raise_for_status()
# Liste des endpoints à essayer (GitHub principal, puis fallback)
endpoints = [
OTA_VERSION_ENDPOINT,
"https://retrogamesets.fr/softs/version.json"
]
response = None
last_error = None
for endpoint_index, endpoint in enumerate(endpoints):
is_fallback = endpoint_index > 0
if is_fallback:
logger.info(f"Tentative sur endpoint de secours : {endpoint}")
# Gestion des erreurs de rate limit GitHub (429) avec retry
max_retries = 3 if not is_fallback else 1 # Moins de retries sur fallback
retry_count = 0
while retry_count < max_retries:
try:
response = requests.get(endpoint, timeout=10)
# Gestion spécifique des erreurs 429 (Too Many Requests) - surtout pour GitHub
if response.status_code == 429:
retry_after = response.headers.get('retry-after')
x_ratelimit_remaining = response.headers.get('x-ratelimit-remaining', '1')
x_ratelimit_reset = response.headers.get('x-ratelimit-reset')
if retry_after:
# En-tête retry-after présent : attendre le nombre de secondes spécifié
wait_time = int(retry_after)
logger.warning(f"Rate limit atteint (429) sur {endpoint}. Attente de {wait_time}s (retry-after header)")
elif x_ratelimit_remaining == '0' and x_ratelimit_reset:
# x-ratelimit-remaining est 0 : attendre jusqu'à x-ratelimit-reset
import time
reset_time = int(x_ratelimit_reset)
current_time = int(time.time())
wait_time = max(reset_time - current_time, 60) # Minimum 60s
logger.warning(f"Rate limit atteint (429) sur {endpoint}. Attente de {wait_time}s (x-ratelimit-reset)")
else:
# Pas d'en-têtes spécifiques : attendre au moins 60s
wait_time = 60
logger.warning(f"Rate limit atteint (429) sur {endpoint}. Attente de {wait_time}s par défaut")
if retry_count < max_retries - 1:
logger.info(f"Nouvelle tentative dans {wait_time}s... ({retry_count + 1}/{max_retries})")
await asyncio.sleep(wait_time)
retry_count += 1
continue
else:
# Si rate limit persistant et qu'on est sur GitHub, essayer le fallback
if not is_fallback:
logger.warning(f"Rate limit GitHub persistant, passage au serveur de secours")
break # Sortir de la boucle retry pour essayer le prochain endpoint
raise requests.exceptions.HTTPError(
f"Limite de débit atteinte (429). Veuillez réessayer plus tard."
)
response.raise_for_status()
# Succès, sortir de toutes les boucles
logger.debug(f"Version récupérée avec succès depuis : {endpoint}")
break
except requests.exceptions.HTTPError as e:
last_error = e
if response and response.status_code == 429:
# 429 géré au-dessus, continuer la boucle ou passer au fallback
retry_count += 1
if retry_count >= max_retries:
break # Passer au prochain endpoint
else:
# Erreur HTTP autre que 429
logger.warning(f"Erreur HTTP {response.status_code if response else 'inconnue'} sur {endpoint}")
break # Passer au prochain endpoint
except requests.exceptions.RequestException as e:
last_error = e
if retry_count < max_retries - 1:
# Erreur réseau, réessayer avec backoff exponentiel
wait_time = 2 ** retry_count # 1s, 2s, 4s
logger.warning(f"Erreur réseau sur {endpoint}. Nouvelle tentative dans {wait_time}s...")
await asyncio.sleep(wait_time)
retry_count += 1
else:
logger.warning(f"Erreur réseau persistante sur {endpoint} : {e}")
break # Passer au prochain endpoint
# Si on a une réponse valide, sortir de la boucle des endpoints
if response and response.status_code == 200:
break
# Si aucun endpoint n'a fonctionné
if not response or response.status_code != 200:
raise last_error if last_error else requests.exceptions.RequestException(
"Impossible de vérifier les mises à jour sur tous les serveurs"
)
# Accepter différents content-types (application/json, text/plain, text/html)
content_type = response.headers.get("content-type", "")
@@ -831,6 +925,16 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
logger.info(f"Le fichier {dest_path} existe déjà et la taille est correcte, téléchargement ignoré")
result[0] = True
result[1] = _("network_download_ok").format(game_name) + _("download_already_present")
# Mettre à jour l'historique
for entry in config.history:
if entry.get("url") == url:
entry["status"] = "Download_OK"
entry["progress"] = 100
entry["message"] = result[1]
save_history(config.history)
break
# Afficher un toast au lieu d'ouvrir l'historique
try:
show_toast(result[1])
@@ -839,6 +943,13 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
with urls_lock:
urls_in_progress.discard(url)
logger.debug(f"URL supprimée du set des téléchargements en cours: {url} (URLs restantes: {len(urls_in_progress)})")
# Libérer le slot de la queue
try:
notify_download_finished()
except Exception:
pass
return result[0], result[1]
file_found = True
@@ -881,6 +992,16 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
logger.info(f"Un fichier avec le même nom de base existe déjà: {existing_path}, téléchargement ignoré")
result[0] = True
result[1] = _("network_download_ok").format(game_name) + _("download_already_extracted")
# Mettre à jour l'historique
for entry in config.history:
if entry.get("url") == url:
entry["status"] = "Download_OK"
entry["progress"] = 100
entry["message"] = result[1]
save_history(config.history)
break
# Afficher un toast au lieu d'ouvrir l'historique
try:
show_toast(result[1])
@@ -889,6 +1010,13 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
with urls_lock:
urls_in_progress.discard(url)
logger.debug(f"URL supprimée du set des téléchargements en cours: {url} (URLs restantes: {len(urls_in_progress)})")
# Libérer le slot de la queue
try:
notify_download_finished()
except Exception:
pass
return result[0], result[1]
except Exception as e:
logger.debug(f"Erreur lors de la vérification des fichiers existants: {e}")
@@ -1115,6 +1243,11 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
# Si annulé, ne pas continuer avec extraction
if download_canceled:
# Libérer le slot de la queue
try:
notify_download_finished()
except Exception:
pass
return
os.chmod(dest_path, 0o644)
@@ -1336,6 +1469,12 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
if url in url_done_events:
url_done_events[url].set()
# Libérer le slot de la queue
try:
notify_download_finished()
except Exception:
pass
return result[0], result[1]
async def download_from_1fichier(url, platform, game_name, is_zip_non_supported=False, task_id=None):

View File

@@ -29,7 +29,7 @@ def delete_old_files():
try:
if os.path.exists(file_path):
os.remove(file_path)
print(f"Ancien fichier supprimé : {file_path}")
print(f"Ancien fichier supprime : {file_path}")
logger.info(f"Ancien fichier supprimé : {file_path}")
except Exception as e:
print(f"Erreur lors de la suppression de {file_path} : {str(e)}")
@@ -39,7 +39,7 @@ def delete_old_files():
try:
if os.path.exists(file_path):
os.remove(file_path)
print(f"Ancien fichier supprimé : {file_path}")
print(f"Ancien fichier supprime : {file_path}")
logger.info(f"Ancien fichier supprimé : {file_path}")
except Exception as e:
print(f"Erreur lors de la suppression de {file_path} : {str(e)}")

View File

@@ -246,11 +246,11 @@ def get_translation(key, default=None):
return key
# Fonction pour normaliser les tailles de fichier
def normalize_size(size_str):
def normalize_size(size_str, lang='en'):
"""
Normalise une taille de fichier dans différents formats (Ko, KiB, Mo, MiB, Go, GiB)
en un format uniforme (Mo ou Go).
Exemples: "150 Mo" -> "150 Mo", "1.5 Go" -> "1.5 Go", "500 Ko" -> "0.5 Mo", "2 GiB" -> "2.15 Go"
en un format uniforme selon la langue (MB/GB pour anglais, Mo/Go pour français).
Exemples: "150 Mo" -> "150 MB" (en), "1.5 Go" -> "1.5 GB" (en), "500 Ko" -> "0.5 MB"
"""
if not size_str:
return None
@@ -282,16 +282,24 @@ def normalize_size(size_str):
elif unit in ['gio', 'gib']:
value = value * 1024 # GiB en Mo
# Afficher en Go si > 1024 Mo, sinon en Mo
if value >= 1024:
return f"{value / 1024:.2f} Go".rstrip('0').rstrip('.')
# Déterminer les unités selon la langue
if lang == 'fr':
mb_unit = 'Mo'
gb_unit = 'Go'
else:
# Arrondir à 1 décimale pour Mo
mb_unit = 'MB'
gb_unit = 'GB'
# Afficher en GB/Go si > 1024 Mo, sinon en MB/Mo
if value >= 1024:
return f"{value / 1024:.2f} {gb_unit}".replace('.00 ', ' ').rstrip('0').rstrip('.')
else:
# Arrondir à 1 décimale pour MB/Mo
rounded = round(value, 1)
if rounded == int(rounded):
return f"{int(rounded)} Mo"
return f"{int(rounded)} {mb_unit}"
else:
return f"{rounded} Mo".rstrip('0').rstrip('.')
return f"{rounded} {mb_unit}".rstrip('0').rstrip('.')
except (ValueError, TypeError):
return size_str # Retourner original si conversion échoue
@@ -356,7 +364,7 @@ try:
logger.info("Test d'écriture dans le fichier de log réussi")
except Exception as e:
logger.error(f"Erreur lors du test d'écriture : {e}")
print(f"ERREUR: Impossible d'écrire dans {config.log_file_web}: {e}", file=sys.stderr)
print(f"ERREUR: Impossible d'ecrire dans {config.log_file_web}: {e}", file=sys.stderr)
# Initialiser les données au démarrage
logger.info("Chargement initial des données...")
@@ -472,6 +480,20 @@ class RGSXHandler(BaseHTTPRequestHandler):
"""Répond avec un 404 générique."""
self._set_headers('text/plain; charset=utf-8', status=404)
self.wfile.write(b'Not found')
def _get_language_from_cookies(self):
"""Récupère la langue depuis les cookies ou retourne 'en' par défaut"""
cookie_header = self.headers.get('Cookie', '')
if cookie_header:
# Parser les cookies
cookies = {}
for cookie in cookie_header.split(';'):
cookie = cookie.strip()
if '=' in cookie:
key, value = cookie.split('=', 1)
cookies[key] = value
return cookies.get('language', 'en')
return 'en'
def _asset_version(self, relative_path: str) -> str:
"""Retourne un identifiant de version basé sur la date de modification du fichier statique."""
@@ -681,7 +703,7 @@ class RGSXHandler(BaseHTTPRequestHandler):
'game_name': game_name,
'platform': platform_name,
'url': game[1] if len(game) > 1 and isinstance(game, (list, tuple)) else None,
'size': normalize_size(game[2] if len(game) > 2 and isinstance(game, (list, tuple)) else None)
'size': normalize_size(game[2] if len(game) > 2 and isinstance(game, (list, tuple)) else None, self._get_language_from_cookies())
})
except Exception as e:
logger.debug(f"Erreur lors de la recherche dans {platform_name}: {e}")
@@ -722,12 +744,15 @@ class RGSXHandler(BaseHTTPRequestHandler):
platform_name = path.split('/api/games/')[-1]
platform_name = urllib.parse.unquote(platform_name)
# Récupérer la langue depuis les cookies ou utiliser 'en' par défaut
lang = self._get_language_from_cookies()
games, _, games_last_modified = get_cached_games(platform_name)
games_formatted = [
{
'name': g[0],
'url': g[1] if len(g) > 1 else None,
'size': normalize_size(g[2] if len(g) > 2 else None)
'size': normalize_size(g[2] if len(g) > 2 else None, lang)
}
for g in games
]
@@ -747,7 +772,7 @@ class RGSXHandler(BaseHTTPRequestHandler):
# Lire depuis history.json - filtrer seulement les téléchargements en cours
history = load_history() or []
print(f"\n[DEBUG PROGRESS] history.json chargé avec {len(history)} entrées totales")
print(f"\n[DEBUG PROGRESS] history.json charge avec {len(history)} entrees totales")
# Filtrer les entrées avec status "Downloading", "Téléchargement", "Connecting", "Try X/Y"
in_progress_statuses = ["Downloading", "Téléchargement", "Downloading", "Connecting", "Extracting"]
@@ -772,9 +797,9 @@ class RGSXHandler(BaseHTTPRequestHandler):
else:
# Debug: afficher les premiers status qui ne matchent pas
if len(downloads) < 3:
print(f" [DEBUG] Ignoré - Status: '{status}', Game: {entry.get('game_name', '')[:50]}")
print(f" [DEBUG] Ignore - Status: '{status}', Game: {entry.get('game_name', '')[:50]}")
print(f"[DEBUG PROGRESS] {len(downloads)} téléchargements en cours trouvés")
print(f"[DEBUG PROGRESS] {len(downloads)} telechargements en cours trouves")
if downloads:
for url, data in list(downloads.items())[:2]:
print(f" - URL: {url[:80]}...")
@@ -2063,7 +2088,7 @@ def run_server(host='0.0.0.0', port=5000):
if __name__ == '__main__':
print("="*60, flush=True)
print("Demarrage du serveur RGSX Web...", flush=True)
print(f"Fichier de log prévu: {config.log_file_web}", flush=True)
print(f"Fichier de log prevu: {config.log_file_web}", flush=True)
print("="*60, flush=True)
parser = argparse.ArgumentParser(description='RGSX Web Server')

View File

@@ -473,3 +473,70 @@ header p { opacity: 0.9; font-size: 1.1em; }
padding: 3px 10px;
}
}
/* Modal Support */
.support-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 10000;
animation: fadeIn 0.2s ease-out;
}
.support-modal-content {
background: #2c2c2c;
color: #ffffff;
padding: 30px;
border-radius: 12px;
max-width: 600px;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
position: relative;
}
.support-modal h2 {
margin: 0 0 20px 0;
color: #4CAF50;
font-size: 24px;
}
.support-modal-message {
white-space: pre-wrap;
line-height: 1.6;
margin-bottom: 25px;
color: #e0e0e0;
}
.support-modal button {
background: #4CAF50;
color: white;
border: none;
padding: 12px 30px;
border-radius: 6px;
cursor: pointer;
font-size: 16px;
font-weight: bold;
width: 100%;
transition: background 0.2s;
}
.support-modal button:hover {
background: #45a049;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; }
}

View File

@@ -109,6 +109,53 @@
document.head.appendChild(style);
}
// Modal pour afficher les messages support avec formatage
function showSupportModal(title, message) {
// Remplacer les \n littéraux par de vrais retours à la ligne
message = message.replace(/\\n/g, '\n');
// Créer la modal
const modal = document.createElement('div');
modal.className = 'support-modal';
const modalContent = document.createElement('div');
modalContent.className = 'support-modal-content';
// Titre
const titleElement = document.createElement('h2');
titleElement.textContent = title;
// Message avec retours à la ligne préservés
const messageElement = document.createElement('div');
messageElement.className = 'support-modal-message';
messageElement.textContent = message;
// Bouton OK
const okButton = document.createElement('button');
okButton.textContent = 'OK';
okButton.onclick = () => {
modal.style.animation = 'fadeOut 0.2s ease-in';
setTimeout(() => modal.remove(), 200);
};
// Assembler la modal
modalContent.appendChild(titleElement);
modalContent.appendChild(messageElement);
modalContent.appendChild(okButton);
modal.appendChild(modalContent);
// Ajouter au DOM
document.body.appendChild(modal);
// Fermer en cliquant sur le fond
modal.onclick = (e) => {
if (e.target === modal) {
modal.style.animation = 'fadeOut 0.2s ease-in';
setTimeout(() => modal.remove(), 200);
}
};
}
// Charger les traductions au démarrage
async function loadTranslations() {
try {
@@ -1036,13 +1083,24 @@
const getSizeInMo = (sizeElem) => {
if (!sizeElem) return 0;
const text = sizeElem.textContent;
// Les tailles sont maintenant normalisées: "100 Mo" ou "2.5 Go"
const match = text.match(/([0-9.]+)\\s*(Mo|Go)/i);
// Support des formats: "100 Mo", "2.5 Go" (français) et "100 MB", "2.5 GB" (anglais)
// Plus Ko/KB, o/B, To/TB
const match = text.match(/([0-9.]+)\s*(o|B|Ko|KB|Mo|MB|Go|GB|To|TB)/i);
if (!match) return 0;
let size = parseFloat(match[1]);
// Convertir Go en Mo pour comparaison
if (match[2].toUpperCase() === 'GO') {
size *= 1024;
const unit = match[2].toUpperCase();
// Convertir tout en Mo
if (unit === 'O' || unit === 'B') {
size /= (1024 * 1024); // octets/bytes vers Mo
} else if (unit === 'KO' || unit === 'KB') {
size /= 1024; // Ko vers Mo
} else if (unit === 'MO' || unit === 'MB') {
// Déjà en Mo
} else if (unit === 'GO' || unit === 'GB') {
size *= 1024; // Go vers Mo
} else if (unit === 'TO' || unit === 'TB') {
size *= 1024 * 1024; // To vers Mo
}
return size;
};
@@ -2075,7 +2133,7 @@
hide_non_release: document.getElementById('hide-non-release')?.checked || savedHideNonRelease,
one_rom_per_game: document.getElementById('one-rom-per-game')?.checked || savedOneRomPerGame,
regex_mode: document.getElementById('regex-mode')?.checked || savedRegexMode,
region_priority: regionPriority
region_priority: regionPriorityOrder
}
};
@@ -2175,7 +2233,7 @@
}
// Générer un fichier ZIP de support
async function generateSupportZip() {
async function generateSupportZip(event) {
try {
// Afficher un message de chargement
const loadingMsg = t('web_support_generating');
@@ -2218,8 +2276,8 @@
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
// Afficher le message d'instructions
alert(t('web_support_title') + '\\n\\n' + t('web_support_message'));
// Afficher le message d'instructions dans une modal
showSupportModal(t('web_support_title'), t('web_support_message'));
// Restaurer le bouton
if (originalButton) {

View File

@@ -1294,6 +1294,18 @@ def _handle_special_platforms(dest_dir, archive_path, before_dirs, iso_before=No
if not success:
return False, error_msg
# PSVita: extraction dans ux0/app + création fichier .psvita
psvita_dir_normal = os.path.join(config.ROMS_FOLDER, "psvita")
psvita_dir_symlink = os.path.join(config.ROMS_FOLDER, "psvita", "psvita")
is_psvita = (dest_dir == psvita_dir_normal or dest_dir == psvita_dir_symlink)
if is_psvita:
expected_base = os.path.splitext(os.path.basename(archive_path))[0]
items_before = before_items if before_items is not None else before_dirs
success, error_msg = handle_psvita(dest_dir, items_before, extracted_basename=expected_base)
if not success:
return False, error_msg
return True, None
def extract_zip(zip_path, dest_dir, url):
@@ -1959,6 +1971,136 @@ def handle_scummvm(dest_dir, before_items, extracted_basename=None):
return False, error_msg
def handle_psvita(dest_dir, before_items, extracted_basename=None):
"""Gère l'organisation spécifique des jeux PSVita extraits.
Structure attendue:
- Archive RAR extraite → Dossier "Nom du jeu"/
- Dans ce dossier → Fichier "IDJeu.zip" (ex: PCSE00890.zip)
- Ce ZIP contient → Dossier "IDJeu" (ex: PCSE00890/)
Actions:
1. Créer fichier "Nom du jeu [IDJeu].psvita" dans dest_dir
2. Extraire IDJeu.zip dans config.SAVE_FOLDER/psvita/ux0/app/
3. Supprimer le dossier temporaire "Nom du jeu"/
Args:
dest_dir: Dossier de destination (psvita ou psvita/psvita)
before_items: Set des éléments présents avant extraction
extracted_basename: Nom de base de l'archive extraite (sans extension)
"""
logger.debug(f"Traitement spécifique PSVita dans: {dest_dir}")
time.sleep(2) # Petite latence post-extraction
try:
after_items = set(os.listdir(dest_dir))
except Exception:
after_items = set()
ignore_names = {"psvita", "images", "videos", "manuals", "media"}
# Filtrer les nouveaux éléments (fichiers ou dossiers)
new_items = [item for item in (after_items - before_items)
if item not in ignore_names and not item.endswith('.psvita')]
if not new_items:
logger.warning("PSVita: Aucun nouveau dossier détecté après extraction")
return True, None
if not extracted_basename:
extracted_basename = new_items[0] if new_items else "game"
# Chercher le dossier du jeu (normalement il n'y en a qu'un)
game_folder = None
for item in new_items:
item_path = os.path.join(dest_dir, item)
if os.path.isdir(item_path):
game_folder = item
game_folder_path = item_path
break
if not game_folder:
logger.error("PSVita: Aucun dossier de jeu trouvé après extraction")
return False, "PSVita: Aucun dossier de jeu trouvé"
logger.debug(f"PSVita: Dossier de jeu trouvé: {game_folder}")
# Chercher le fichier ZIP à l'intérieur (IDJeu.zip)
try:
contents = os.listdir(game_folder_path)
zip_files = [f for f in contents if f.lower().endswith('.zip')]
if not zip_files:
logger.error(f"PSVita: Aucun fichier ZIP trouvé dans {game_folder}")
return False, f"PSVita: Aucun ZIP trouvé dans {game_folder}"
# Prendre le premier ZIP trouvé
zip_filename = zip_files[0]
zip_path = os.path.join(game_folder_path, zip_filename)
# Extraire l'ID du jeu (nom du ZIP sans extension)
game_id = os.path.splitext(zip_filename)[0]
logger.debug(f"PSVita: ZIP trouvé: {zip_filename}, ID du jeu: {game_id}")
# 1. Créer le fichier .psvita dans dest_dir
psvita_filename = f"{game_folder} [{game_id}].psvita"
psvita_file_path = os.path.join(dest_dir, psvita_filename)
try:
# Créer un fichier vide .psvita
with open(psvita_file_path, 'w', encoding='utf-8') as f:
f.write(f"# PSVita Game\n")
f.write(f"# Game: {game_folder}\n")
f.write(f"# ID: {game_id}\n")
logger.info(f"PSVita: Fichier .psvita créé: {psvita_filename}")
except Exception as e:
logger.error(f"PSVita: Erreur création fichier .psvita: {e}")
return False, f"Erreur création {psvita_filename}: {e}"
# 2. Extraire le ZIP dans le dossier parent de config.SAVE_FOLDER/psvita/ux0/app/
save_parent2 = os.path.dirname(config.SAVE_FOLDER)
save_parent = os.path.dirname(save_parent2)
ux0_app_dir = os.path.join(save_parent, "psvita", "ux0", "app")
os.makedirs(ux0_app_dir, exist_ok=True)
logger.debug(f"PSVita: Extraction de {zip_filename} dans {ux0_app_dir}")
try:
import zipfile
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(ux0_app_dir)
logger.info(f"PSVita: ZIP extrait avec succès dans {ux0_app_dir}")
# Vérifier que le dossier game_id existe bien
game_id_path = os.path.join(ux0_app_dir, game_id)
if not os.path.exists(game_id_path):
logger.warning(f"PSVita: Le dossier {game_id} n'a pas été trouvé dans l'extraction")
else:
logger.info(f"PSVita: Dossier {game_id} confirmé dans ux0/app/")
except zipfile.BadZipFile as e:
logger.error(f"PSVita: Fichier ZIP corrompu: {e}")
return False, f"ZIP corrompu: {zip_filename}"
except Exception as e:
logger.error(f"PSVita: Erreur extraction ZIP: {e}")
return False, f"Erreur extraction {zip_filename}: {e}"
# 3. Supprimer le dossier temporaire du jeu
try:
import shutil
shutil.rmtree(game_folder_path)
logger.info(f"PSVita: Dossier temporaire supprimé: {game_folder}")
except Exception as e:
logger.warning(f"PSVita: Impossible de supprimer {game_folder}: {e}")
# Ne pas échouer pour ça, le jeu est quand même installé
logger.info(f"PSVita: Traitement terminé avec succès - {psvita_filename} créé, {game_id} installé dans ux0/app/")
return True, None
except Exception as e:
logger.error(f"PSVita: Erreur générale: {e}", exc_info=True)
return False, f"Erreur PSVita: {str(e)}"
def handle_xbox(dest_dir, iso_files, url=None):
"""Gère la conversion des fichiers Xbox extraits et met à jour l'UI (Converting)."""
logger.debug(f"Traitement spécifique Xbox dans: {dest_dir}")

View File

@@ -1,3 +1,3 @@
{
"version": "2.3.2.7"
"version": "2.3.3.3"
}