forked from Mirrors/RGSX
v1.9.7.7 - Corrrection de bugs de téléchargements, bug detection clé 1fichier, ajout options d'accessibilité pour agrandir/reduire la taille des polices
This commit is contained in:
64
controls.py
64
controls.py
@@ -9,7 +9,7 @@ import json
|
||||
import os
|
||||
from display import draw_validation_transition
|
||||
from network import download_rom, download_from_1fichier, is_1fichier_url
|
||||
from utils import load_games, check_extension_before_download, is_extension_supported, load_extensions_json, sanitize_filename
|
||||
from utils import load_games, check_extension_before_download, is_extension_supported, load_extensions_json, sanitize_filename, load_api_key_1fichier
|
||||
from history import load_history, clear_history, add_to_history, save_history
|
||||
import logging
|
||||
from language import _ # Import de la fonction de traduction
|
||||
@@ -504,6 +504,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.current_history_item = len(config.history) - 1
|
||||
# Vérifier d'abord si c'est un lien 1fichier
|
||||
if is_1fichier_url(url):
|
||||
config.API_KEY_1FICHIER = load_api_key_1fichier()
|
||||
if not config.API_KEY_1FICHIER:
|
||||
config.previous_menu_state = config.menu_state
|
||||
config.menu_state = "error"
|
||||
@@ -739,13 +740,50 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.needs_redraw = True
|
||||
logger.error(f"config.pending_download est None pour {game_name}")
|
||||
break
|
||||
elif is_input_matched(event, "cancel"):
|
||||
elif is_input_matched(event, "cancel") or is_input_matched(event, "history"):
|
||||
if config.history and config.current_history_item < len(config.history):
|
||||
entry = config.history[config.current_history_item]
|
||||
if entry.get("status") in ["downloading", "Téléchargement", "Extracting"] and is_input_matched(event, "cancel"):
|
||||
config.menu_state = "confirm_cancel_download"
|
||||
config.confirm_cancel_selection = 0
|
||||
config.needs_redraw = True
|
||||
logger.debug("Demande d'annulation de téléchargement")
|
||||
return action
|
||||
config.menu_state = validate_menu_state(config.previous_menu_state)
|
||||
config.current_history_item = 0
|
||||
config.history_scroll_offset = 0
|
||||
config.needs_redraw = True
|
||||
logger.debug(f"Retour à {config.menu_state} depuis history")
|
||||
|
||||
# Confirmation annulation téléchargement
|
||||
elif config.menu_state == "confirm_cancel_download":
|
||||
if is_input_matched(event, "confirm"):
|
||||
if config.confirm_cancel_selection == 1: # Oui
|
||||
entry = config.history[config.current_history_item]
|
||||
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:
|
||||
task.cancel()
|
||||
del config.download_tasks[task_id]
|
||||
entry["status"] = "Canceled"
|
||||
entry["progress"] = 0
|
||||
entry["message"] = "Téléchargement annulé"
|
||||
save_history(config.history)
|
||||
logger.debug(f"Téléchargement annulé: {game_name}")
|
||||
break
|
||||
config.menu_state = "history"
|
||||
config.needs_redraw = True
|
||||
else: # Non
|
||||
config.menu_state = "history"
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "left") or is_input_matched(event, "right"):
|
||||
config.confirm_cancel_selection = 1 - config.confirm_cancel_selection
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "cancel"):
|
||||
config.menu_state = "history"
|
||||
config.needs_redraw = True
|
||||
|
||||
# Confirmation vider l'historique"
|
||||
elif config.menu_state == "confirm_clear_history":
|
||||
logger.debug(f"État confirm_clear_history, confirm_clear_selection={config.confirm_clear_selection}, événement={event.type}, valeur={getattr(event, 'value', None)}")
|
||||
@@ -866,26 +904,10 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.needs_redraw = True
|
||||
logger.debug(f"Passage à language_select depuis pause_menu")
|
||||
elif config.selected_option == 4: # Accessibility
|
||||
config.accessibility_mode = not config.accessibility_mode
|
||||
config.init_font()
|
||||
# Reinitialiser les polices dans le main
|
||||
font_path = os.path.join(config.APP_FOLDER, "assets", "Pixel-UniCode.ttf")
|
||||
multiplier = 1.5 if config.accessibility_mode else 1.0
|
||||
try:
|
||||
config.font = pygame.font.Font(font_path, int(36 * multiplier))
|
||||
config.title_font = pygame.font.Font(font_path, int(48 * multiplier))
|
||||
config.search_font = pygame.font.Font(font_path, int(48 * multiplier))
|
||||
config.progress_font = pygame.font.Font(font_path, int(36 * multiplier))
|
||||
config.small_font = pygame.font.Font(font_path, int(28 * multiplier))
|
||||
except:
|
||||
config.font = pygame.font.SysFont("arial", int(48 * multiplier))
|
||||
config.title_font = pygame.font.SysFont("arial", int(60 * multiplier))
|
||||
config.search_font = pygame.font.SysFont("arial", int(60 * multiplier))
|
||||
config.progress_font = pygame.font.SysFont("arial", int(36 * multiplier))
|
||||
config.small_font = pygame.font.SysFont("arial", int(28 * multiplier))
|
||||
config.menu_state = config.previous_menu_state
|
||||
config.previous_menu_state = validate_menu_state(config.previous_menu_state)
|
||||
config.menu_state = "accessibility_menu"
|
||||
config.needs_redraw = True
|
||||
logger.debug(f"Mode accessibilité {'activé' if config.accessibility_mode else 'désactivé'}")
|
||||
logger.debug("Passage au menu accessibilité")
|
||||
elif config.selected_option == 5: # Redownload game cache
|
||||
config.previous_menu_state = validate_menu_state(config.previous_menu_state)
|
||||
config.menu_state = "redownload_game_cache"
|
||||
|
||||
Reference in New Issue
Block a user