mirror of
https://github.com/RetroGameSets/RGSX.git
synced 2026-03-19 16:26:00 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56c87ab05f | ||
|
|
b12d645fbf | ||
|
|
04e68adef0 | ||
|
|
52f2b960c2 | ||
|
|
1ea604840e | ||
|
|
802696e78f | ||
|
|
6f17173a8c | ||
|
|
05a8df5933 | ||
|
|
55231bb823 | ||
|
|
d9c1ca6794 | ||
|
|
6613b43264 | ||
|
|
d60dc31291 | ||
|
|
ace6ec876f | ||
|
|
9f759c1928 | ||
|
|
db287e33d7 |
24
README.md
24
README.md
@@ -4,6 +4,16 @@
|
||||
|
||||
A free, user-friendly ROM downloader for Batocera, Knulli, and RetroBat with multi-source support.
|
||||
|
||||
<p align="center">
|
||||
<img width="69%" alt="platform menu" src="https://github.com/user-attachments/assets/4464b57b-06a8-45e9-a411-cc12b421545a" />
|
||||
<img width="30%" alt="controls help" src="https://github.com/user-attachments/assets/38cac7e6-14f2-4e83-91da-0679669822ee" />
|
||||
</p>
|
||||
<p align="center">
|
||||
<img width="49%" alt="web interface" src="https://github.com/user-attachments/assets/71f8bd39-5901-45a9-82b2-91426b3c31a7" />
|
||||
<img width="49%" alt="api menu" src="https://github.com/user-attachments/assets/5bae018d-b7d9-4a95-9f1b-77db751ff24f" />
|
||||
</p>
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Installation
|
||||
@@ -145,22 +155,13 @@ RGSX includes a web interface that launched automatically when using RGSX for re
|
||||
|
||||
### Enable/Disable Web Service at Boot, without the need to launch RGSX
|
||||
|
||||
**Method 1: From RGSX Menu**
|
||||
**From RGSX Menu**
|
||||
1. Open **Pause Menu** (Start/ALTGr)
|
||||
2. Navigate to **Settings > Web Service**
|
||||
3. Toggle **Enable at Boot**
|
||||
4. Restart your device
|
||||
|
||||
**Method 2: Manual Configuration**
|
||||
|
||||
Edit `/saves/ports/rgsx/rgsx_settings.json`:
|
||||
```json
|
||||
{
|
||||
"web_service": {
|
||||
"enabled_at_boot": true
|
||||
}
|
||||
}
|
||||
```
|
||||
**Port Configuration**: The web service runs on port `5000` by default. Ensure this port is not blocked by firewall rules.
|
||||
|
||||
---
|
||||
@@ -229,6 +230,7 @@ Free and open-source software. Use, modify, and distribute freely.
|
||||
|
||||
## Thanks to all contributors, and followers of this app
|
||||
|
||||
**If you want to support my project you can buy me a beer : https://bit.ly/donate-to-rgsx**
|
||||
[](https://starchart.cc/RetroGameSets/RGSX)
|
||||
|
||||
**Developed with ❤️ for the retro gaming community.**
|
||||
**Developed with ❤️ for the retro gaming community.**
|
||||
|
||||
406
README_FR.md
406
README_FR.md
@@ -1,268 +1,236 @@
|
||||
# 🎮 Retro Game Sets Xtra (RGSX)
|
||||
|
||||
## SUPPORT / HELP : https://discord.gg/Vph9jwg3VV
|
||||
**[Support / Aide Discord](https://discord.gg/Vph9jwg3VV)** • **[Installation](#-installation)** • **[Documentation anglaise](https://github.com/RetroGameSets/RGSX/blob/main/README.md)**
|
||||
|
||||
RGSX est une application développée en Python basée sur Pygame pour la partie graphique pour la communauté par RetroGameSets. Elle est entièrement gratuite.
|
||||
Un téléchargeur de ROMs gratuit et facile à utiliser pour Batocera, Knulli et RetroBat avec support multi-sources.
|
||||
|
||||
L'application prend en charge plusieurs sources comme myrient, 1fichier (avec support de débridage via AllDebrid en option). Ces sources pourront être mises à jour fréquemment.
|
||||
<p align="center">
|
||||
<img width="69%" alt="menu plateformes" src="https://github.com/user-attachments/assets/4464b57b-06a8-45e9-a411-cc12b421545a" />
|
||||
<img width="30%" alt="aide contrôles" src="https://github.com/user-attachments/assets/38cac7e6-14f2-4e83-91da-0679669822ee" />
|
||||
</p>
|
||||
<p align="center">
|
||||
<img width="49%" alt="interface web" src="https://github.com/user-attachments/assets/71f8bd39-5901-45a9-82b2-91426b3c31a7" />
|
||||
<img width="49%" alt="menu API" src="https://github.com/user-attachments/assets/5bae018d-b7d9-4a95-9f1b-77db751ff24f" />
|
||||
</p>
|
||||
|
||||
## INSTALLATION : https://github.com/RetroGameSets/RGSX/blob/main/README_FR.md#-installation
|
||||
|
||||
## ✨ Fonctionnalités
|
||||
|
||||
- **Téléchargement de jeux** : Prise en charge des fichiers ZIP et gestion des extensions non supportées à partir du fichier `es_systems.cfg` d'EmulationStation (et des `es_systems_*.cfg` personnalisés sur Batocera). RGSX lit les extensions autorisées par système depuis ces configurations et extrait automatiquement les archives si le système ne les supporte pas.
|
||||
- Les téléchargements ne nécessitent aucune authentification ni compte pour la plupart.
|
||||
- Les systèmes notés `(1fichier)` dans le nom ne seront accessibles que si vous renseignez votre clé API (1Fichier,AllDebrid, Real-Debrid)
|
||||
---
|
||||
> ## IMPORTANT (1Fichier / AllDebrid / Real-Debdrid)
|
||||
> Pour télécharger depuis des liens 1Fichier, vous pouvez utiliser soit votre clé API 1Fichier, soit votre clé API AllDebrid (fallback automatique si 1Fichier est absent).
|
||||
>
|
||||
> Où coller votre clé API (le fichier doit contenir uniquement la clé) :
|
||||
> - `/saves/ports/rgsx/1FichierAPI.txt` (clé API 1Fichier)
|
||||
> - `/saves/ports/rgsx/AllDebridAPI.txt` (clé API AllDebrid)
|
||||
> - `/saves/ports/rgsx/RealDebridAPI.txt` (clé API Real-Debrid)
|
||||
>
|
||||
> Ne créez PAS ces fichiers manuellement. Lancez une première fois l'application RGSX : elle créera automatiquement les fichiers vides s’ils sont absents. Ensuite, ouvrez le fichier correspondant et collez votre clé.
|
||||
---
|
||||
|
||||
**🧰 Utilisation en ligne de commande (CLI)**
|
||||
|
||||
RGSX propose aussi une interface en ligne de commande (sans interface graphique) pour lister les plateformes/jeux et télécharger des ROMs :
|
||||
|
||||
- Guide FR: voir `https://github.com/RetroGameSets/RGSX/blob/main/README_CLI.md`
|
||||
|
||||
- **Historique des téléchargements** : Consultez la liste de tous les téléchargements actuels et anciens.
|
||||
|
||||
- **Téléchargements multi-sélection** : Marquez plusieurs jeux dans la liste avec la touche associée à Vider Historique (par défaut X) pour préparer un lot. Appuyez ensuite sur Confirmer pour lancer les téléchargements en séquence.
|
||||
|
||||
- **Personnalisation des contrôles** : Remappez les touches du clavier ou de la manette à votre convenance, par defaut certaines manettes sont automatiquement configurées
|
||||
|
||||
- **Grille des plateformes** : Possibilité de modifier la disposition de la grille des plateformes (3x3, 3x4, 4x3, 4x4)
|
||||
|
||||
- **Afficher/Masquer plateformes non supportées** : masquage automatique des systèmes dont le dossier ROM est absent selon `es_systems.cfg`, avec un interrupteur dans le menu Affichage.
|
||||
|
||||
- **Changement de police et de taille** : Si vous trouvez les écritures trop petites/trop grosses, pas assez lisibles, vous pouvez le changer dans le menu.
|
||||
|
||||
- **Mode recherche / Filtre** : Filtrez les jeux par nom pour une navigation rapide avec clavier virtuel sur manette.
|
||||
|
||||
- **Support multilingue** : Interface disponible en plusieurs langues. Vous pourrez choisir la langue dans le menu.
|
||||
|
||||
- **Interface adaptative** : L'interface s'adapte à toutes résolutions de 800x600 à 4K (non testé au-delà de 1920x1080).
|
||||
|
||||
- **Mise à jour automatique** : l'application se relance automatiquement après une mise à jour.
|
||||
|
||||
- **Systèmes et Extensions des fichiers** : à la première utilisation, RGSX lit `es_systems.cfg` (RetroBat/Batocera) et génère `/saves/ports/rgsx/rom_extensions.json` avec les extensions autorisées par système. Ainsi que la liste des plateformes prises en charge par le système.
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ Prérequis
|
||||
|
||||
### Système d'exploitation
|
||||
- Batocera / Knulli ou Retrobat
|
||||
|
||||
### Matériel
|
||||
- PC, Raspberry, console portable...
|
||||
- Manette (optionnelle, mais recommandée pour une expérience optimale) ou Clavier.
|
||||
- Connexion internet active
|
||||
|
||||
### Espace disque
|
||||
- 100 Mo pour l'application.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
### Méthode Automatique : BATOCERA / KNULLI
|
||||
### Installation rapide (Batocera / Knulli)
|
||||
|
||||
- Sur un PC lancer un terminal XTERM depuis le menu F1>Applications
|
||||
- Depuis un autre équipement sur le réseau avec application Putty ou autre logiciel prenant en charge le SSH (connectez vous à l'IP user=root pass=linux)
|
||||
**Accès SSH ou Terminal requis :**
|
||||
```bash
|
||||
curl -L bit.ly/rgsx-install | sh
|
||||
```
|
||||
|
||||
**Entrez la commande :**
|
||||
**`curl -L bit.ly/rgsx-install | sh`**
|
||||
|
||||
Patientez et regardez le retour à l'écran ou sur la commande.
|
||||
Après l'installation :
|
||||
1. Mettez à jour les listes de jeux : `Menu > Paramètres des jeux > Mettre à jour la liste des jeux`
|
||||
2. Trouvez RGSX dans **PORTS** ou **Jeux amateurs et portages**
|
||||
|
||||
Vous trouverez RGSX dans le système "PORTS" ou "Jeux Amateurs et portages" (et physiquement dans `/roms/ports/RGSX` et `/roms/windows/rgsx` pour Retrobat.
|
||||
### Installation manuelle (Tous systèmes)
|
||||
1. **Télécharger** : [RGSX_full_latest.zip](https://github.com/RetroGameSets/RGSX/releases/latest/download/RGSX_full_latest.zip)
|
||||
2. **Extraire** :
|
||||
- **Batocera/Knulli** : extraire le dossier `ports` dans `/roms/`
|
||||
- **RetroBat** : extraire les dossiers `ports` et `windows` dans `/roms/`
|
||||
3. **Rafraîchir** : `Menu > Paramètres des jeux > Mettre à jour la liste des jeux`
|
||||
|
||||
Mettez à jour la liste des jeux via : `Menu > Paramètres de jeux > Mettre à jour la liste des jeux` si l'application n'apparaît pas !
|
||||
### Mise à jour manuelle (si la mise à jour automatique a échoué)
|
||||
Téléchargez la dernière version : [RGSX_update_latest.zip](https://github.com/RetroGameSets/RGSX/releases/latest/download/RGSX_full_latest.zip)
|
||||
|
||||
**Chemins d'installation :**
|
||||
- `/roms/ports/RGSX` (tous systèmes)
|
||||
- `/roms/windows/RGSX` (RetroBat uniquement)
|
||||
|
||||
---
|
||||
|
||||
### Méthode manuelle (Retrobat / Batocera)
|
||||
## 🎮 Utilisation
|
||||
|
||||
- Téléchargez le contenu du dépôt en zip : https://github.com/RetroGameSets/RGSX/archive/refs/heads/main.zip
|
||||
- Extraire le fichier zip dans le dossier ROMS de votre installation (pour Batocera, seulement le dossier PORTS, pour Retrobat : PORTS et WINDOWS)
|
||||
- Vous aurez donc les dossiers `/roms/ports/RGSX` et `/roms/windows/rgsx`
|
||||
- Mettez à jour la liste des jeux via : `Menu > Paramètres de jeux > Mettre à jour la liste des jeux` si l'application n'apparaît pas !
|
||||
### Premier lancement
|
||||
|
||||
- Téléchargement automatique des images systèmes et des listes de jeux
|
||||
- Configuration automatique des contrôles si votre manette est reconnue
|
||||
- **Contrôles cassés ?** Supprimez `/saves/ports/rgsx/controls.json` puis relancez
|
||||
|
||||
**Mode clavier** : lorsqu'aucune manette n'est détectée, les contrôles s'affichent sous forme de `[Touche]` au lieu d'icônes.
|
||||
|
||||
### Structure du menu pause
|
||||
|
||||
**Contrôles**
|
||||
- Voir l'aide des contrôles
|
||||
- Remapper les contrôles
|
||||
|
||||
**Affichage**
|
||||
- Disposition (3×3, 3×4, 4×3, 4×4)
|
||||
- Taille de police (UI générale)
|
||||
- Taille de police du footer (texte des contrôles/version)
|
||||
- Famille de police (polices pixel)
|
||||
- Masquer l'avertissement d'extension inconnue
|
||||
|
||||
**Jeux**
|
||||
- Historique des téléchargements
|
||||
+- Mode des sources (RGSX / Personnalisé)
|
||||
- Mettre à jour le cache des jeux
|
||||
- Afficher les plateformes non supportées
|
||||
- Masquer les systèmes premium
|
||||
- Filtrer les plateformes
|
||||
|
||||
**Paramètres**
|
||||
- Musique de fond (on/off)
|
||||
- Options de symlink (Batocera)
|
||||
- Service web (Batocera)
|
||||
- Gestion des clés API
|
||||
- Sélection de la langue
|
||||
|
||||
---
|
||||
|
||||
## 🏁 Premier démarrage
|
||||
## ✨ Fonctionnalités
|
||||
|
||||
- Vous trouverez RGSX dans le système "WINDOWS" sur Retrobat et dans "PORTS" ou "Jeux Amateurs et portages"
|
||||
- Au premier lancement, l'application importera automatiquement la configuration des contrôles depuis des fichiers pré-configurés dans /roms/ports/RGSX/assets/controls si votre manette est reconnue
|
||||
- L'application téléchargera toutes les données nécessaires automatiquement ensuite (images des systèmes, liste des jeux, etc.)
|
||||
- 🎯 **Détection intelligente des systèmes** – Découverte automatique des systèmes supportés depuis `es_systems.cfg`
|
||||
- 📦 **Gestion intelligente des archives** – Extraction automatique quand un système ne supporte pas les fichiers ZIP
|
||||
- 🔑 **Débloquage premium** – API 1Fichier + fallback AllDebrid/Real-Debrid pour des téléchargements illimités
|
||||
- 🎨 **Entièrement personnalisable** – Disposition (3×3 à 4×4), polices, tailles de police (UI + footer), langues (EN/FR/DE/ES/IT/PT)
|
||||
- 🎮 **Pensé manette d'abord** – Auto-mapping pour les manettes populaires + remapping personnalisé
|
||||
- 🔍 **Filtrage avancé** – Recherche par nom, affichage/masquage des systèmes non supportés, filtre de plateformes
|
||||
- 📊 **Gestion des téléchargements** – File d'attente, historique, notifications de progression
|
||||
- 🌐 **Sources personnalisées** – Utilisez vos propres URLs de dépôt de jeux
|
||||
- ♿ **Accessibilité** – Échelles de police séparées pour l'UI et le footer, support du mode clavier seul
|
||||
|
||||
INFO : pour retrobat au premier lancement, l'application téléchargera Python dans le dossier /system/tools/python qui est nécessaire pour faire fonctionner l'application. Le fichier fait environ 50 Mo et va assez vite à télécharger mais il n'y a aucun retour visuel à l'écran, qui va rester figé sur le chargement de RGSX pendant quelques secondes. Vous trouvez le log d'installation dans `/roms/ports/RGSX-INSTALL.log` à fournir en cas de problème.
|
||||
> ### 🔑 Configuration des clés API
|
||||
> Pour des téléchargements 1Fichier illimités, ajoutez vos clés API dans `/saves/ports/rgsx/` :
|
||||
> - `1FichierAPI.txt` – Clé API 1Fichier (recommandé)
|
||||
> - `AllDebridAPI.txt` – Fallback AllDebrid (optionnel)
|
||||
> - `RealDebridAPI.txt` – Fallback Real-Debrid (optionnel)
|
||||
>
|
||||
> **Chaque fichier ne doit contenir QUE la clé, sans texte supplémentaire.**
|
||||
|
||||
---
|
||||
### Télécharger des jeux
|
||||
|
||||
## 🕹️ Utilisation
|
||||
1. Parcourez les plateformes → sélectionnez un jeu
|
||||
2. **Téléchargement direct** : appuyez sur `Confirmer`
|
||||
3. **Ajout à la file d'attente** : appuyez sur `X` (bouton Ouest)
|
||||
4. Suivez la progression dans le menu **Historique** ou via les popups de notification
|
||||
|
||||
### Navigation dans les menus
|
||||
### Sources de jeux personnalisées
|
||||
|
||||
- Utilisez les touches directionnelles (D-Pad, flèches du clavier) pour naviguer entre les plateformes, jeux et options.
|
||||
- Appuyez sur la touche configurée comme start (par défaut, **P** ou bouton Start sur la manette) pour ouvrir le menu pause. Depuis ce menu, accédez à toute la configuration de l'application.
|
||||
- Vous pouvez aussi, depuis le menu, régénérer le cache de la liste des systèmes/jeux/images pour être sûr d'avoir les dernières mises à jour.
|
||||
Basculez vers les sources personnalisées via **Menu pause > Jeux > Mode des sources**.
|
||||
|
||||
---
|
||||
|
||||
#### Menu Affichage
|
||||
|
||||
- Disposition: basculez la grille des plateformes entre 3x3, 3x4, 4x3, 4x4.
|
||||
- Taille de police: ajustez l’échelle du texte (accessibilité).
|
||||
- Afficher plateformes non supportées: afficher/masquer les systèmes dont le dossier ROM est absent.
|
||||
- Filtrer les systèmes: afficher/masquer rapidement des plateformes par nom (persistant).
|
||||
|
||||
---
|
||||
|
||||
### Téléchargement
|
||||
|
||||
- Sélectionnez une plateforme, puis un jeu.
|
||||
- Appuyez sur la touche configurée confirm (par défaut, **Entrée** ou bouton **A**) pour lancer le téléchargement.
|
||||
- Option : appuyez sur la touche Vider Historique (par défaut **X**) sur plusieurs jeux pour activer/désactiver leur sélection (marqueur [X]). Puis validez pour lancer un lot de téléchargements.
|
||||
- Suivez la progression dans le menu `HISTORIQUE`.
|
||||
|
||||
---
|
||||
|
||||
### Personnalisation des contrôles
|
||||
|
||||
- Dans le menu pause, sélectionnez **Reconfigurer controles**.
|
||||
- Suivez les instructions à l'écran pour mapper chaque action en maintenant la touche ou le bouton pendant 3 secondes.
|
||||
- Les noms des boutons s'affichent automatiquement selon votre manette (A, B, X, Y, LB, RB, LT, RT, etc.).
|
||||
- La configuration est compatible avec toutes les manettes supportées par EmulationStation.
|
||||
- En cas de problème de contrôles ou configuration corrompue, supprimez le fichier : `/saves/ports/rgsx/controls.json` s'il existe puis redémarrez l'application (il sera recréé automatiquement).
|
||||
|
||||
---
|
||||
|
||||
### Historique
|
||||
|
||||
- Accédez à l'historique des téléchargements via le menu pause ou en appuyant sur la touche historique (par défaut, **H**).
|
||||
- Sélectionnez un jeu pour le retélécharger si nécessaire en cas d'erreur ou annulation.
|
||||
- Videz tout l'historique via le bouton **EFFACER** dans le menu historique. Les jeux ne sont pas effacés seulement la liste.
|
||||
- Annulez un téléchargement avec le bouton **RETOUR**
|
||||
|
||||
---
|
||||
|
||||
### Logs
|
||||
|
||||
Les logs sont enregistrés dans `/roms/ports/RGSX/logs/RGSX.log` sur batocera et sur Retrobat pour diagnostiquer les problèmes et seront à partager pour tout support.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Journal des modifications
|
||||
Toutes les infos sur discord ou sur les commit github.
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Sources de jeux personnalisées
|
||||
Vous pouvez changer la source dans le menu pause (Source des jeux : RGSX / Personnalisée).
|
||||
|
||||
Le mode personnalisé attend une URL ZIP (HTTP/HTTPS) pointant vers une archive des sources avec la même structure que celle par défaut. À configurer dans :
|
||||
`{chemin rgsx_settings}` → clé : `sources.custom_url`
|
||||
|
||||
Comportement :
|
||||
- Si mode personnalisé sélectionné et URL vide/invalide → liste vide + popup (aucun fallback)
|
||||
- Corrigez l’URL puis utilisez "Mettre à jour la liste des jeux" et redémarrez si nécessaire
|
||||
|
||||
Exemple dans rgsx_settings.json :
|
||||
Configurez dans `/saves/ports/rgsx/rgsx_settings.json` :
|
||||
```json
|
||||
"sources": {
|
||||
"mode": "custom",
|
||||
"custom_url": "https://exemple.com/mes-sources.zip"
|
||||
{
|
||||
"sources": {
|
||||
"mode": "custom",
|
||||
"custom_url": "https://example.com/my-sources.zip"
|
||||
}
|
||||
}
|
||||
```
|
||||
Revenez au mode RGSX à tout moment via le menu pause.
|
||||
**Note** : si le mode personnalisé est activé mais que l'URL est invalide/vide = utilisation de `/saves/ports/rgsx/games.zip`. Vous devez mettre à jour le cache des jeux dans le menu RGSX après avoir corrigé l'URL.
|
||||
|
||||
---
|
||||
|
||||
## 📁 Structure du projet
|
||||
## 🌐 Interface web (Batocera/Knulli uniquement)
|
||||
|
||||
RGSX inclut une interface web qui se lance automatiquement avec RGSX pour parcourir et télécharger des jeux à distance depuis n'importe quel appareil de votre réseau.
|
||||
|
||||
### Accéder à l'interface web
|
||||
|
||||
1. **Trouvez l'adresse IP de votre Batocera** :
|
||||
- Dans le menu Batocera : `Paramètres réseau`
|
||||
- Ou depuis un terminal : `ip addr show`
|
||||
|
||||
2. **Ouvrez dans un navigateur** : `http://[IP_BATO]:5000` ou `http://BATOCERA:5000`
|
||||
- Exemple : `http://192.168.1.100:5000`
|
||||
|
||||
3. **Accessible depuis n'importe quel appareil** : téléphone, tablette, PC sur le même réseau
|
||||
|
||||
### Fonctionnalités de l'interface web
|
||||
|
||||
- 📱 **Compatible mobile** – Design responsive qui fonctionne sur tous les écrans
|
||||
- 🔍 **Parcourir tous les systèmes** – Voir toutes les plateformes et les jeux
|
||||
- ⬇️ **Téléchargements à distance** – Ajouter des téléchargements directement sur votre Batocera
|
||||
- 📊 **Statut en temps réel** – Voir les téléchargements actifs et l'historique
|
||||
- 🎮 **Même liste de jeux** – Utilise les mêmes sources que l'application principale
|
||||
|
||||
|
||||
### Activer/Désactiver le service web au démarrage, sans lancer RGSX
|
||||
|
||||
**Depuis le menu RGSX**
|
||||
1. Ouvrez le **menu pause** (Start/ALTGr)
|
||||
2. Allez dans **Paramètres > Service web**
|
||||
3. Basculez sur **Activer au démarrage**
|
||||
4. Redémarrez votre appareil
|
||||
|
||||
|
||||
**Configuration du port** : le service web utilise le port `5000` par défaut. Assurez-vous qu'il n'est pas bloqué par un pare-feu.
|
||||
|
||||
---
|
||||
|
||||
## 📁 Structure des fichiers
|
||||
|
||||
```
|
||||
/roms/windows/RGSX
|
||||
│
|
||||
├── RGSX Retrobat.bat # Raccourci pour lancer l'application RGSX pour retrobat uniquement, non nécessaire pour batocera/knulli
|
||||
/roms/ports/RGSX/
|
||||
├── __main__.py # Point d'entrée
|
||||
├── controls.py # Gestion des entrées
|
||||
├── display.py # Moteur de rendu
|
||||
├── network.py # Gestionnaire de téléchargements
|
||||
├── rgsx_settings.py # Gestionnaire de paramètres
|
||||
├── assets/controls/ # Profils de manettes
|
||||
├── languages/ # Traductions (EN/FR/DE/ES/IT/PT)
|
||||
└── logs/RGSX.log # Logs d'exécution
|
||||
|
||||
/roms/ports/
|
||||
├── RGSX-INSTALL.log # LOG d'installation uniquement
|
||||
└── RGSX/
|
||||
│ └──── __main__.py # Point d'entrée principal de l'application.
|
||||
│ ├──── controls.py # Gestion des événements de navigation dans les menus.
|
||||
│ ├──── controls_mapper.py # Configuration des contrôles
|
||||
│ ├──── display.py # Rendu des interfaces graphiques avec Pygame.
|
||||
│ ├──── config.py # Configuration globale (chemins, paramètres, etc.).
|
||||
│ ├──── rgsx_settings.py # Gestion unifiée des paramètres de l'application.
|
||||
│ ├──── network.py # Gestion des téléchargements de jeux.
|
||||
│ ├──── history.py # Gestion de l'historique des téléchargements.
|
||||
│ ├──── language.py # Gestion du support multilingue.
|
||||
│ ├──── accessibility.py # Gestion des paramètres d'accessibilité.
|
||||
│ ├──── utils.py # Fonctions utilitaires (wrap du texte, troncage etc.).
|
||||
│ ├──── update_gamelist.py # Mise à jour de la liste des jeux (Batocera/Knulli).
|
||||
│ └──── update_gamelist_windows.py # MAJ gamelist retrobat au lancement.
|
||||
└────logs/
|
||||
│ └──── RGSX.log # Fichier de logs.
|
||||
└── assets/ # Ressources de l'application (polices, exécutables, musique).
|
||||
└──── controls/ # Fichiers de configuration des contrôles pré-définis
|
||||
└──── languages/ # Fichiers de traduction
|
||||
/roms/windows/RGSX/
|
||||
└── RGSX Retrobat.bat # Lanceur RetroBat
|
||||
|
||||
|
||||
/saves/ports/RGSX/
|
||||
│
|
||||
├── systems_list.json # Liste des systèmes / dossiers / images.
|
||||
├── games/ # Liens des jeux / plateformes
|
||||
├── images/ # Images des plateformes.
|
||||
├── rgsx_settings.json # Fichier de configuration des paramètres.
|
||||
├── controls.json # Fichier de mappage des contrôles manuel
|
||||
├── history.json # Base de données de l'historique de téléchargements
|
||||
├── rom_extensions.json # Généré depuis es_systems.cfg : extensions autorisées
|
||||
├── 1FichierAPI.txt # Clé API 1fichier
|
||||
└── AllDebridAPI.txt # Clé API AllDebrid
|
||||
/saves/ports/rgsx/
|
||||
├── rgsx_settings.json # Préférences utilisateur
|
||||
├── controls.json # Mappage des contrôles
|
||||
├── history.json # Historique des téléchargements
|
||||
├── rom_extensions.json # Cache des extensions supportées
|
||||
├── systems_list.json # Systèmes détectés
|
||||
├── games/ # Bases de données de jeux (par plateforme)
|
||||
├── images/ # Images des plateformes
|
||||
├── 1FichierAPI.txt # Clé API 1Fichier
|
||||
├── AllDebridAPI.txt # Clé API AllDebrid
|
||||
└── RealDebridAPI.txt # Clé API Real-Debrid
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Dépannage
|
||||
|
||||
| Problème | Solution |
|
||||
|----------|----------|
|
||||
| Contrôles qui ne répondent plus | Supprimer `/saves/ports/rgsx/controls.json` + redémarrer |
|
||||
| Jeux non affichés | Menu pause > Jeux > Mettre à jour le cache des jeux |
|
||||
| Téléchargement bloqué | Vérifier les clés API dans `/saves/ports/rgsx/` |
|
||||
| Crash de l'application | Vérifier `/roms/ports/RGSX/logs/RGSX.log` |
|
||||
| Changement de layout non pris en compte | Redémarrer RGSX après modification du layout |
|
||||
|
||||
**Besoin d'aide ?** Partagez les logs depuis `/roms/ports/RGSX/logs/` sur [Discord](https://discord.gg/Vph9jwg3VV).
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Contribution
|
||||
|
||||
### Signaler un bug
|
||||
|
||||
1. Consultez les logs dans `/roms/ports/RGSX/logs/RGSX.log`.
|
||||
2. Envoyez un message sur le discord avec le log complet et une description du problème.
|
||||
- Lien Discord : https://discord.gg/Vph9jwg3VV
|
||||
|
||||
### Proposer une fonctionnalité
|
||||
|
||||
- Discutez de votre idée sur le discord pour obtenir des retours.
|
||||
- Soumettez une issue avec une description claire de la fonctionnalité proposée.
|
||||
- Expliquez comment elle s'intègre dans l'application.
|
||||
|
||||
### Contribuer au code
|
||||
|
||||
1. Forkez le dépôt et créez une branche pour votre fonctionnalité ou correction :
|
||||
```bash
|
||||
git checkout -b feature/nom-de-votre-fonctionnalité
|
||||
```
|
||||
2. Testez vos modifications sur Batocera.
|
||||
3. Soumettez une pull request avec une description détaillée.
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Problèmes connus
|
||||
|
||||
- (Aucun listé actuellement)
|
||||
- **Rapports de bugs** : ouvrez une issue GitHub avec les logs ou postez sur Discord
|
||||
- **Demandes de fonctionnalités** : discutez d'abord sur Discord, puis ouvrez une issue
|
||||
- **Contributions de code** :
|
||||
```bash
|
||||
git checkout -b feature/your-feature
|
||||
# Testez sur Batocera/RetroBat
|
||||
# Soumettez une Pull Request
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 Licence
|
||||
|
||||
Ce projet est libre. Vous êtes libre de l'utiliser, le modifier et le distribuer selon les termes de cette licence.
|
||||
Logiciel libre et open-source. Utilisation, modification et distribution autorisées librement.
|
||||
|
||||
## Merci à tous les contributeurs et aux personnes qui suivent l'application
|
||||
|
||||
[](https://starchart.cc/RetroGameSets/RGSX)
|
||||
|
||||
**Développé avec ❤️ pour la communauté du retrogaming.**
|
||||
|
||||
Développé avec ❤️ pour les amateurs de jeux rétro.
|
||||
|
||||
@@ -22,7 +22,7 @@ from display import (
|
||||
init_display, draw_loading_screen, draw_error_screen, draw_platform_grid,
|
||||
draw_progress_screen, draw_controls, draw_virtual_keyboard,
|
||||
draw_extension_warning, draw_pause_menu, draw_controls_help, draw_game_list,
|
||||
draw_display_menu,
|
||||
draw_display_menu, draw_filter_menu_choice, draw_filter_advanced, draw_filter_priority_config,
|
||||
draw_history_list, draw_clear_history_dialog, draw_cancel_download_dialog,
|
||||
draw_confirm_dialog, draw_reload_games_data_dialog, draw_popup, draw_gradient,
|
||||
draw_toast, show_toast, THEME_COLORS
|
||||
@@ -420,6 +420,21 @@ async def main():
|
||||
global current_music, music_files, music_folder, joystick
|
||||
logger.debug("Début main")
|
||||
|
||||
# Charger les filtres de jeux sauvegardés
|
||||
try:
|
||||
from game_filters import GameFilters
|
||||
from rgsx_settings import load_game_filters
|
||||
config.game_filter_obj = GameFilters()
|
||||
filter_dict = load_game_filters()
|
||||
if filter_dict:
|
||||
config.game_filter_obj.load_from_dict(filter_dict)
|
||||
if config.game_filter_obj.is_active():
|
||||
config.filter_active = True
|
||||
logger.info("Filtres de jeux chargés et actifs")
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur lors du chargement des filtres: {e}")
|
||||
config.game_filter_obj = None
|
||||
|
||||
# Démarrer le serveur web en arrière-plan
|
||||
start_web_server()
|
||||
|
||||
@@ -672,6 +687,10 @@ async def main():
|
||||
"history_error_details",
|
||||
"history_confirm_delete",
|
||||
"history_extract_archive",
|
||||
# Menus filtrage avancé
|
||||
"filter_menu_choice",
|
||||
"filter_advanced",
|
||||
"filter_priority_config",
|
||||
}
|
||||
if config.menu_state in SIMPLE_HANDLE_STATES:
|
||||
action = handle_controls(event, sources, joystick, screen)
|
||||
@@ -1070,6 +1089,12 @@ async def main():
|
||||
elif config.menu_state == "filter_platforms":
|
||||
from display import draw_filter_platforms_menu
|
||||
draw_filter_platforms_menu(screen)
|
||||
elif config.menu_state == "filter_menu_choice":
|
||||
draw_filter_menu_choice(screen)
|
||||
elif config.menu_state == "filter_advanced":
|
||||
draw_filter_advanced(screen)
|
||||
elif config.menu_state == "filter_priority_config":
|
||||
draw_filter_priority_config(screen)
|
||||
elif config.menu_state == "controls_help":
|
||||
draw_controls_help(screen, config.previous_menu_state)
|
||||
elif config.menu_state == "history":
|
||||
|
||||
@@ -13,7 +13,7 @@ except Exception:
|
||||
pygame = None # type: ignore
|
||||
|
||||
# Version actuelle de l'application
|
||||
app_version = "2.3.2.1"
|
||||
app_version = "2.3.2.8"
|
||||
|
||||
|
||||
def get_application_root():
|
||||
@@ -380,6 +380,11 @@ search_mode = False # Indicateur si le mode recherche est actif
|
||||
search_query = "" # Chaîne de recherche saisie par l'utilisateur
|
||||
filter_active = False # Indicateur si un filtre est appliqué
|
||||
|
||||
# Variables pour le filtrage avancé
|
||||
selected_filter_choice = 0 # Index dans le menu de choix de filtrage (recherche / avancé)
|
||||
selected_filter_option = 0 # Index dans le menu de filtrage avancé
|
||||
game_filter_obj = None # Objet GameFilters pour le filtrage avancé
|
||||
|
||||
# Gestion des états du menu
|
||||
needs_redraw = False # Indicateur si l'écran doit être redessiné
|
||||
selected_option = 0 # Index de l'option sélectionnée dans le menu
|
||||
|
||||
@@ -15,14 +15,12 @@ from utils import (
|
||||
load_games, check_extension_before_download, is_extension_supported,
|
||||
load_extensions_json, play_random_music, sanitize_filename,
|
||||
save_music_config, load_api_keys, _get_dest_folder_name,
|
||||
extract_zip, extract_rar, find_file_with_or_without_extension,
|
||||
toggle_web_service_at_boot, check_web_service_status,
|
||||
toggle_custom_dns_at_boot, check_custom_dns_status,
|
||||
extract_zip, extract_rar, find_file_with_or_without_extension, toggle_web_service_at_boot, check_web_service_status,
|
||||
restart_application, generate_support_zip, load_sources,
|
||||
ensure_download_provider_keys, missing_all_provider_keys, build_provider_paths_string
|
||||
)
|
||||
from history import load_history, clear_history, add_to_history, save_history
|
||||
from language import _, get_available_languages, set_language
|
||||
from language import _, get_available_languages, set_language
|
||||
from rgsx_settings import (
|
||||
get_allow_unknown_extensions, set_display_grid, get_font_family, set_font_family,
|
||||
get_show_unsupported_platforms, set_show_unsupported_platforms,
|
||||
@@ -60,7 +58,12 @@ VALID_STATES = [
|
||||
"scraper", # écran du scraper avec métadonnées
|
||||
"history_error_details", # détails de l'erreur
|
||||
"history_confirm_delete", # confirmation suppression jeu
|
||||
"history_extract_archive" # extraction d'archive
|
||||
"history_extract_archive", # extraction d'archive
|
||||
# Nouveaux menus filtrage avancé
|
||||
"filter_menu_choice", # menu de choix entre recherche et filtrage avancé
|
||||
"filter_search", # recherche par nom (existant, mais renommé)
|
||||
"filter_advanced", # filtrage avancé par région, etc.
|
||||
"filter_priority_config", # configuration priorité régions pour one-rom-per-game
|
||||
]
|
||||
|
||||
def validate_menu_state(state):
|
||||
@@ -198,7 +201,21 @@ def is_input_matched(event, action_name):
|
||||
elif input_type == "axis" and event.type == pygame.JOYAXISMOTION:
|
||||
axis = mapping.get("axis")
|
||||
direction = mapping.get("direction")
|
||||
return event.axis == axis and abs(event.value) > 0.5 and (1 if event.value > 0 else -1) == direction
|
||||
threshold = 0.5
|
||||
# Pour les triggers Xbox (axes 4 et 5), la position de repos est -1.0
|
||||
# Il faut inverser la détection : direction -1 = trigger appuyé (vers +1.0)
|
||||
if axis in [4, 5]:
|
||||
# Triggers Xbox: repos à -1.0, appuyé vers +1.0
|
||||
# On inverse la direction configurée
|
||||
if direction == -1:
|
||||
# Direction -1 configurée = détecter quand trigger appuyé (valeur positive)
|
||||
return event.axis == axis and event.value > threshold
|
||||
else:
|
||||
# Direction +1 configurée = détecter aussi quand trigger appuyé
|
||||
return event.axis == axis and event.value > threshold
|
||||
else:
|
||||
# Autres axes: logique normale
|
||||
return event.axis == axis and abs(event.value) > threshold and (1 if event.value > 0 else -1) == direction
|
||||
elif input_type == "hat" and event.type == pygame.JOYHATMOTION:
|
||||
hat_value = mapping.get("value")
|
||||
if isinstance(hat_value, list):
|
||||
@@ -206,6 +223,28 @@ def is_input_matched(event, action_name):
|
||||
return event.value == hat_value
|
||||
elif input_type == "mouse" and event.type == pygame.MOUSEBUTTONDOWN:
|
||||
return event.button == mapping.get("button")
|
||||
|
||||
# Fallback clavier pour dépannage (fonctionne toujours même avec manette configurée)
|
||||
if event.type == pygame.KEYDOWN:
|
||||
keyboard_fallback = {
|
||||
"up": pygame.K_UP,
|
||||
"down": pygame.K_DOWN,
|
||||
"left": pygame.K_LEFT,
|
||||
"right": pygame.K_RIGHT,
|
||||
"confirm": pygame.K_RETURN,
|
||||
"cancel": pygame.K_ESCAPE,
|
||||
"start": pygame.K_RALT,
|
||||
"filter": pygame.K_f,
|
||||
"history": pygame.K_h,
|
||||
"clear_history": pygame.K_DELETE,
|
||||
"delete": pygame.K_d,
|
||||
"space": pygame.K_SPACE,
|
||||
"page_up": pygame.K_PAGEUP,
|
||||
"page_down": pygame.K_PAGEDOWN,
|
||||
}
|
||||
if action_name in keyboard_fallback:
|
||||
return event.key == keyboard_fallback[action_name]
|
||||
|
||||
return False
|
||||
|
||||
def _launch_next_queued_download():
|
||||
@@ -442,8 +481,15 @@ def handle_controls(event, sources, joystick, screen):
|
||||
if config.platforms:
|
||||
config.current_platform = config.selected_platform
|
||||
config.games = load_games(config.platforms[config.current_platform])
|
||||
config.filtered_games = config.games
|
||||
config.filter_active = False
|
||||
|
||||
# Apply saved filters automatically if any
|
||||
if 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
|
||||
draw_validation_transition(screen, config.current_platform)
|
||||
@@ -471,6 +517,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"
|
||||
@@ -479,6 +527,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"
|
||||
@@ -487,6 +537,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"
|
||||
@@ -495,6 +547,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"
|
||||
@@ -622,14 +676,12 @@ def handle_controls(event, sources, joystick, screen):
|
||||
event.value)
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "filter"):
|
||||
config.search_mode = True
|
||||
config.search_query = ""
|
||||
config.filtered_games = config.games
|
||||
config.current_game = 0
|
||||
config.scroll_offset = 0
|
||||
config.selected_key = (0, 0)
|
||||
# Afficher le menu de choix entre recherche et filtrage avancé
|
||||
config.menu_state = "filter_menu_choice"
|
||||
config.selected_filter_choice = 0
|
||||
config.previous_menu_state = "game"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Entrée en mode recherche")
|
||||
logger.debug("Ouverture du menu de filtrage")
|
||||
elif is_input_matched(event, "history"):
|
||||
config.menu_state = "history"
|
||||
config.needs_redraw = True
|
||||
@@ -1417,7 +1469,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
# Sous-menu Display
|
||||
elif config.menu_state == "pause_display_menu":
|
||||
sel = getattr(config, 'pause_display_selection', 0)
|
||||
total = 6 # layout, font size, footer font size, font family, unknown, back
|
||||
total = 6 # layout, font size, footer font size, font family, allow unknown extensions, back
|
||||
if is_input_matched(event, "up"):
|
||||
config.pause_display_selection = (sel - 1) % total
|
||||
config.needs_redraw = True
|
||||
@@ -1425,7 +1477,6 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.pause_display_selection = (sel + 1) % total
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "left") or is_input_matched(event, "right") or is_input_matched(event, "confirm"):
|
||||
sel = getattr(config, 'pause_display_selection', 0)
|
||||
# 0 layout cycle
|
||||
if sel == 0 and (is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
layouts = [(3,3),(3,4),(4,3),(4,4)]
|
||||
@@ -1441,12 +1492,12 @@ def handle_controls(event, sources, joystick, screen):
|
||||
logger.error(f"Erreur set_display_grid: {e}")
|
||||
config.GRID_COLS = new_cols
|
||||
config.GRID_ROWS = new_rows
|
||||
# Afficher popup au lieu de redémarrer
|
||||
# Afficher un popup indiquant que le changement sera effectif après redémarrage
|
||||
try:
|
||||
restart_msg = _("popup_layout_changed_restart").format(new_cols, new_rows) if _ else f"Layout changed to {new_cols}x{new_rows}. Please restart the app to apply changes."
|
||||
show_toast(restart_msg, duration=3000)
|
||||
config.popup_message = _("popup_layout_changed_restart_required") if _ else "Layout changed. Restart required to apply."
|
||||
config.popup_timer = 3000
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur toast après layout: {e}")
|
||||
logger.error(f"Erreur popup layout: {e}")
|
||||
config.needs_redraw = True
|
||||
# 1 font size
|
||||
elif sel == 1 and (is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
@@ -1468,23 +1519,16 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.needs_redraw = True
|
||||
# 2 footer font size
|
||||
elif sel == 2 and (is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
opts = getattr(config, 'footer_font_scale_options', [0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0])
|
||||
from accessibility import update_footer_font_scale
|
||||
footer_opts = getattr(config, 'footer_font_scale_options', [0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0])
|
||||
idx = getattr(config, 'current_footer_font_scale_index', 3)
|
||||
idx = max(0, idx-1) if is_input_matched(event, "left") else min(len(opts)-1, idx+1)
|
||||
idx = max(0, idx-1) if is_input_matched(event, "left") else min(len(footer_opts)-1, idx+1)
|
||||
if idx != getattr(config, 'current_footer_font_scale_index', 3):
|
||||
config.current_footer_font_scale_index = idx
|
||||
scale = opts[idx]
|
||||
config.accessibility_settings["footer_font_scale"] = scale
|
||||
try:
|
||||
save_accessibility_settings(config.accessibility_settings)
|
||||
update_footer_font_scale()
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur sauvegarde footer font scale: {e}")
|
||||
try:
|
||||
init_footer_font_func = getattr(config, 'init_footer_font', None)
|
||||
if callable(init_footer_font_func):
|
||||
init_footer_font_func()
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur init footer font: {e}")
|
||||
logger.error(f"Erreur update footer font scale: {e}")
|
||||
config.needs_redraw = True
|
||||
# 3 font family cycle
|
||||
elif sel == 3 and (is_input_matched(event, "left") or is_input_matched(event, "right") or is_input_matched(event, "confirm")):
|
||||
@@ -1531,7 +1575,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur toggle allow_unknown_extensions: {e}")
|
||||
# 5 back
|
||||
elif sel == 5 and (is_input_matched(event, "confirm")):
|
||||
elif sel == 5 and is_input_matched(event, "confirm"):
|
||||
config.menu_state = "pause_menu"
|
||||
config.last_state_change_time = pygame.time.get_ticks()
|
||||
config.needs_redraw = True
|
||||
@@ -1551,7 +1595,6 @@ 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"):
|
||||
sel = getattr(config, 'pause_games_selection', 0)
|
||||
if sel == 0 and is_input_matched(event, "confirm"): # history
|
||||
config.history = load_history()
|
||||
config.current_history_item = 0
|
||||
@@ -1579,8 +1622,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.menu_state = "reload_games_data"
|
||||
config.redownload_confirm_selection = 0
|
||||
config.needs_redraw = True
|
||||
# 3 unsupported toggle
|
||||
elif sel == 3 and (is_input_matched(event, "left") or is_input_matched(event, "right") or is_input_matched(event, "confirm")):
|
||||
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()
|
||||
new_val = set_show_unsupported_platforms(not current)
|
||||
@@ -1590,8 +1632,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.needs_redraw = True
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur toggle unsupported: {e}")
|
||||
# 4 hide premium systems
|
||||
elif sel == 4 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
elif sel == 4 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")): # hide premium
|
||||
try:
|
||||
cur = get_hide_premium_systems()
|
||||
new_val = set_hide_premium_systems(not cur)
|
||||
@@ -1600,8 +1641,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.needs_redraw = True
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur toggle hide_premium_systems: {e}")
|
||||
# 5 filter platforms
|
||||
elif sel == 5 and (is_input_matched(event, "confirm") or is_input_matched(event, "right")):
|
||||
elif sel == 5 and is_input_matched(event, "confirm"): # filter platforms
|
||||
config.filter_return_to = "pause_games_menu"
|
||||
config.menu_state = "filter_platforms"
|
||||
config.selected_filter_index = 0
|
||||
@@ -1622,11 +1662,9 @@ def handle_controls(event, sources, joystick, screen):
|
||||
# Calculer le nombre total d'options selon le système
|
||||
total = 4 # music, symlink, api keys, back
|
||||
web_service_index = -1
|
||||
custom_dns_index = -1
|
||||
if config.OPERATING_SYSTEM == "Linux":
|
||||
total = 6 # music, symlink, web_service, custom_dns, api keys, back
|
||||
total = 5 # music, symlink, web_service, api keys, back
|
||||
web_service_index = 2
|
||||
custom_dns_index = 3
|
||||
|
||||
if is_input_matched(event, "up"):
|
||||
config.pause_settings_selection = (sel - 1) % total
|
||||
@@ -1635,7 +1673,6 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.pause_settings_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"):
|
||||
sel = getattr(config, 'pause_settings_selection', 0)
|
||||
# Option 0: Music toggle
|
||||
if sel == 0 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
config.music_enabled = not config.music_enabled
|
||||
@@ -1646,11 +1683,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
if music_files and music_folder:
|
||||
config.current_music = play_random_music(music_files, music_folder, getattr(config, "current_music", None))
|
||||
else:
|
||||
try:
|
||||
if pygame.mixer.get_init() is not None:
|
||||
pygame.mixer.music.stop()
|
||||
except (AttributeError, NotImplementedError):
|
||||
pass
|
||||
pygame.mixer.music.stop()
|
||||
config.needs_redraw = True
|
||||
logger.info(f"Musique {'activée' if config.music_enabled else 'désactivée'} via settings")
|
||||
# Option 1: Symlink toggle
|
||||
@@ -1663,6 +1696,7 @@ def handle_controls(event, sources, joystick, screen):
|
||||
logger.info(f"Symlink option {'activée' if not current_status else 'désactivée'} via settings")
|
||||
# Option 2: Web Service toggle (seulement si Linux)
|
||||
elif sel == web_service_index and web_service_index >= 0 and (is_input_matched(event, "confirm") or is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
|
||||
current_status = check_web_service_status()
|
||||
# Afficher un message de chargement
|
||||
config.popup_message = _("settings_web_service_enabling") if not current_status else _("settings_web_service_disabling")
|
||||
@@ -1679,26 +1713,8 @@ 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 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")):
|
||||
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"Service custom DNS {'activé' if not current_status else 'désactivé'} au démarrage")
|
||||
else:
|
||||
logger.error(f"Erreur toggle service custom DNS: {message}")
|
||||
threading.Thread(target=toggle_dns, daemon=True).start()
|
||||
# Option API Keys (index varie selon Linux ou pas)
|
||||
elif sel == (custom_dns_index + 1 if custom_dns_index >= 0 else 2) and is_input_matched(event, "confirm"):
|
||||
elif sel == (web_service_index + 1 if web_service_index >= 0 else 2) and is_input_matched(event, "confirm"):
|
||||
config.menu_state = "pause_api_keys_status"
|
||||
config.needs_redraw = True
|
||||
# Option Back (dernière option)
|
||||
@@ -1734,7 +1750,6 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.display_menu_selection = (sel + 1) % 5
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "left") or is_input_matched(event, "right") or is_input_matched(event, "confirm"):
|
||||
sel = getattr(config, 'display_menu_selection', 0)
|
||||
# 0: layout change
|
||||
if sel == 0 and (is_input_matched(event, "left") or is_input_matched(event, "right")):
|
||||
layouts = [(3,3),(3,4),(4,3),(4,4)]
|
||||
@@ -1922,48 +1937,312 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.needs_redraw = True
|
||||
logger.debug("Annulation de la sélection de langue, retour au menu pause")
|
||||
|
||||
# Menu de choix filtrage
|
||||
elif config.menu_state == "filter_menu_choice":
|
||||
if is_input_matched(event, "up"):
|
||||
config.selected_filter_choice = (config.selected_filter_choice - 1) % 2
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "down"):
|
||||
config.selected_filter_choice = (config.selected_filter_choice + 1) % 2
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "confirm"):
|
||||
if config.selected_filter_choice == 0:
|
||||
# Recherche par nom (mode existant)
|
||||
config.search_mode = True
|
||||
config.search_query = ""
|
||||
config.filtered_games = config.games
|
||||
config.current_game = 0
|
||||
config.scroll_offset = 0
|
||||
config.selected_key = (0, 0)
|
||||
config.menu_state = "game"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Entrée en mode recherche par nom")
|
||||
else:
|
||||
# Filtrage avancé
|
||||
from game_filters import GameFilters
|
||||
from rgsx_settings import load_game_filters
|
||||
|
||||
# Initialiser le filtre
|
||||
if not hasattr(config, 'game_filter_obj'):
|
||||
config.game_filter_obj = GameFilters()
|
||||
filter_dict = load_game_filters()
|
||||
if filter_dict:
|
||||
config.game_filter_obj.load_from_dict(filter_dict)
|
||||
|
||||
config.menu_state = "filter_advanced"
|
||||
config.selected_filter_option = 0
|
||||
config.needs_redraw = True
|
||||
logger.debug("Entrée en filtrage avancé")
|
||||
elif is_input_matched(event, "cancel"):
|
||||
config.menu_state = "game"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Retour à la liste des jeux")
|
||||
|
||||
# Filtrage avancé
|
||||
elif config.menu_state == "filter_advanced":
|
||||
from game_filters import GameFilters
|
||||
from rgsx_settings import save_game_filters
|
||||
|
||||
# Initialiser le filtre si nécessaire
|
||||
if not hasattr(config, 'game_filter_obj'):
|
||||
config.game_filter_obj = GameFilters()
|
||||
from rgsx_settings import load_game_filters
|
||||
filter_dict = load_game_filters()
|
||||
if filter_dict:
|
||||
config.game_filter_obj.load_from_dict(filter_dict)
|
||||
|
||||
# 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
|
||||
|
||||
total_items = num_regions + num_other_options + num_buttons
|
||||
|
||||
if is_input_matched(event, "up"):
|
||||
# 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"):
|
||||
# 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"):
|
||||
# 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 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'
|
||||
else:
|
||||
config.game_filter_obj.region_filters[region] = 'include'
|
||||
config.needs_redraw = True
|
||||
logger.debug(f"Filtre région {region} modifié: {config.game_filter_obj.region_filters[region]}")
|
||||
|
||||
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
|
||||
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("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")
|
||||
|
||||
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
|
||||
if 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.menu_state = "game"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Filtres appliqués")
|
||||
|
||||
elif button_idx == 1:
|
||||
# Reset
|
||||
config.game_filter_obj.reset()
|
||||
save_game_filters(config.game_filter_obj.to_dict())
|
||||
config.filtered_games = config.games
|
||||
config.filter_active = False
|
||||
config.needs_redraw = True
|
||||
logger.debug("Filtres réinitialisés")
|
||||
|
||||
elif button_idx == 2:
|
||||
# Back
|
||||
config.menu_state = "game"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Retour sans appliquer les filtres")
|
||||
|
||||
elif is_input_matched(event, "cancel"):
|
||||
config.menu_state = "game"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Annulation du filtrage avancé")
|
||||
|
||||
# Configuration priorité régions
|
||||
elif config.menu_state == "filter_priority_config":
|
||||
from game_filters import GameFilters
|
||||
from rgsx_settings import save_game_filters
|
||||
|
||||
if not hasattr(config, 'game_filter_obj'):
|
||||
config.game_filter_obj = GameFilters()
|
||||
|
||||
priority_list = config.game_filter_obj.region_priority
|
||||
total_items = len(priority_list) + 1 # +1 pour le bouton Back
|
||||
|
||||
if not hasattr(config, 'selected_priority_index'):
|
||||
config.selected_priority_index = 0
|
||||
|
||||
if is_input_matched(event, "up"):
|
||||
config.selected_priority_index = (config.selected_priority_index - 1) % total_items
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "down"):
|
||||
config.selected_priority_index = (config.selected_priority_index + 1) % total_items
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "confirm"):
|
||||
if config.selected_priority_index >= len(priority_list):
|
||||
# Bouton Back : retour au menu filtrage avancé
|
||||
save_game_filters(config.game_filter_obj.to_dict())
|
||||
config.menu_state = "filter_advanced"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Retour au filtrage avancé")
|
||||
elif is_input_matched(event, "left") and config.selected_priority_index < len(priority_list):
|
||||
# Monter la région dans la priorité
|
||||
idx = config.selected_priority_index
|
||||
if idx > 0:
|
||||
priority_list[idx], priority_list[idx-1] = priority_list[idx-1], priority_list[idx]
|
||||
config.selected_priority_index = idx - 1
|
||||
config.needs_redraw = True
|
||||
logger.debug(f"Priorité modifiée: {priority_list}")
|
||||
elif is_input_matched(event, "right") and config.selected_priority_index < len(priority_list):
|
||||
# Descendre la région dans la priorité
|
||||
idx = config.selected_priority_index
|
||||
if idx < len(priority_list) - 1:
|
||||
priority_list[idx], priority_list[idx+1] = priority_list[idx+1], priority_list[idx]
|
||||
config.selected_priority_index = idx + 1
|
||||
config.needs_redraw = True
|
||||
logger.debug(f"Priorité modifiée: {priority_list}")
|
||||
elif is_input_matched(event, "cancel"):
|
||||
# Retour sans sauvegarder
|
||||
config.menu_state = "filter_advanced"
|
||||
config.needs_redraw = True
|
||||
logger.debug("Annulation configuration priorité")
|
||||
|
||||
# Menu filtre plateformes
|
||||
elif config.menu_state == "filter_platforms":
|
||||
total_items = len(config.filter_platforms_selection)
|
||||
action_buttons = 4
|
||||
extended_max = total_items + action_buttons - 1
|
||||
# Indices: 0-3 = boutons, 4+ = liste des systèmes
|
||||
extended_max = action_buttons + total_items - 1
|
||||
if is_input_matched(event, "up"):
|
||||
if config.selected_filter_index > 0:
|
||||
config.selected_filter_index -= 1
|
||||
config.needs_redraw = True
|
||||
else:
|
||||
# Wrap vers les boutons (premier bouton) depuis le haut
|
||||
if total_items > 0:
|
||||
config.selected_filter_index = total_items
|
||||
config.needs_redraw = True
|
||||
# Wrap vers le bas (dernière ligne de la liste)
|
||||
config.selected_filter_index = extended_max
|
||||
config.needs_redraw = True
|
||||
# Activer la répétition automatique
|
||||
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"):
|
||||
if config.selected_filter_index < extended_max:
|
||||
config.selected_filter_index += 1
|
||||
config.needs_redraw = True
|
||||
else:
|
||||
# Wrap retour en haut de la liste
|
||||
# Wrap retour en haut (premier bouton)
|
||||
config.selected_filter_index = 0
|
||||
config.needs_redraw = True
|
||||
# Activer la répétition automatique
|
||||
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"):
|
||||
if config.selected_filter_index >= total_items:
|
||||
if config.selected_filter_index > total_items:
|
||||
# Navigation gauche/droite uniquement pour les boutons (indices 0-3)
|
||||
if config.selected_filter_index < action_buttons:
|
||||
if config.selected_filter_index > 0:
|
||||
config.selected_filter_index -= 1
|
||||
config.needs_redraw = True
|
||||
# sinon ignorer
|
||||
# sinon ignorer (dans la liste)
|
||||
elif is_input_matched(event, "right"):
|
||||
if config.selected_filter_index >= total_items:
|
||||
if config.selected_filter_index < extended_max:
|
||||
# Navigation gauche/droite uniquement pour les boutons (indices 0-3)
|
||||
if config.selected_filter_index < action_buttons:
|
||||
if config.selected_filter_index < action_buttons - 1:
|
||||
config.selected_filter_index += 1
|
||||
config.needs_redraw = True
|
||||
# sinon ignorer
|
||||
# sinon ignorer (dans la liste)
|
||||
elif is_input_matched(event, "confirm"):
|
||||
if config.selected_filter_index < total_items:
|
||||
name, hidden = config.filter_platforms_selection[config.selected_filter_index]
|
||||
config.filter_platforms_selection[config.selected_filter_index] = (name, not hidden)
|
||||
config.filter_platforms_dirty = True
|
||||
config.needs_redraw = True
|
||||
else:
|
||||
btn_idx = config.selected_filter_index - total_items
|
||||
# Indices 0-3 = boutons, 4+ = liste
|
||||
if config.selected_filter_index < action_buttons:
|
||||
# Action sur un bouton
|
||||
btn_idx = config.selected_filter_index
|
||||
settings = load_rgsx_settings()
|
||||
if btn_idx == 0: # all visible
|
||||
config.filter_platforms_selection = [(n, False) for n, _ in config.filter_platforms_selection]
|
||||
@@ -2009,6 +2288,14 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.selected_option = 5
|
||||
config.filter_return_to = None
|
||||
config.needs_redraw = True
|
||||
else:
|
||||
# Action sur un élément de la liste (indices >= action_buttons)
|
||||
list_index = config.selected_filter_index - action_buttons
|
||||
if list_index < total_items:
|
||||
name, hidden = config.filter_platforms_selection[list_index]
|
||||
config.filter_platforms_selection[list_index] = (name, not hidden)
|
||||
config.filter_platforms_dirty = True
|
||||
config.needs_redraw = True
|
||||
elif is_input_matched(event, "cancel"):
|
||||
target = getattr(config, 'filter_return_to', 'pause_menu')
|
||||
config.menu_state = target
|
||||
@@ -2025,13 +2312,32 @@ def handle_controls(event, sources, joystick, screen):
|
||||
# Gestion des relâchements de touches
|
||||
if event.type == pygame.KEYUP:
|
||||
# Vérifier quelle touche a été relâchée
|
||||
# Définir le mapping clavier (même que dans is_input_matched)
|
||||
keyboard_fallback = {
|
||||
"up": pygame.K_UP,
|
||||
"down": pygame.K_DOWN,
|
||||
"left": pygame.K_LEFT,
|
||||
"right": pygame.K_RIGHT,
|
||||
"confirm": pygame.K_RETURN,
|
||||
"cancel": pygame.K_ESCAPE,
|
||||
"page_up": pygame.K_PAGEUP,
|
||||
"page_down": pygame.K_PAGEDOWN,
|
||||
}
|
||||
|
||||
for action_name in ["up", "down", "left", "right", "page_up", "page_down", "confirm", "cancel"]:
|
||||
if config.controls_config.get(action_name, {}).get("type") == "key" and \
|
||||
# Vérifier d'abord le keyboard_fallback
|
||||
if action_name in keyboard_fallback and keyboard_fallback[action_name] == event.key:
|
||||
update_key_state(action_name, False)
|
||||
# Sinon vérifier la config normale
|
||||
elif config.controls_config.get(action_name, {}).get("type") == "key" and \
|
||||
config.controls_config.get(action_name, {}).get("key") == event.key:
|
||||
update_key_state(action_name, False)
|
||||
|
||||
# Gestion spéciale pour confirm dans le menu game
|
||||
if action_name == "confirm" and config.menu_state == "game":
|
||||
# Gestion spéciale pour confirm dans le menu game (ne dépend pas du key_state)
|
||||
if action_name == "confirm" and config.menu_state == "game" and \
|
||||
((action_name in keyboard_fallback and keyboard_fallback[action_name] == event.key) or \
|
||||
(config.controls_config.get(action_name, {}).get("type") == "key" and \
|
||||
config.controls_config.get(action_name, {}).get("key") == event.key)):
|
||||
press_duration = current_time - config.confirm_press_start_time
|
||||
# Si appui court (< 2 secondes) et pas déjà traité par l'appui long
|
||||
if press_duration < config.confirm_long_press_threshold and not config.confirm_long_press_triggered:
|
||||
@@ -2122,9 +2428,11 @@ def handle_controls(event, sources, joystick, screen):
|
||||
for action_name in ["up", "down", "left", "right", "page_up", "page_down", "confirm", "cancel"]:
|
||||
if config.controls_config.get(action_name, {}).get("type") == "button" and \
|
||||
config.controls_config.get(action_name, {}).get("button") == event.button:
|
||||
update_key_state(action_name, False)
|
||||
# Vérifier que cette action était bien activée par un bouton gamepad
|
||||
if action_name in key_states and key_states[action_name].get("event_type") == pygame.JOYBUTTONDOWN:
|
||||
update_key_state(action_name, False)
|
||||
|
||||
# Gestion spéciale pour confirm dans le menu game
|
||||
# Gestion spéciale pour confirm dans le menu game (ne dépend pas du key_state)
|
||||
if action_name == "confirm" and config.menu_state == "game":
|
||||
press_duration = current_time - config.confirm_press_start_time
|
||||
# Si appui court (< 2 secondes) et pas déjà traité par l'appui long
|
||||
@@ -2211,18 +2519,31 @@ def handle_controls(event, sources, joystick, screen):
|
||||
config.confirm_press_start_time = 0
|
||||
config.confirm_long_press_triggered = False
|
||||
|
||||
elif event.type == pygame.JOYAXISMOTION and abs(event.value) < 0.5:
|
||||
# Vérifier quel axe a été relâché
|
||||
for action_name in ["up", "down", "left", "right", "page_up", "page_down"]:
|
||||
if config.controls_config.get(action_name, {}).get("type") == "axis" and \
|
||||
config.controls_config.get(action_name, {}).get("axis") == event.axis:
|
||||
update_key_state(action_name, False)
|
||||
elif event.type == pygame.JOYAXISMOTION:
|
||||
# Détection de relâchement d'axe
|
||||
# Pour les triggers Xbox (axes 4 et 5), relâché = retour à -1.0
|
||||
# Pour les autres axes, relâché = proche de 0
|
||||
is_released = False
|
||||
if event.axis in [4, 5]: # Triggers Xbox
|
||||
is_released = event.value < 0.5 # Relâché si < 0.5 (pas appuyé)
|
||||
else: # Autres axes
|
||||
is_released = abs(event.value) < 0.5
|
||||
|
||||
if is_released:
|
||||
for action_name in ["up", "down", "left", "right", "page_up", "page_down"]:
|
||||
if config.controls_config.get(action_name, {}).get("type") == "axis" and \
|
||||
config.controls_config.get(action_name, {}).get("axis") == event.axis:
|
||||
# Vérifier que cette action était bien activée par cet axe
|
||||
if action_name in key_states and key_states[action_name].get("event_type") == pygame.JOYAXISMOTION:
|
||||
update_key_state(action_name, False)
|
||||
|
||||
elif event.type == pygame.JOYHATMOTION and event.value == (0, 0):
|
||||
# Vérifier quel hat a été relâché
|
||||
for action_name in ["up", "down", "left", "right", "page_up", "page_down"]:
|
||||
if config.controls_config.get(action_name, {}).get("type") == "hat":
|
||||
update_key_state(action_name, False)
|
||||
# Vérifier que cette action était bien activée par un hat
|
||||
if action_name in key_states and key_states[action_name].get("event_type") == pygame.JOYHATMOTION:
|
||||
update_key_state(action_name, False)
|
||||
|
||||
return action
|
||||
|
||||
@@ -2234,11 +2555,9 @@ def update_key_state(action, pressed, event_type=None, event_value=None):
|
||||
if pressed:
|
||||
# La touche vient d'être pressée
|
||||
if action not in key_states:
|
||||
# Ajouter un délai initial pour éviter les doubles actions sur appui court
|
||||
initial_debounce = REPEAT_ACTION_DEBOUNCE
|
||||
key_states[action] = {
|
||||
"pressed": True,
|
||||
"first_press_time": current_time + initial_debounce, # Ajouter un délai initial
|
||||
"first_press_time": current_time,
|
||||
"last_repeat_time": current_time,
|
||||
"event_type": event_type,
|
||||
"event_value": event_value
|
||||
@@ -2305,4 +2624,4 @@ def get_emergency_controls():
|
||||
# manette basique
|
||||
"confirm_joy": {"type": "button", "button": 0},
|
||||
"cancel_joy": {"type": "button", "button": 1},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ from utils import truncate_text_middle, wrap_text, load_system_image, truncate_t
|
||||
import logging
|
||||
import math
|
||||
from history import load_history, is_game_downloaded
|
||||
from language import _
|
||||
from language import _, get_size_units, get_speed_unit
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -193,7 +193,9 @@ THEME_COLORS = {
|
||||
"background_bottom": (60, 80, 100), # noir vers bleu foncé
|
||||
# Fond des cadres
|
||||
"button_idle": (50, 50, 70, 150), # Bleu sombre métal
|
||||
# Fond des boutons sélectionnés dans les popups ou menu
|
||||
# Fond des boutons sélectionnés
|
||||
"button_selected": (70, 70, 100, 200), # Bleu plus clair
|
||||
# Fond des boutons hover dans les popups ou menu
|
||||
"button_hover": (255, 0, 255, 220), # Rose
|
||||
# Générique
|
||||
"text": (255, 255, 255), # blanc
|
||||
@@ -209,6 +211,10 @@ THEME_COLORS = {
|
||||
"title_text": (200, 200, 200), # gris clair
|
||||
# Bordures
|
||||
"border": (150, 150, 150), # Bordures grises subtiles
|
||||
"border_selected": (0, 255, 0), # Bordure verte pour sélection
|
||||
# Couleurs pour filtres
|
||||
"green": (0, 255, 0), # vert
|
||||
"red": (255, 0, 0), # rouge
|
||||
}
|
||||
|
||||
# Général, résolution, overlay
|
||||
@@ -251,7 +257,18 @@ def draw_stylized_button(screen, text, x, y, width, height, selected=False):
|
||||
pygame.draw.rect(glow_surface, THEME_COLORS["fond_lignes"] + (50,), (5, 5, width, height), border_radius=12)
|
||||
screen.blit(glow_surface, (x - 5, y - 5))
|
||||
screen.blit(button_surface, (x, y))
|
||||
|
||||
# Vérifier si le texte dépasse la largeur disponible
|
||||
text_surface = config.font.render(text, True, THEME_COLORS["text"])
|
||||
available_width = width - 20 # Marge de 10px de chaque côté
|
||||
|
||||
if text_surface.get_width() > available_width:
|
||||
# Tronquer le texte avec "..."
|
||||
truncated_text = text
|
||||
while text_surface.get_width() > available_width and len(truncated_text) > 0:
|
||||
truncated_text = truncated_text[:-1]
|
||||
text_surface = config.font.render(truncated_text + "...", True, THEME_COLORS["text"])
|
||||
|
||||
text_rect = text_surface.get_rect(center=(x + width // 2, y + height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
@@ -847,13 +864,19 @@ def draw_game_list(screen):
|
||||
pygame.draw.rect(screen, THEME_COLORS["border"], title_rect_inflated, 2, border_radius=12)
|
||||
screen.blit(title_surface, title_rect)
|
||||
elif config.filter_active:
|
||||
filter_text = _("game_filter").format(config.search_query)
|
||||
title_surface = config.font.render(filter_text, True, THEME_COLORS["fond_lignes"])
|
||||
# Display filter active indicator with count
|
||||
if hasattr(config, 'game_filter_obj') and config.game_filter_obj and config.game_filter_obj.is_active():
|
||||
total_games = len(config.games)
|
||||
filtered_count = len(games)
|
||||
filter_text = _("filter_games_shown").format(filtered_count, total_games)
|
||||
else:
|
||||
filter_text = _("game_filter").format(config.search_query)
|
||||
title_surface = config.font.render(filter_text, True, THEME_COLORS["green"])
|
||||
title_rect = title_surface.get_rect(center=(config.screen_width // 2, title_surface.get_height() // 2 + 20))
|
||||
title_rect_inflated = title_rect.inflate(60, 30)
|
||||
title_rect_inflated.topleft = ((config.screen_width - title_rect_inflated.width) // 2, 10)
|
||||
pygame.draw.rect(screen, THEME_COLORS["button_idle"], title_rect_inflated, border_radius=12)
|
||||
pygame.draw.rect(screen, THEME_COLORS["border"], title_rect_inflated, 2, border_radius=12)
|
||||
pygame.draw.rect(screen, THEME_COLORS["border_selected"], title_rect_inflated, 3, border_radius=12)
|
||||
screen.blit(title_surface, title_rect)
|
||||
else:
|
||||
title_text = _("game_count").format(platform_name, game_count)
|
||||
@@ -956,15 +979,16 @@ def draw_game_scrollbar(screen, scroll_offset, total_items, visible_items, x, y,
|
||||
pygame.draw.rect(screen, THEME_COLORS["fond_lignes"], (x, scrollbar_y, 15, scrollbar_height), border_radius=4)
|
||||
|
||||
def format_size(size):
|
||||
"""Convertit une taille en octets en format lisible."""
|
||||
"""Convertit une taille en octets en format lisible avec unités adaptées à la langue."""
|
||||
if not isinstance(size, (int, float)) or size == 0:
|
||||
return "N/A"
|
||||
|
||||
for unit in ['o', 'Ko', 'Mo', 'Go', 'To']:
|
||||
units = get_size_units()
|
||||
for unit in units[:-1]: # Tous sauf le dernier (Po/PB)
|
||||
if size < 1024.0:
|
||||
return f"{size:.1f} {unit}"
|
||||
size /= 1024.0
|
||||
return f"{size:.1f} Po"
|
||||
return f"{size:.1f} {units[-1]}" # Dernier niveau (Po/PB)
|
||||
|
||||
|
||||
def draw_history_list(screen):
|
||||
@@ -991,7 +1015,7 @@ def draw_history_list(screen):
|
||||
if entry.get("status") in ["Téléchargement", "Downloading"]:
|
||||
speed = entry.get("speed", 0.0)
|
||||
if speed and speed > 0:
|
||||
speed_str = f" - {speed:.2f} Mo/s"
|
||||
speed_str = f" - {speed:.2f} {get_speed_unit()}"
|
||||
break
|
||||
|
||||
screen.blit(OVERLAY, (0, 0))
|
||||
@@ -1036,7 +1060,7 @@ def draw_history_list(screen):
|
||||
if history and history[current_history_item_inverted].get("status") in ["Téléchargement", "Downloading"]:
|
||||
speed = history[current_history_item_inverted].get("speed", 0.0)
|
||||
if speed > 0:
|
||||
speed_str = f"{speed:.2f} Mo/s"
|
||||
speed_str = f"{speed:.2f} {get_speed_unit()}"
|
||||
title_text = _("history_title").format(history_count) + f" {speed_str}"
|
||||
else:
|
||||
title_text = _("history_title").format(history_count)
|
||||
@@ -1669,11 +1693,23 @@ def draw_language_menu(screen):
|
||||
vpad = max(8, min(14, int(title_surface.get_height() * 0.4)))
|
||||
title_bg_rect = title_rect.inflate(hpad, vpad)
|
||||
|
||||
# Dimensions responsives des boutons
|
||||
# Largeur bornée entre 260 et 380px (~40% de la largeur écran)
|
||||
button_width = max(260, min(380, int(config.screen_width * 0.4)))
|
||||
# Hauteur réduite et responsive (env. 5.5% de la hauteur écran), bornée 28..56
|
||||
button_height = max(28, min(56, int(config.screen_height * 0.055)))
|
||||
# Calculer hauteur dynamique basée sur la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
|
||||
# Calculer largeur maximale nécessaire pour les noms de langues
|
||||
max_text_width = 0
|
||||
for lang_code in available_languages:
|
||||
lang_name = get_language_name(lang_code)
|
||||
text_surface = config.font.render(lang_name, True, THEME_COLORS["text"])
|
||||
if text_surface.get_width() > max_text_width:
|
||||
max_text_width = text_surface.get_width()
|
||||
|
||||
# Largeur bornée entre valeur calculée et limites raisonnables
|
||||
button_width = max(260, min(500, max_text_width + 60))
|
||||
# Hauteur réduite et responsive (env. 5.5% de la hauteur écran), bornée mais aussi fonction de la police
|
||||
# Augmenter le padding pour grandes polices
|
||||
button_height = max(28, min(70, max(int(config.screen_height * 0.055), font_height + 20)))
|
||||
# Espacement vertical proportionnel et borné
|
||||
button_spacing = max(8, int(button_height * 0.35))
|
||||
|
||||
@@ -1724,8 +1760,17 @@ def draw_language_menu(screen):
|
||||
pygame.draw.rect(screen, button_color, (button_x, button_y, button_width, button_height), border_radius=10)
|
||||
pygame.draw.rect(screen, THEME_COLORS["border"], (button_x, button_y, button_width, button_height), 2, border_radius=10)
|
||||
|
||||
# Texte du bouton
|
||||
# Texte avec gestion du dépassement
|
||||
text_surface = config.font.render(lang_name, True, THEME_COLORS["text"])
|
||||
available_width = button_width - 20 # Marge de 10px de chaque côté
|
||||
|
||||
if text_surface.get_width() > available_width:
|
||||
# Tronquer le texte avec "..."
|
||||
truncated_text = lang_name
|
||||
while text_surface.get_width() > available_width and len(truncated_text) > 0:
|
||||
truncated_text = truncated_text[:-1]
|
||||
text_surface = config.font.render(truncated_text + "...", True, THEME_COLORS["text"])
|
||||
|
||||
text_rect = text_surface.get_rect(center=(button_x + button_width // 2, button_y + button_height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
@@ -1851,8 +1896,20 @@ def draw_pause_menu(screen, selected_option):
|
||||
_("menu_support"), # 6 -> support
|
||||
_("menu_quit") # 7 -> quit
|
||||
]
|
||||
menu_width = int(config.screen_width * 0.6)
|
||||
button_height = int(config.screen_height * 0.048)
|
||||
# Calculer hauteur dynamique basée sur la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
button_height = max(int(config.screen_height * 0.048), font_height + 20)
|
||||
|
||||
# Calculer largeur maximale nécessaire pour le texte
|
||||
max_text_width = 0
|
||||
for option in options:
|
||||
text_surface = config.font.render(option, True, THEME_COLORS["text"])
|
||||
if text_surface.get_width() > max_text_width:
|
||||
max_text_width = text_surface.get_width()
|
||||
|
||||
# Largeur du menu basée sur le texte le plus long + marges
|
||||
menu_width = min(int(config.screen_width * 0.8), max(int(config.screen_width * 0.5), max_text_width + 80))
|
||||
margin_top_bottom = 24
|
||||
menu_height = len(options) * (button_height + 12) + 2 * margin_top_bottom
|
||||
menu_x = (config.screen_width - menu_width) // 2
|
||||
@@ -1897,8 +1954,23 @@ def draw_pause_menu(screen, selected_option):
|
||||
def _draw_submenu_generic(screen, title, options, selected_index):
|
||||
"""Helper générique pour dessiner un sous-menu hiérarchique."""
|
||||
screen.blit(OVERLAY, (0, 0))
|
||||
menu_width = int(config.screen_width * 0.72)
|
||||
button_height = int(config.screen_height * 0.045)
|
||||
|
||||
# Calculer hauteur dynamique basée sur la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
button_height = max(int(config.screen_height * 0.045), font_height + 18)
|
||||
|
||||
# Calculer largeur maximale nécessaire pour le texte (titre + options)
|
||||
max_text_width = 0
|
||||
title_surface = config.font.render(title, True, THEME_COLORS["text"])
|
||||
max_text_width = title_surface.get_width()
|
||||
for option in options:
|
||||
text_surface = config.font.render(option, True, THEME_COLORS["text"])
|
||||
if text_surface.get_width() > max_text_width:
|
||||
max_text_width = text_surface.get_width()
|
||||
|
||||
# Largeur du menu basée sur le texte le plus long + marges
|
||||
menu_width = min(int(config.screen_width * 0.85), max(int(config.screen_width * 0.55), max_text_width + 80))
|
||||
margin_top_bottom = 26
|
||||
menu_height = (len(options)+1) * (button_height + 10) + 2 * margin_top_bottom # +1 pour le titre
|
||||
menu_x = (config.screen_width - menu_width) // 2
|
||||
@@ -2014,12 +2086,14 @@ def draw_pause_display_menu(screen, selected_index):
|
||||
fam_label = family_map.get(current_family, current_family)
|
||||
font_family_txt = f"{_('submenu_display_font_family') if _ else 'Font'}: < {fam_label} >"
|
||||
|
||||
# Allow unknown extensions
|
||||
allow_unknown = get_allow_unknown_extensions()
|
||||
status_unknown = _('status_on') if allow_unknown else _('status_off')
|
||||
raw_unknown_label = _('submenu_display_allow_unknown_ext') if _ else 'Hide unknown ext warn: {status}'
|
||||
if '{status}' in raw_unknown_label:
|
||||
raw_unknown_label = raw_unknown_label.split('{status}')[0].rstrip(' :')
|
||||
unknown_txt = f"{raw_unknown_label}: < {status_unknown} >"
|
||||
|
||||
back_txt = _("menu_back") if _ else "Back"
|
||||
options = [layout_txt, font_txt, footer_font_txt, font_family_txt, unknown_txt, back_txt]
|
||||
_draw_submenu_generic(screen, _("menu_display"), options, selected_index)
|
||||
@@ -2319,11 +2393,32 @@ def draw_filter_platforms_menu(screen):
|
||||
pygame.draw.rect(screen, THEME_COLORS["border"], title_rect_inflated, 2, border_radius=12)
|
||||
screen.blit(title_surface, title_rect)
|
||||
|
||||
# Zone liste
|
||||
# Boutons d'action en haut (avant la liste)
|
||||
btn_width = 220
|
||||
btn_height = int(config.screen_height * 0.0463)
|
||||
spacing = 30
|
||||
buttons_y = title_rect_inflated.bottom + 20
|
||||
center_x = config.screen_width // 2
|
||||
actions = [
|
||||
("filter_all", 0),
|
||||
("filter_none", 1),
|
||||
("filter_apply", 2),
|
||||
("filter_back", 3)
|
||||
]
|
||||
total_items = len(config.filter_platforms_selection)
|
||||
action_buttons = len(actions)
|
||||
|
||||
for idx, (key, btn_idx) in enumerate(actions):
|
||||
btn_x = center_x - (len(actions) * (btn_width + spacing) - spacing) // 2 + idx * (btn_width + spacing)
|
||||
is_selected = (config.selected_filter_index == btn_idx)
|
||||
label = _(key)
|
||||
draw_stylized_button(screen, label, btn_x, buttons_y, btn_width, btn_height, selected=is_selected)
|
||||
|
||||
# Zone liste (après les boutons)
|
||||
list_width = int(config.screen_width * 0.7)
|
||||
list_height = int(config.screen_height * 0.6)
|
||||
list_height = int(config.screen_height * 0.5)
|
||||
list_x = (config.screen_width - list_width) // 2
|
||||
list_y = title_rect_inflated.bottom + 20
|
||||
list_y = buttons_y + btn_height + 20
|
||||
pygame.draw.rect(screen, THEME_COLORS["button_idle"], (list_x, list_y, list_width, list_height), border_radius=12)
|
||||
pygame.draw.rect(screen, THEME_COLORS["border"], (list_x, list_y, list_width, list_height), 2, border_radius=12)
|
||||
|
||||
@@ -2340,12 +2435,13 @@ def draw_filter_platforms_menu(screen):
|
||||
elif config.selected_filter_index >= config.filter_platforms_scroll_offset + visible_items:
|
||||
config.filter_platforms_scroll_offset = config.selected_filter_index - visible_items + 1
|
||||
|
||||
# Dessiner items
|
||||
# Dessiner items (les indices de la liste commencent à action_buttons)
|
||||
for i in range(config.filter_platforms_scroll_offset, min(config.filter_platforms_scroll_offset + visible_items, total_items)):
|
||||
name, is_hidden = config.filter_platforms_selection[i]
|
||||
idx_on_screen = i - config.filter_platforms_scroll_offset
|
||||
y_center = list_y + 10 + idx_on_screen * line_height + line_height // 2
|
||||
selected = (i == config.selected_filter_index)
|
||||
# Les éléments de la liste ont des indices à partir de action_buttons
|
||||
selected = (config.selected_filter_index == action_buttons + i)
|
||||
checkbox = "[ ]" if is_hidden else "[X]" # inversé: coché signifie visible
|
||||
# Correction: on veut [X] si visible => is_hidden False
|
||||
checkbox = "[X]" if not is_hidden else "[ ]"
|
||||
@@ -2365,37 +2461,12 @@ def draw_filter_platforms_menu(screen):
|
||||
scroll_y = int((config.filter_platforms_scroll_offset / max(1, total_items - visible_items)) * (list_height - 20 - scroll_height))
|
||||
pygame.draw.rect(screen, THEME_COLORS["fond_lignes"], (list_x + list_width - 25, list_y + 10 + scroll_y, 10, scroll_height), border_radius=4)
|
||||
|
||||
# Boutons d'action
|
||||
btn_width = 220
|
||||
btn_height = int(config.screen_height * 0.0463)
|
||||
spacing = 30
|
||||
buttons_y = list_y + list_height + 20
|
||||
center_x = config.screen_width // 2
|
||||
actions = [
|
||||
("filter_all", -2),
|
||||
("filter_none", -3),
|
||||
("filter_apply", -4),
|
||||
("filter_back", -5)
|
||||
]
|
||||
# Indice spécial sélection boutons quand selected_filter_index >= total_items
|
||||
extra_index_base = total_items
|
||||
# Ajuster selected_filter_index max pour inclure boutons
|
||||
extended_max = total_items + len(actions) - 1
|
||||
if config.selected_filter_index > extended_max:
|
||||
config.selected_filter_index = extended_max
|
||||
|
||||
for idx, (key, offset) in enumerate(actions):
|
||||
btn_x = center_x - (len(actions) * (btn_width + spacing) - spacing) // 2 + idx * (btn_width + spacing)
|
||||
is_selected = (config.selected_filter_index == total_items + idx)
|
||||
label = _(key)
|
||||
draw_stylized_button(screen, label, btn_x, buttons_y, btn_width, btn_height, selected=is_selected)
|
||||
|
||||
# Infos bas
|
||||
hidden_count = sum(1 for _, h in config.filter_platforms_selection if h)
|
||||
visible_count = total_items - hidden_count
|
||||
info_text = _("filter_platforms_info").format(visible_count, hidden_count, total_items)
|
||||
info_surface = config.small_font.render(info_text, True, THEME_COLORS["text"])
|
||||
info_rect = info_surface.get_rect(center=(config.screen_width // 2, buttons_y + btn_height + 30))
|
||||
info_rect = info_surface.get_rect(center=(config.screen_width // 2, list_y + list_height + 20))
|
||||
screen.blit(info_surface, info_rect)
|
||||
|
||||
if config.filter_platforms_dirty:
|
||||
@@ -2611,7 +2682,10 @@ def draw_confirm_dialog(screen):
|
||||
wrapped_message = wrap_text(message, config.font, config.screen_width - 80)
|
||||
line_height = config.font.get_height() + 5
|
||||
text_height = len(wrapped_message) * line_height
|
||||
button_height = int(config.screen_height * 0.0463)
|
||||
# Adapter hauteur bouton en fonction de la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
button_height = max(int(config.screen_height * 0.0463), font_height + 15)
|
||||
margin_top_bottom = 20
|
||||
rect_height = text_height + button_height + 2 * margin_top_bottom
|
||||
max_text_width = max([config.font.size(line)[0] for line in wrapped_message], default=300)
|
||||
@@ -2644,7 +2718,10 @@ def draw_reload_games_data_dialog(screen):
|
||||
wrapped_message = wrap_text(message, config.small_font, config.screen_width - 80)
|
||||
line_height = config.small_font.get_height() + 5
|
||||
text_height = len(wrapped_message) * line_height
|
||||
button_height = int(config.screen_height * 0.0463)
|
||||
# Adapter hauteur bouton en fonction de la taille de police
|
||||
sample_text = config.small_font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
button_height = max(int(config.screen_height * 0.0463), font_height + 15)
|
||||
margin_top_bottom = 20
|
||||
rect_height = text_height + button_height + 2 * margin_top_bottom
|
||||
max_text_width = max([config.small_font.size(line)[0] for line in wrapped_message], default=300)
|
||||
@@ -3346,3 +3423,442 @@ def draw_scraper_screen(screen):
|
||||
url_surface = config.small_font.render(url_text, True, THEME_COLORS["title_text"])
|
||||
url_rect = url_surface.get_rect(center=(config.screen_width // 2, rect_y + rect_height - 20))
|
||||
screen.blit(url_surface, url_rect)
|
||||
|
||||
|
||||
def draw_filter_menu_choice(screen):
|
||||
"""Affiche le menu de choix entre recherche par nom et filtrage avancé"""
|
||||
screen.blit(OVERLAY, (0, 0))
|
||||
|
||||
# Titre
|
||||
title = _("filter_menu_title")
|
||||
title_surface = config.title_font.render(title, True, THEME_COLORS["text"])
|
||||
title_rect = title_surface.get_rect(center=(config.screen_width // 2, 60))
|
||||
screen.blit(title_surface, title_rect)
|
||||
|
||||
# Options
|
||||
options = [
|
||||
_("filter_search_by_name"),
|
||||
_("filter_advanced")
|
||||
]
|
||||
|
||||
# Calculer hauteur dynamique basée sur la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
button_height = max(60, font_height + 30)
|
||||
|
||||
# Calculer largeur maximale nécessaire pour le texte
|
||||
max_text_width = 0
|
||||
for option in options:
|
||||
text_surface = config.font.render(option, True, THEME_COLORS["text"])
|
||||
if text_surface.get_width() > max_text_width:
|
||||
max_text_width = text_surface.get_width()
|
||||
|
||||
# Largeur du bouton basée sur le texte le plus long + marges
|
||||
button_width = max(400, max_text_width + 80)
|
||||
|
||||
# Calculer positions
|
||||
menu_y = 150
|
||||
button_spacing = 20
|
||||
|
||||
for i, option in enumerate(options):
|
||||
y = menu_y + i * (button_height + button_spacing)
|
||||
x = (config.screen_width - button_width) // 2
|
||||
|
||||
# Couleur selon sélection
|
||||
if i == config.selected_filter_choice:
|
||||
color = THEME_COLORS["button_selected"]
|
||||
border_color = THEME_COLORS["border_selected"]
|
||||
else:
|
||||
color = THEME_COLORS["button_idle"]
|
||||
border_color = THEME_COLORS["border"]
|
||||
|
||||
# Dessiner bouton
|
||||
pygame.draw.rect(screen, color, (x, y, button_width, button_height), border_radius=12)
|
||||
pygame.draw.rect(screen, border_color, (x, y, button_width, button_height), 3, border_radius=12)
|
||||
|
||||
# Texte avec gestion du dépassement
|
||||
text_surface = config.font.render(option, True, THEME_COLORS["text"])
|
||||
available_width = button_width - 40 # Marge de 20px de chaque côté
|
||||
|
||||
if text_surface.get_width() > available_width:
|
||||
# Tronquer le texte avec "..."
|
||||
truncated_text = option
|
||||
while text_surface.get_width() > available_width and len(truncated_text) > 0:
|
||||
truncated_text = truncated_text[:-1]
|
||||
text_surface = config.font.render(truncated_text + "...", True, THEME_COLORS["text"])
|
||||
|
||||
text_rect = text_surface.get_rect(center=(config.screen_width // 2, y + button_height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
|
||||
def draw_filter_advanced(screen):
|
||||
"""Affiche l'écran de filtrage avancé"""
|
||||
from game_filters import GameFilters
|
||||
|
||||
screen.blit(OVERLAY, (0, 0))
|
||||
|
||||
# Initialiser le filtre si nécessaire
|
||||
if not hasattr(config, 'game_filter_obj'):
|
||||
config.game_filter_obj = GameFilters()
|
||||
# Charger depuis settings
|
||||
from rgsx_settings import load_game_filters
|
||||
filter_dict = load_game_filters()
|
||||
if filter_dict:
|
||||
config.game_filter_obj.load_from_dict(filter_dict)
|
||||
|
||||
# Liste des options (sans les régions pour l'instant)
|
||||
options = []
|
||||
|
||||
# Section Régions (titre seulement)
|
||||
region_title = _("filter_region_title")
|
||||
options.append(('header', region_title))
|
||||
|
||||
# On va afficher les régions en grille 3x3, donc on ajoute des placeholders
|
||||
regions_list = []
|
||||
for region in GameFilters.REGIONS:
|
||||
region_key = f"filter_region_{region.lower()}"
|
||||
region_label = _(region_key)
|
||||
filter_state = config.game_filter_obj.region_filters.get(region, 'include') # Par défaut: include
|
||||
|
||||
if filter_state == 'exclude':
|
||||
status = f"[X] {_('filter_region_exclude')}"
|
||||
color = THEME_COLORS["red"]
|
||||
else: # 'include'
|
||||
status = f"[V] {_('filter_region_include')}"
|
||||
color = THEME_COLORS["green"]
|
||||
|
||||
regions_list.append(('region', region, f"{region_label}: {status}", color))
|
||||
|
||||
# Ajouter les régions comme une seule entrée "grid" dans options
|
||||
options.append(('region_grid', regions_list))
|
||||
|
||||
# Section Autres options
|
||||
options.append(('separator', ''))
|
||||
options.append(('header', _("filter_other_options")))
|
||||
|
||||
hide_text = _("filter_hide_non_release")
|
||||
hide_status = "[X]" if config.game_filter_obj.hide_non_release else "[ ]"
|
||||
options.append(('toggle', 'hide_non_release', f"{hide_text}: {hide_status}"))
|
||||
|
||||
one_rom_text = _("filter_one_rom_per_game")
|
||||
one_rom_status = "[X]" if config.game_filter_obj.one_rom_per_game else "[ ]"
|
||||
# Afficher les 3 premières régions de priorité
|
||||
priority_preview = " → ".join(config.game_filter_obj.region_priority[:3]) + "..."
|
||||
options.append(('toggle', 'one_rom_per_game', f"{one_rom_text}: {one_rom_status}"))
|
||||
options.append(('button_inline', 'priority_config', f"{_('filter_priority_order')}: {priority_preview}"))
|
||||
|
||||
# Boutons d'action (seront affichés séparément en bas)
|
||||
buttons = [
|
||||
('apply', _("filter_apply_filters")),
|
||||
('reset', _("filter_reset_filters")),
|
||||
('back', _("filter_back"))
|
||||
]
|
||||
|
||||
# Afficher les options (sans les boutons)
|
||||
if not hasattr(config, 'selected_filter_option'):
|
||||
config.selected_filter_option = 0
|
||||
|
||||
# Calculer le nombre total d'items sélectionnables (régions individuelles + autres options + boutons)
|
||||
total_items = len(regions_list) + len([opt for opt in options if opt[0] in ['toggle', 'button_inline']]) + len(buttons)
|
||||
if config.selected_filter_option >= total_items:
|
||||
config.selected_filter_option = total_items - 1
|
||||
|
||||
# Calculer d'abord la hauteur totale nécessaire
|
||||
# Adapter la hauteur en fonction de la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
line_height = max(50, font_height + 30)
|
||||
item_height = max(45, font_height + 20)
|
||||
item_spacing_y = 10
|
||||
items_per_row = 3
|
||||
|
||||
# Titre
|
||||
title_height = 60
|
||||
|
||||
# Hauteur du header régions
|
||||
header_height = line_height
|
||||
|
||||
# Hauteur de la grille de régions
|
||||
num_rows = (len(regions_list) + items_per_row - 1) // items_per_row
|
||||
grid_height = num_rows * (item_height + item_spacing_y)
|
||||
|
||||
# Hauteur du séparateur
|
||||
separator_height = 10
|
||||
|
||||
# Hauteur du header autres options
|
||||
header2_height = line_height
|
||||
|
||||
# Hauteur des autres options (3 options)
|
||||
num_other_options = len([opt for opt in options if opt[0] in ['toggle', 'button_inline']])
|
||||
other_options_height = num_other_options * (item_height + 10)
|
||||
|
||||
# Hauteur des boutons
|
||||
# Adapter en fonction de la taille de police
|
||||
sample_text = config.font.render("Sample", True, THEME_COLORS["text"])
|
||||
font_height = sample_text.get_height()
|
||||
button_height = max(50, font_height + 20)
|
||||
buttons_top_margin = 30
|
||||
|
||||
# Hauteur totale du contenu
|
||||
total_content_height = (title_height + header_height + grid_height + separator_height +
|
||||
header2_height + other_options_height + buttons_top_margin + button_height)
|
||||
|
||||
# Calculer position de départ pour centrer verticalement
|
||||
control_bar_estimated_height = 80
|
||||
available_height = config.screen_height - control_bar_estimated_height
|
||||
start_y = (available_height - total_content_height) // 2
|
||||
if start_y < 20:
|
||||
start_y = 20 # Marge minimale du haut
|
||||
|
||||
current_y = start_y
|
||||
|
||||
# Titre
|
||||
title = _("filter_advanced_title")
|
||||
title_surface = config.title_font.render(title, True, THEME_COLORS["text"])
|
||||
title_rect = title_surface.get_rect(center=(config.screen_width // 2, current_y + 20))
|
||||
screen.blit(title_surface, title_rect)
|
||||
current_y += title_height
|
||||
|
||||
region_index_start = 0 # Les régions commencent à l'index 0
|
||||
|
||||
for option in options:
|
||||
option_type = option[0]
|
||||
|
||||
if option_type == 'header':
|
||||
# En-tête de section
|
||||
text_surface = config.font.render(option[1], True, THEME_COLORS["title_text"])
|
||||
text_rect = text_surface.get_rect(center=(config.screen_width // 2, current_y + 20))
|
||||
screen.blit(text_surface, text_rect)
|
||||
current_y += line_height
|
||||
|
||||
elif option_type == 'separator':
|
||||
current_y += separator_height
|
||||
|
||||
elif option_type == 'region_grid':
|
||||
# Afficher les régions en grille 3 par ligne
|
||||
regions_data = option[1]
|
||||
item_spacing_x = 20
|
||||
|
||||
# Calculer la largeur maximale nécessaire pour les boutons de régions
|
||||
max_region_width = 0
|
||||
for region_data in regions_data:
|
||||
text = region_data[2]
|
||||
text_surface = config.font.render(text, True, THEME_COLORS["text"])
|
||||
text_width = text_surface.get_width() + 30 # Padding de 30px
|
||||
if text_width > max_region_width:
|
||||
max_region_width = text_width
|
||||
|
||||
# Largeur minimale de 200px
|
||||
item_width = max(max_region_width, 200)
|
||||
|
||||
# Calculer la largeur totale de la grille
|
||||
total_grid_width = items_per_row * item_width + (items_per_row - 1) * item_spacing_x
|
||||
grid_start_x = (config.screen_width - total_grid_width) // 2
|
||||
|
||||
for idx, region_data in enumerate(regions_data):
|
||||
row = idx // items_per_row
|
||||
col = idx % items_per_row
|
||||
|
||||
x = grid_start_x + col * (item_width + item_spacing_x)
|
||||
y = current_y + row * (item_height + item_spacing_y)
|
||||
|
||||
# Index global de cette région
|
||||
global_idx = region_index_start + idx
|
||||
|
||||
# Couleur selon sélection
|
||||
if global_idx == config.selected_filter_option:
|
||||
bg_color = THEME_COLORS["button_selected"]
|
||||
border_color = THEME_COLORS["border_selected"]
|
||||
else:
|
||||
bg_color = THEME_COLORS["button_idle"]
|
||||
border_color = THEME_COLORS["border"]
|
||||
|
||||
# Dessiner fond
|
||||
pygame.draw.rect(screen, bg_color, (x, y, item_width, item_height), border_radius=8)
|
||||
pygame.draw.rect(screen, border_color, (x, y, item_width, item_height), 2, border_radius=8)
|
||||
|
||||
# Texte centré
|
||||
text = region_data[2]
|
||||
text_color = region_data[3]
|
||||
|
||||
text_surface = config.font.render(text, True, text_color)
|
||||
text_rect = text_surface.get_rect(center=(x + item_width // 2, y + item_height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
# Calculer la hauteur occupée par la grille
|
||||
current_y += num_rows * (item_height + item_spacing_y) + 10
|
||||
|
||||
elif option_type in ['toggle', 'button_inline']:
|
||||
# Option sélectionnable - largeur adaptée au texte
|
||||
text = option[2]
|
||||
text_surface = config.font.render(text, True, THEME_COLORS["text"])
|
||||
text_width = text_surface.get_width()
|
||||
|
||||
# Largeur avec padding
|
||||
width = text_width + 40
|
||||
x = (config.screen_width - width) // 2 # Centrer
|
||||
height = item_height
|
||||
|
||||
# Index global de cette option (après les régions)
|
||||
global_idx = len(regions_list) + len([opt for opt in options[:options.index(option)] if opt[0] in ['toggle', 'button_inline']])
|
||||
|
||||
# Couleur selon sélection
|
||||
if global_idx == config.selected_filter_option:
|
||||
bg_color = THEME_COLORS["button_selected"]
|
||||
border_color = THEME_COLORS["border_selected"]
|
||||
else:
|
||||
bg_color = THEME_COLORS["button_idle"]
|
||||
border_color = THEME_COLORS["border"]
|
||||
|
||||
# Dessiner fond
|
||||
pygame.draw.rect(screen, bg_color, (x, current_y, width, height), border_radius=8)
|
||||
pygame.draw.rect(screen, border_color, (x, current_y, width, height), 2, border_radius=8)
|
||||
|
||||
# Texte centré
|
||||
text_color = THEME_COLORS["text"]
|
||||
text_rect = text_surface.get_rect(center=(x + width // 2, current_y + height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
current_y += height + 10
|
||||
|
||||
# Afficher les 3 boutons côte à côte en bas
|
||||
current_y += buttons_top_margin
|
||||
button_y = current_y
|
||||
button_spacing = 20
|
||||
|
||||
# Calculer la largeur de chaque bouton en fonction du texte
|
||||
button_widths = []
|
||||
for button_id, button_text in buttons:
|
||||
text_surface = config.font.render(button_text, True, THEME_COLORS["text"])
|
||||
button_widths.append(text_surface.get_width() + 40) # Padding de 40px
|
||||
|
||||
# Largeur totale des boutons
|
||||
total_buttons_width = sum(button_widths) + button_spacing * (len(buttons) - 1)
|
||||
button_start_x = (config.screen_width - total_buttons_width) // 2
|
||||
|
||||
# Calculer l'index de début des boutons (après toutes les régions et autres options)
|
||||
button_index_start = len(regions_list) + num_other_options
|
||||
|
||||
current_button_x = button_start_x
|
||||
for i, (button_id, button_text) in enumerate(buttons):
|
||||
button_index = button_index_start + i
|
||||
button_width = button_widths[i]
|
||||
|
||||
# Couleur selon sélection
|
||||
if button_index == config.selected_filter_option:
|
||||
bg_color = THEME_COLORS["button_selected"]
|
||||
border_color = THEME_COLORS["border_selected"]
|
||||
else:
|
||||
bg_color = THEME_COLORS["button_idle"]
|
||||
border_color = THEME_COLORS["border"]
|
||||
|
||||
# Dessiner bouton
|
||||
pygame.draw.rect(screen, bg_color, (current_button_x, button_y, button_width, button_height), border_radius=8)
|
||||
pygame.draw.rect(screen, border_color, (current_button_x, button_y, button_width, button_height), 2, border_radius=8)
|
||||
|
||||
# Texte centré
|
||||
text_surface = config.font.render(button_text, True, THEME_COLORS["text"])
|
||||
text_rect = text_surface.get_rect(center=(current_button_x + button_width // 2, button_y + button_height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
current_button_x += button_width + button_spacing
|
||||
|
||||
# Info filtre actif (au-dessus des boutons)
|
||||
if config.game_filter_obj.is_active():
|
||||
info_text = _("filter_active")
|
||||
info_surface = config.small_font.render(info_text, True, THEME_COLORS["green"])
|
||||
info_rect = info_surface.get_rect(center=(config.screen_width // 2, button_y - 20))
|
||||
screen.blit(info_surface, info_rect)
|
||||
|
||||
|
||||
def draw_filter_priority_config(screen):
|
||||
"""Affiche l'écran de configuration de la priorité des régions pour One ROM per game"""
|
||||
from game_filters import GameFilters
|
||||
|
||||
screen.blit(OVERLAY, (0, 0))
|
||||
|
||||
# Titre
|
||||
title = _("filter_priority_title")
|
||||
title_surface = config.title_font.render(title, True, THEME_COLORS["text"])
|
||||
title_rect = title_surface.get_rect(center=(config.screen_width // 2, 40))
|
||||
screen.blit(title_surface, title_rect)
|
||||
|
||||
# Description
|
||||
desc = _("filter_priority_desc")
|
||||
desc_surface = config.small_font.render(desc, True, THEME_COLORS["title_text"])
|
||||
desc_rect = desc_surface.get_rect(center=(config.screen_width // 2, 85))
|
||||
screen.blit(desc_surface, desc_rect)
|
||||
|
||||
# Initialiser le filtre si nécessaire
|
||||
if not hasattr(config, 'game_filter_obj'):
|
||||
from game_filters import GameFilters
|
||||
from rgsx_settings import load_game_filters
|
||||
config.game_filter_obj = GameFilters()
|
||||
filter_dict = load_game_filters()
|
||||
if filter_dict:
|
||||
config.game_filter_obj.load_from_dict(filter_dict)
|
||||
|
||||
# Liste des régions avec leur priorité
|
||||
start_y = 130
|
||||
line_height = 60
|
||||
|
||||
if not hasattr(config, 'selected_priority_index'):
|
||||
config.selected_priority_index = 0
|
||||
|
||||
priority_list = config.game_filter_obj.region_priority.copy()
|
||||
|
||||
# Afficher chaque région avec sa position
|
||||
for i, region in enumerate(priority_list):
|
||||
y = start_y + i * line_height
|
||||
x = 120
|
||||
width = config.screen_width - 240
|
||||
height = 50
|
||||
|
||||
# Couleur selon sélection
|
||||
if i == config.selected_priority_index:
|
||||
bg_color = THEME_COLORS["button_selected"]
|
||||
border_color = THEME_COLORS["border_selected"]
|
||||
else:
|
||||
bg_color = THEME_COLORS["button_idle"]
|
||||
border_color = THEME_COLORS["border"]
|
||||
|
||||
# Dessiner fond
|
||||
pygame.draw.rect(screen, bg_color, (x, y, width, height), border_radius=8)
|
||||
pygame.draw.rect(screen, border_color, (x, y, width, height), 2, border_radius=8)
|
||||
|
||||
# Numéro de priorité
|
||||
priority_text = f"#{i+1}"
|
||||
priority_surface = config.font.render(priority_text, True, THEME_COLORS["text"])
|
||||
screen.blit(priority_surface, (x + 15, y + (height - priority_surface.get_height()) // 2))
|
||||
|
||||
# Nom de la région (traduit si possible)
|
||||
region_key = f"filter_region_{region.lower()}"
|
||||
region_label = _(region_key)
|
||||
region_surface = config.font.render(region_label, True, THEME_COLORS["text"])
|
||||
screen.blit(region_surface, (x + 80, y + (height - region_surface.get_height()) // 2))
|
||||
|
||||
# Flèches pour réorganiser (si sélectionné)
|
||||
if i == config.selected_priority_index:
|
||||
arrows_text = "← →"
|
||||
arrows_surface = config.font.render(arrows_text, True, THEME_COLORS["green"])
|
||||
screen.blit(arrows_surface, (x + width - 50, y + (height - arrows_surface.get_height()) // 2))
|
||||
|
||||
# Boutons en bas
|
||||
control_bar_estimated_height = 80
|
||||
button_width = 300
|
||||
button_height = 50
|
||||
button_x = (config.screen_width - button_width) // 2
|
||||
button_y = config.screen_height - control_bar_estimated_height - button_height - 20
|
||||
|
||||
# Bouton Back
|
||||
is_button_selected = config.selected_priority_index >= len(priority_list)
|
||||
bg_color = THEME_COLORS["button_selected"] if is_button_selected else THEME_COLORS["button_idle"]
|
||||
border_color = THEME_COLORS["border_selected"] if is_button_selected else THEME_COLORS["border"]
|
||||
|
||||
pygame.draw.rect(screen, bg_color, (button_x, button_y, button_width, button_height), border_radius=8)
|
||||
pygame.draw.rect(screen, border_color, (button_x, button_y, button_width, button_height), 2, border_radius=8)
|
||||
|
||||
back_text = _("filter_back")
|
||||
text_surface = config.font.render(back_text, True, THEME_COLORS["text"])
|
||||
text_rect = text_surface.get_rect(center=(button_x + button_width // 2, button_y + button_height // 2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
|
||||
237
ports/RGSX/game_filters.py
Normal file
237
ports/RGSX/game_filters.py
Normal file
@@ -0,0 +1,237 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Module de filtrage des jeux pour RGSX
|
||||
Partagé entre l'interface graphique et l'interface web
|
||||
"""
|
||||
|
||||
import re
|
||||
import logging
|
||||
from typing import List, Tuple, Dict, Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GameFilters:
|
||||
"""Classe pour gérer les filtres de jeux"""
|
||||
|
||||
# Régions disponibles
|
||||
REGIONS = ['USA', 'Canada', 'Europe', 'France', 'Germany', 'Japan', 'Korea', 'World', 'Other']
|
||||
|
||||
def __init__(self):
|
||||
# Initialiser toutes les régions en mode 'include' par défaut
|
||||
self.region_filters = {region: 'include' for region in self.REGIONS}
|
||||
self.hide_non_release = False
|
||||
self.one_rom_per_game = False
|
||||
self.regex_mode = False
|
||||
self.region_priority = ['USA', 'Canada', 'World', 'Europe', 'Japan', 'Other']
|
||||
|
||||
def load_from_dict(self, filter_dict: Dict[str, Any]):
|
||||
"""Charge les filtres depuis un dictionnaire (depuis settings)"""
|
||||
loaded_region_filters = filter_dict.get('region_filters', {})
|
||||
# Initialiser toutes les régions en 'include' par défaut, puis appliquer celles chargées
|
||||
self.region_filters = {region: 'include' for region in self.REGIONS}
|
||||
self.region_filters.update(loaded_region_filters)
|
||||
|
||||
self.hide_non_release = filter_dict.get('hide_non_release', False)
|
||||
self.one_rom_per_game = filter_dict.get('one_rom_per_game', False)
|
||||
self.regex_mode = filter_dict.get('regex_mode', False)
|
||||
self.region_priority = filter_dict.get('region_priority',
|
||||
['USA', 'Canada', 'World', 'Europe', 'Japan', 'Other'])
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Convertit les filtres en dictionnaire (pour sauvegarder dans settings)"""
|
||||
return {
|
||||
'region_filters': self.region_filters,
|
||||
'hide_non_release': self.hide_non_release,
|
||||
'one_rom_per_game': self.one_rom_per_game,
|
||||
'regex_mode': self.regex_mode,
|
||||
'region_priority': self.region_priority
|
||||
}
|
||||
|
||||
def is_active(self) -> bool:
|
||||
"""Vérifie si des filtres sont actifs (au moins une région en exclude ou options activées)"""
|
||||
has_exclude = any(state == 'exclude' for state in self.region_filters.values())
|
||||
return (has_exclude or
|
||||
self.hide_non_release or
|
||||
self.one_rom_per_game)
|
||||
|
||||
def reset(self):
|
||||
"""Réinitialise tous les filtres (toutes les régions en include)"""
|
||||
self.region_filters = {region: 'include' for region in self.REGIONS}
|
||||
self.hide_non_release = False
|
||||
self.one_rom_per_game = False
|
||||
self.regex_mode = False
|
||||
|
||||
@staticmethod
|
||||
def get_game_regions(game_name: str) -> List[str]:
|
||||
"""Extrait les régions d'un nom de jeu"""
|
||||
name = game_name.upper()
|
||||
regions = []
|
||||
|
||||
# Patterns de région communs
|
||||
if 'USA' in name or 'US)' in name:
|
||||
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 'FRANCE' in name or 'FR)' in name:
|
||||
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 'KOREA' in name or 'KR)' in name or 'KOR)' in name:
|
||||
regions.append('Korea')
|
||||
if 'WORLD' in name:
|
||||
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:
|
||||
regions.append('Other')
|
||||
|
||||
# Si aucune région trouvée
|
||||
if not regions:
|
||||
regions.append('Other')
|
||||
|
||||
return regions
|
||||
|
||||
@staticmethod
|
||||
def is_non_release_game(game_name: str) -> bool:
|
||||
"""Vérifie si un jeu est une version non-release (demo, beta, proto)"""
|
||||
name = game_name.upper()
|
||||
non_release_patterns = [
|
||||
r'\([^\)]*BETA[^\)]*\)',
|
||||
r'\([^\)]*DEMO[^\)]*\)',
|
||||
r'\([^\)]*PROTO[^\)]*\)',
|
||||
r'\([^\)]*SAMPLE[^\)]*\)',
|
||||
r'\([^\)]*KIOSK[^\)]*\)',
|
||||
r'\([^\)]*PREVIEW[^\)]*\)',
|
||||
r'\([^\)]*TEST[^\)]*\)',
|
||||
r'\([^\)]*DEBUG[^\)]*\)',
|
||||
r'\([^\)]*ALPHA[^\)]*\)',
|
||||
r'\([^\)]*PRE-RELEASE[^\)]*\)',
|
||||
r'\([^\)]*PRERELEASE[^\)]*\)',
|
||||
r'\([^\)]*UNFINISHED[^\)]*\)',
|
||||
r'\([^\)]*WIP[^\)]*\)',
|
||||
r'\[[^\]]*BETA[^\]]*\]',
|
||||
r'\[[^\]]*DEMO[^\]]*\]',
|
||||
r'\[[^\]]*TEST[^\]]*\]'
|
||||
]
|
||||
return any(re.search(pattern, name) for pattern in non_release_patterns)
|
||||
|
||||
@staticmethod
|
||||
def get_base_game_name(game_name: str) -> str:
|
||||
"""Obtient le nom de base du jeu (sans régions, versions, etc.)"""
|
||||
base = game_name
|
||||
|
||||
# Supprimer extensions
|
||||
base = re.sub(r'\.(zip|7z|rar|gz|iso)$', '', base, flags=re.IGNORECASE)
|
||||
|
||||
# Extraire info disque si présent
|
||||
disc_info = ''
|
||||
disc_match = (re.search(r'\(Dis[ck]\s*(\d+)\)', base, re.IGNORECASE) or
|
||||
re.search(r'\[Dis[ck]\s*(\d+)\]', base, re.IGNORECASE) or
|
||||
re.search(r'Dis[ck]\s*(\d+)', base, re.IGNORECASE) or
|
||||
re.search(r'\(CD\s*(\d+)\)', base, re.IGNORECASE) or
|
||||
re.search(r'CD\s*(\d+)', base, re.IGNORECASE))
|
||||
if disc_match:
|
||||
disc_info = f' (Disc {disc_match.group(1)})'
|
||||
|
||||
# Supprimer contenu entre parenthèses et crochets
|
||||
base = re.sub(r'\([^)]*\)', '', base)
|
||||
base = re.sub(r'\[[^\]]*\]', '', base)
|
||||
|
||||
# Normaliser espaces
|
||||
base = re.sub(r'\s+', ' ', base).strip()
|
||||
|
||||
# Rajouter info disque
|
||||
base = base + disc_info
|
||||
|
||||
return base
|
||||
|
||||
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()
|
||||
|
||||
for i, region in enumerate(self.region_priority):
|
||||
region_upper = region.upper()
|
||||
if region_upper in name:
|
||||
return i
|
||||
|
||||
return len(self.region_priority) # Autres régions (priorité la plus basse)
|
||||
|
||||
def apply_filters(self, games: List[Tuple]) -> List[Tuple]:
|
||||
"""
|
||||
Applique les filtres à une liste de jeux
|
||||
games: Liste de tuples (game_name, game_url, size)
|
||||
Retourne: Liste filtrée de tuples
|
||||
"""
|
||||
if not self.is_active():
|
||||
return games
|
||||
|
||||
filtered_games = []
|
||||
|
||||
# Filtrage par région
|
||||
for game in games:
|
||||
game_name = game[0]
|
||||
|
||||
# Vérifier les filtres de région
|
||||
if self.region_filters:
|
||||
game_regions = self.get_game_regions(game_name)
|
||||
|
||||
# Vérifier si le jeu a au moins une région incluse
|
||||
has_included_region = False
|
||||
|
||||
for region in game_regions:
|
||||
filter_state = self.region_filters.get(region, 'include')
|
||||
if filter_state == 'include':
|
||||
has_included_region = True
|
||||
break # Si on trouve une région incluse, c'est bon
|
||||
|
||||
# Le jeu est affiché seulement s'il a au moins une région incluse
|
||||
if not has_included_region:
|
||||
continue
|
||||
|
||||
# Filtrer les non-release
|
||||
if self.hide_non_release and self.is_non_release_game(game_name):
|
||||
continue
|
||||
|
||||
filtered_games.append(game)
|
||||
|
||||
# Appliquer "one rom per game"
|
||||
if self.one_rom_per_game:
|
||||
filtered_games = self._apply_one_rom_per_game(filtered_games)
|
||||
|
||||
return filtered_games
|
||||
|
||||
def _apply_one_rom_per_game(self, games: List[Tuple]) -> List[Tuple]:
|
||||
"""Garde seulement une ROM par jeu selon la priorité de région"""
|
||||
games_by_base = {}
|
||||
|
||||
for game in games:
|
||||
game_name = game[0]
|
||||
base_name = self.get_base_game_name(game_name)
|
||||
|
||||
if base_name not in games_by_base:
|
||||
games_by_base[base_name] = []
|
||||
|
||||
games_by_base[base_name].append(game)
|
||||
|
||||
# Pour chaque jeu de base, garder celui avec la meilleure priorité
|
||||
result = []
|
||||
for base_name, game_list in games_by_base.items():
|
||||
if len(game_list) == 1:
|
||||
result.append(game_list[0])
|
||||
else:
|
||||
# Trier par priorité de région
|
||||
sorted_games = sorted(game_list,
|
||||
key=lambda g: self.get_region_priority(g[0]))
|
||||
result.append(sorted_games[0])
|
||||
|
||||
return result
|
||||
@@ -67,6 +67,28 @@ def load_language(lang_code=None):
|
||||
return load_language(DEFAULT_LANGUAGE)
|
||||
return False
|
||||
|
||||
def get_size_units():
|
||||
"""Retourne les unités de taille adaptées à la langue courante.
|
||||
|
||||
Français utilise l'octet (o, Ko, Mo, Go, To, Po)
|
||||
Autres langues utilisent byte (B, KB, MB, GB, TB, PB)
|
||||
"""
|
||||
if current_language == "fr":
|
||||
return ['o', 'Ko', 'Mo', 'Go', 'To', 'Po']
|
||||
else:
|
||||
return ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
|
||||
|
||||
def get_speed_unit():
|
||||
"""Retourne l'unité de vitesse adaptée à la langue courante.
|
||||
|
||||
Français utilise Mo/s
|
||||
Autres langues utilisent MB/s
|
||||
"""
|
||||
if current_language == "fr":
|
||||
return "Mo/s"
|
||||
else:
|
||||
return "MB/s"
|
||||
|
||||
def get_text(key, default=None):
|
||||
"""Récupère la traduction correspondant à la clé en garantissant une chaîne.
|
||||
|
||||
|
||||
@@ -339,7 +339,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}",
|
||||
@@ -367,10 +367,44 @@
|
||||
"web_filter_regex_mode": "Regex-Suche aktivieren",
|
||||
"web_filter_one_rom_per_game": "Eine ROM pro Spiel",
|
||||
"web_filter_configure_priority": "Regions-Prioritätsreihenfolge konfigurieren",
|
||||
"filter_all": "Alles auswählen",
|
||||
"filter_none": "Alles abwählen",
|
||||
"filter_all": "Alle auswählen",
|
||||
"filter_none": "Alle abwählen",
|
||||
"filter_apply": "Filter anwenden",
|
||||
"accessibility_footer_font_size": "Fußzeilenschriftgröße: {0}",
|
||||
"popup_layout_changed_restart": "Layout geändert auf {0}x{1}. Bitte starten Sie die App neu.",
|
||||
"web_started": "Gestartet",
|
||||
"web_downloading": "Download",
|
||||
"web_in_progress": "In Bearbeitung",
|
||||
"web_added_to_queue": "zur Warteschlange hinzugefügt",
|
||||
"web_download_success": "erfolgreich heruntergeladen!",
|
||||
"web_download_error_for": "Fehler beim Herunterladen von",
|
||||
"web_already_present": "war bereits vorhanden",
|
||||
"filter_menu_title": "Filtermenü",
|
||||
"filter_search_by_name": "Nach Namen suchen",
|
||||
"filter_advanced": "Erweiterte Filterung",
|
||||
"filter_advanced_title": "Erweiterte Spielfilterung",
|
||||
"filter_region_title": "Nach Region filtern",
|
||||
"filter_region_include": "Einschließen",
|
||||
"filter_region_exclude": "Ausschließen",
|
||||
"filter_region_usa": "USA",
|
||||
"filter_region_canada": "Kanada",
|
||||
"filter_region_europe": "Europa",
|
||||
"filter_region_france": "Frankreich",
|
||||
"filter_region_germany": "Deutschland",
|
||||
"filter_region_japan": "Japan",
|
||||
"filter_region_korea": "Korea",
|
||||
"filter_region_world": "Welt",
|
||||
"filter_region_other": "Andere",
|
||||
"filter_other_options": "Weitere Optionen",
|
||||
"filter_hide_non_release": "Demos/Betas/Protos ausblenden",
|
||||
"filter_one_rom_per_game": "Eine ROM pro Spiel",
|
||||
"filter_priority_order": "Prioritätsreihenfolge",
|
||||
"filter_priority_title": "Regionsprioritätskonfiguration",
|
||||
"filter_priority_desc": "Prioritätsreihenfolge für \"Eine ROM pro Spiel\" festlegen",
|
||||
"filter_regex_mode": "Regex-Modus",
|
||||
"filter_apply_filters": "Anwenden",
|
||||
"filter_reset_filters": "Zurücksetzen",
|
||||
"filter_back": "Zurück",
|
||||
"accessibility_footer_font_size": "Fußzeilen-Schriftgröße: {0}",
|
||||
"popup_layout_changed_restart": "Layout geändert auf {0}x{1}. Bitte starten Sie die App neu."
|
||||
"filter_active": "Filter aktiv",
|
||||
"filter_games_shown": "{0} Spiel(e) angezeigt"
|
||||
}
|
||||
@@ -341,7 +341,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}",
|
||||
@@ -367,10 +367,44 @@
|
||||
"web_filter_regex_mode": "Enable Regex Search",
|
||||
"web_filter_one_rom_per_game": "One ROM Per Game",
|
||||
"web_filter_configure_priority": "Configure region priority order",
|
||||
"filter_all": "Check All",
|
||||
"filter_none": "Uncheck All",
|
||||
"filter_apply": "Apply Filter",
|
||||
"filter_back": "Back",
|
||||
"filter_all": "Check all",
|
||||
"filter_none": "Uncheck all",
|
||||
"filter_apply": "Apply filter",
|
||||
"accessibility_footer_font_size": "Footer font size: {0}",
|
||||
"popup_layout_changed_restart": "Layout changed to {0}x{1}. Please restart the app to apply."
|
||||
"popup_layout_changed_restart": "Layout changed to {0}x{1}. Please restart the app to apply.",
|
||||
"web_started": "Started",
|
||||
"web_downloading": "Download",
|
||||
"web_in_progress": "In progress",
|
||||
"web_added_to_queue": "added to queue",
|
||||
"web_download_success": "downloaded successfully!",
|
||||
"web_download_error_for": "Error downloading",
|
||||
"web_already_present": "was already present",
|
||||
"filter_menu_title": "Filter Menu",
|
||||
"filter_search_by_name": "Search by name",
|
||||
"filter_advanced": "Advanced filtering",
|
||||
"filter_advanced_title": "Advanced Game Filtering",
|
||||
"filter_region_title": "Filter by region",
|
||||
"filter_region_include": "Include",
|
||||
"filter_region_exclude": "Exclude",
|
||||
"filter_region_usa": "USA",
|
||||
"filter_region_canada": "Canada",
|
||||
"filter_region_europe": "Europe",
|
||||
"filter_region_france": "France",
|
||||
"filter_region_germany": "Germany",
|
||||
"filter_region_japan": "Japan",
|
||||
"filter_region_korea": "Korea",
|
||||
"filter_region_world": "World",
|
||||
"filter_region_other": "Other",
|
||||
"filter_other_options": "Other options",
|
||||
"filter_hide_non_release": "Hide Demos/Betas/Protos",
|
||||
"filter_one_rom_per_game": "One ROM per game",
|
||||
"filter_priority_order": "Priority order",
|
||||
"filter_priority_title": "Region Priority Configuration",
|
||||
"filter_priority_desc": "Set preference order for \"One ROM per game\"",
|
||||
"filter_regex_mode": "Regex Mode",
|
||||
"filter_apply_filters": "Apply",
|
||||
"filter_reset_filters": "Reset",
|
||||
"filter_back": "Back",
|
||||
"filter_active": "Filter active",
|
||||
"filter_games_shown": "{0} game(s) shown"
|
||||
}
|
||||
@@ -341,7 +341,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}",
|
||||
@@ -370,7 +370,41 @@
|
||||
"filter_all": "Marcar todo",
|
||||
"filter_none": "Desmarcar todo",
|
||||
"filter_apply": "Aplicar filtro",
|
||||
"filter_back": "Volver",
|
||||
"accessibility_footer_font_size": "Tamaño fuente pie de página: {0}",
|
||||
"popup_layout_changed_restart": "Diseño cambiado a {0}x{1}. Reinicie la app para aplicar."
|
||||
"popup_layout_changed_restart": "Diseño cambiado a {0}x{1}. Reinicie la app para aplicar.",
|
||||
"web_started": "Iniciado",
|
||||
"web_downloading": "Descarga",
|
||||
"web_in_progress": "En curso",
|
||||
"web_added_to_queue": "añadido a la cola",
|
||||
"web_download_success": "¡descargado con éxito!",
|
||||
"web_download_error_for": "Error al descargar",
|
||||
"web_already_present": "ya estaba presente",
|
||||
"filter_menu_title": "Menú de filtros",
|
||||
"filter_search_by_name": "Buscar por nombre",
|
||||
"filter_advanced": "Filtrado avanzado",
|
||||
"filter_advanced_title": "Filtrado avanzado de juegos",
|
||||
"filter_region_title": "Filtrar por región",
|
||||
"filter_region_include": "Incluir",
|
||||
"filter_region_exclude": "Excluir",
|
||||
"filter_region_usa": "EE.UU.",
|
||||
"filter_region_canada": "Canadá",
|
||||
"filter_region_europe": "Europa",
|
||||
"filter_region_france": "Francia",
|
||||
"filter_region_germany": "Alemania",
|
||||
"filter_region_japan": "Japón",
|
||||
"filter_region_korea": "Corea",
|
||||
"filter_region_world": "Mundial",
|
||||
"filter_region_other": "Otros",
|
||||
"filter_other_options": "Otras opciones",
|
||||
"filter_hide_non_release": "Ocultar Demos/Betas/Protos",
|
||||
"filter_one_rom_per_game": "Una ROM por juego",
|
||||
"filter_priority_order": "Orden de prioridad",
|
||||
"filter_priority_title": "Configuración de prioridad de regiones",
|
||||
"filter_priority_desc": "Definir orden de preferencia para \"Una ROM por juego\"",
|
||||
"filter_regex_mode": "Modo Regex",
|
||||
"filter_apply_filters": "Aplicar",
|
||||
"filter_reset_filters": "Restablecer",
|
||||
"filter_back": "Volver",
|
||||
"filter_active": "Filtro activo",
|
||||
"filter_games_shown": "{0} juego(s) mostrado(s)"
|
||||
}
|
||||
@@ -341,7 +341,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}",
|
||||
@@ -370,7 +370,41 @@
|
||||
"filter_all": "Tout cocher",
|
||||
"filter_none": "Tout décocher",
|
||||
"filter_apply": "Appliquer filtre",
|
||||
"filter_back": "Retour",
|
||||
"accessibility_footer_font_size": "Taille police pied de page : {0}",
|
||||
"popup_layout_changed_restart": "Disposition changée en {0}x{1}. Veuillez redémarrer l'app pour appliquer."
|
||||
"popup_layout_changed_restart": "Disposition changée en {0}x{1}. Veuillez redémarrer l'app pour appliquer.",
|
||||
"web_started": "Démarré",
|
||||
"web_downloading": "Téléchargement",
|
||||
"web_in_progress": "En cours",
|
||||
"web_added_to_queue": "ajouté à la queue",
|
||||
"web_download_success": "téléchargé avec succès!",
|
||||
"web_download_error_for": "Erreur lors du téléchargement de",
|
||||
"web_already_present": "était déjà présent",
|
||||
"filter_menu_title": "Menu Filtrage",
|
||||
"filter_search_by_name": "Recherche par nom",
|
||||
"filter_advanced": "Filtrage avancé",
|
||||
"filter_advanced_title": "Filtrage avancé des jeux",
|
||||
"filter_region_title": "Filtrer par région",
|
||||
"filter_region_include": "Inclure",
|
||||
"filter_region_exclude": "Exclure",
|
||||
"filter_region_usa": "USA",
|
||||
"filter_region_canada": "Canada",
|
||||
"filter_region_europe": "Europe",
|
||||
"filter_region_france": "France",
|
||||
"filter_region_germany": "Allemagne",
|
||||
"filter_region_japan": "Japon",
|
||||
"filter_region_korea": "Corée",
|
||||
"filter_region_world": "Monde",
|
||||
"filter_region_other": "Autres",
|
||||
"filter_other_options": "Autres options",
|
||||
"filter_hide_non_release": "Masquer Démos/Betas/Protos",
|
||||
"filter_one_rom_per_game": "Une ROM par jeu",
|
||||
"filter_priority_order": "Ordre de priorité",
|
||||
"filter_priority_title": "Configuration de la priorité des régions",
|
||||
"filter_priority_desc": "Définir l'ordre de préférence pour \"Une ROM par jeu\"",
|
||||
"filter_regex_mode": "Mode Regex",
|
||||
"filter_apply_filters": "Appliquer",
|
||||
"filter_reset_filters": "Réinitialiser",
|
||||
"filter_back": "Retour",
|
||||
"filter_active": "Filtre actif",
|
||||
"filter_games_shown": "{0} jeu(x) affiché(s)"
|
||||
}
|
||||
@@ -338,7 +338,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}",
|
||||
@@ -370,7 +370,41 @@
|
||||
"filter_all": "Seleziona tutto",
|
||||
"filter_none": "Deseleziona tutto",
|
||||
"filter_apply": "Applica filtro",
|
||||
"filter_back": "Indietro",
|
||||
"accessibility_footer_font_size": "Dimensione carattere piè di pagina: {0}",
|
||||
"popup_layout_changed_restart": "Layout cambiato in {0}x{1}. Riavviare l'app per applicare."
|
||||
"popup_layout_changed_restart": "Layout cambiato a {0}x{1}. Riavvia l'app per applicare.",
|
||||
"web_started": "Avviato",
|
||||
"web_downloading": "Download",
|
||||
"web_in_progress": "In corso",
|
||||
"web_added_to_queue": "aggiunto alla coda",
|
||||
"web_download_success": "scaricato con successo!",
|
||||
"web_download_error_for": "Errore durante il download di",
|
||||
"web_already_present": "era già presente",
|
||||
"filter_menu_title": "Menu filtri",
|
||||
"filter_search_by_name": "Cerca per nome",
|
||||
"filter_advanced": "Filtro avanzato",
|
||||
"filter_advanced_title": "Filtro avanzato giochi",
|
||||
"filter_region_title": "Filtra per regione",
|
||||
"filter_region_include": "Includi",
|
||||
"filter_region_exclude": "Escludi",
|
||||
"filter_region_usa": "USA",
|
||||
"filter_region_canada": "Canada",
|
||||
"filter_region_europe": "Europa",
|
||||
"filter_region_france": "Francia",
|
||||
"filter_region_germany": "Germania",
|
||||
"filter_region_japan": "Giappone",
|
||||
"filter_region_korea": "Corea",
|
||||
"filter_region_world": "Mondo",
|
||||
"filter_region_other": "Altro",
|
||||
"filter_other_options": "Altre opzioni",
|
||||
"filter_hide_non_release": "Nascondi Demo/Beta/Proto",
|
||||
"filter_one_rom_per_game": "Una ROM per gioco",
|
||||
"filter_priority_order": "Ordine di priorità",
|
||||
"filter_priority_title": "Configurazione priorità regioni",
|
||||
"filter_priority_desc": "Imposta ordine di preferenza per \"Una ROM per gioco\"",
|
||||
"filter_regex_mode": "Modalità Regex",
|
||||
"filter_apply_filters": "Applica",
|
||||
"filter_reset_filters": "Reimposta",
|
||||
"filter_back": "Indietro",
|
||||
"filter_active": "Filtro attivo",
|
||||
"filter_games_shown": "{0} gioco/i mostrato/i"
|
||||
}
|
||||
@@ -340,7 +340,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}",
|
||||
@@ -370,7 +370,41 @@
|
||||
"filter_all": "Marcar tudo",
|
||||
"filter_none": "Desmarcar tudo",
|
||||
"filter_apply": "Aplicar filtro",
|
||||
"accessibility_footer_font_size": "Tamanho da fonte do rodapé: {0}",
|
||||
"popup_layout_changed_restart": "Layout alterado para {0}x{1}. Reinicie o app para aplicar.",
|
||||
"web_started": "Iniciado",
|
||||
"web_downloading": "Download",
|
||||
"web_in_progress": "Em andamento",
|
||||
"web_added_to_queue": "adicionado à fila",
|
||||
"web_download_success": "baixado com sucesso!",
|
||||
"web_download_error_for": "Erro ao baixar",
|
||||
"web_already_present": "já estava presente",
|
||||
"filter_menu_title": "Menu de filtros",
|
||||
"filter_search_by_name": "Pesquisar por nome",
|
||||
"filter_advanced": "Filtragem avançada",
|
||||
"filter_advanced_title": "Filtragem avançada de jogos",
|
||||
"filter_region_title": "Filtrar por região",
|
||||
"filter_region_include": "Incluir",
|
||||
"filter_region_exclude": "Excluir",
|
||||
"filter_region_usa": "EUA",
|
||||
"filter_region_canada": "Canadá",
|
||||
"filter_region_europe": "Europa",
|
||||
"filter_region_france": "França",
|
||||
"filter_region_germany": "Alemanha",
|
||||
"filter_region_japan": "Japão",
|
||||
"filter_region_korea": "Coreia",
|
||||
"filter_region_world": "Mundial",
|
||||
"filter_region_other": "Outros",
|
||||
"filter_other_options": "Outras opções",
|
||||
"filter_hide_non_release": "Ocultar Demos/Betas/Protos",
|
||||
"filter_one_rom_per_game": "Uma ROM por jogo",
|
||||
"filter_priority_order": "Ordem de prioridade",
|
||||
"filter_priority_title": "Configuração de prioridade de regiões",
|
||||
"filter_priority_desc": "Definir ordem de preferência para \"Uma ROM por jogo\"",
|
||||
"filter_regex_mode": "Modo Regex",
|
||||
"filter_apply_filters": "Aplicar",
|
||||
"filter_reset_filters": "Redefinir",
|
||||
"filter_back": "Voltar",
|
||||
"accessibility_footer_font_size": "Tamanho fonte rodapé: {0}",
|
||||
"popup_layout_changed_restart": "Layout alterado para {0}x{1}. Reinicie o app para aplicar."
|
||||
"filter_active": "Filtro ativo",
|
||||
"filter_games_shown": "{0} jogo(s) exibido(s)"
|
||||
}
|
||||
@@ -339,3 +339,26 @@ def get_language(settings=None):
|
||||
if settings is None:
|
||||
settings = load_rgsx_settings()
|
||||
return settings.get("language", "en")
|
||||
|
||||
|
||||
def load_game_filters():
|
||||
"""Charge les filtres de jeux depuis rgsx_settings.json."""
|
||||
try:
|
||||
settings = load_rgsx_settings()
|
||||
return settings.get("game_filters", {})
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading game filters: {str(e)}")
|
||||
return {}
|
||||
|
||||
|
||||
def save_game_filters(filters_dict):
|
||||
"""Sauvegarde les filtres de jeux dans rgsx_settings.json."""
|
||||
try:
|
||||
settings = load_rgsx_settings()
|
||||
settings["game_filters"] = filters_dict
|
||||
save_rgsx_settings(settings)
|
||||
logger.debug(f"Game filters saved: {filters_dict}")
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Error saving game filters: {str(e)}")
|
||||
return False
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -460,13 +468,32 @@ class RGSXHandler(BaseHTTPRequestHandler):
|
||||
|
||||
def _send_html(self, html, status=200, etag=None, last_modified=None):
|
||||
"""Envoie une réponse HTML"""
|
||||
self._set_headers('text/html; charset=utf-8', status, etag=etag, last_modified=last_modified)
|
||||
self.wfile.write(html.encode('utf-8'))
|
||||
try:
|
||||
self._set_headers('text/html; charset=utf-8', status, etag=etag, last_modified=last_modified)
|
||||
self.wfile.write(html.encode('utf-8'))
|
||||
except (ConnectionAbortedError, BrokenPipeError) as e:
|
||||
# La connexion a été fermée par le client, ce n'est pas une erreur critique
|
||||
logger.debug(f"Connexion fermée par le client pendant l'envoi HTML: {e}")
|
||||
pass
|
||||
|
||||
def _send_not_found(self):
|
||||
"""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."""
|
||||
@@ -676,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}")
|
||||
@@ -703,10 +730,13 @@ class RGSXHandler(BaseHTTPRequestHandler):
|
||||
|
||||
# Route: API - Traductions
|
||||
elif path == '/api/translations':
|
||||
# Ajouter le code de langue dans les traductions pour que JS puisse l'utiliser
|
||||
translations_with_lang = TRANSLATIONS.copy()
|
||||
translations_with_lang['_language'] = get_language()
|
||||
self._send_json({
|
||||
'success': True,
|
||||
'language': get_language(),
|
||||
'translations': TRANSLATIONS
|
||||
'translations': translations_with_lang
|
||||
})
|
||||
|
||||
# Route: API - Liste des jeux d'une plateforme
|
||||
@@ -714,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
|
||||
]
|
||||
@@ -1461,6 +1494,47 @@ class RGSXHandler(BaseHTTPRequestHandler):
|
||||
'error': str(e)
|
||||
}, status=500)
|
||||
|
||||
# Route: Sauvegarder seulement les filtres (sauvegarde rapide)
|
||||
elif path == '/api/save_filters':
|
||||
try:
|
||||
from rgsx_settings import load_rgsx_settings, save_rgsx_settings
|
||||
|
||||
# Charger les settings actuels
|
||||
current_settings = load_rgsx_settings()
|
||||
|
||||
# Mettre à jour seulement les filtres
|
||||
if 'game_filters' not in current_settings:
|
||||
current_settings['game_filters'] = {}
|
||||
|
||||
current_settings['game_filters']['region_filters'] = data.get('region_filters', {})
|
||||
current_settings['game_filters']['hide_non_release'] = data.get('hide_non_release', False)
|
||||
current_settings['game_filters']['one_rom_per_game'] = data.get('one_rom_per_game', False)
|
||||
current_settings['game_filters']['regex_mode'] = data.get('regex_mode', False)
|
||||
current_settings['game_filters']['region_priority'] = data.get('region_priority', ['USA', 'Canada', 'World', 'Europe', 'Japan', 'Other'])
|
||||
|
||||
# Sauvegarder
|
||||
save_rgsx_settings(current_settings)
|
||||
|
||||
# Mettre à jour config.game_filter_obj
|
||||
if hasattr(config, 'game_filter_obj'):
|
||||
config.game_filter_obj.region_filters = data.get('region_filters', {})
|
||||
config.game_filter_obj.hide_non_release = data.get('hide_non_release', False)
|
||||
config.game_filter_obj.one_rom_per_game = data.get('one_rom_per_game', False)
|
||||
config.game_filter_obj.regex_mode = data.get('regex_mode', False)
|
||||
config.game_filter_obj.region_priority = data.get('region_priority', ['USA', 'Canada', 'World', 'Europe', 'Japan', 'Other'])
|
||||
|
||||
self._send_json({
|
||||
'success': True,
|
||||
'message': 'Filtres sauvegardés'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Erreur lors de la sauvegarde des filtres: {e}")
|
||||
self._send_json({
|
||||
'success': False,
|
||||
'error': str(e)
|
||||
}, status=500)
|
||||
|
||||
# Route: Vider l'historique
|
||||
elif path == '/api/clear-history':
|
||||
try:
|
||||
|
||||
@@ -401,6 +401,55 @@ header p { opacity: 0.9; font-size: 1.1em; }
|
||||
}
|
||||
}
|
||||
|
||||
/* Amélioration de la lisibilité des settings */
|
||||
#settings-content label {
|
||||
display: block;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#settings-content select,
|
||||
#settings-content input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 2px solid #ccc;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
background-color: #f8f8f8;
|
||||
color: #000;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
#settings-content select:focus,
|
||||
#settings-content input[type="text"]:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
#settings-content input[type="checkbox"] {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#settings-content label.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#settings-content label.checkbox-label span {
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#settings-content button {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
header h1 {
|
||||
font-size: 1.5em;
|
||||
@@ -424,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; }
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
@@ -135,6 +182,34 @@
|
||||
return text;
|
||||
}
|
||||
|
||||
// Fonction pour obtenir les unités de taille selon la langue
|
||||
function getSizeUnits() {
|
||||
// Détecter la langue depuis les traductions chargées ou le navigateur
|
||||
const lang = translations['_language'] || navigator.language.substring(0, 2);
|
||||
// Français utilise o, Ko, Mo, Go, To
|
||||
// Autres langues utilisent B, KB, MB, GB, TB
|
||||
return lang === 'fr' ? ['o', 'Ko', 'Mo', 'Go', 'To', 'Po'] : ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||
}
|
||||
|
||||
// Fonction pour obtenir l'unité de vitesse selon la langue
|
||||
function getSpeedUnit() {
|
||||
const lang = translations['_language'] || navigator.language.substring(0, 2);
|
||||
return lang === 'fr' ? 'Mo/s' : 'MB/s';
|
||||
}
|
||||
|
||||
// Fonction pour formater une taille en octets
|
||||
function formatSize(bytes) {
|
||||
if (!bytes || bytes === 0) return 'N/A';
|
||||
const units = getSizeUnits();
|
||||
let size = bytes;
|
||||
let unitIndex = 0;
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024;
|
||||
unitIndex++;
|
||||
}
|
||||
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
||||
}
|
||||
|
||||
// Appliquer les traductions à tous les éléments marqués
|
||||
function applyTranslations() {
|
||||
// Mettre à jour le titre de la page
|
||||
@@ -281,6 +356,9 @@
|
||||
|
||||
// Restaurer l'état depuis l'URL au chargement
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
// Load saved filters first
|
||||
loadSavedFilters();
|
||||
|
||||
const path = window.location.pathname;
|
||||
|
||||
if (path.startsWith('/platform/')) {
|
||||
@@ -450,9 +528,130 @@
|
||||
// Filter state: Map of region -> 'include' or 'exclude'
|
||||
let regionFilters = new Map();
|
||||
|
||||
// Checkbox filter states (stored globally to restore after page changes)
|
||||
let savedHideNonRelease = false;
|
||||
let savedOneRomPerGame = false;
|
||||
let savedRegexMode = false;
|
||||
|
||||
// Region priority order for "One ROM Per Game" (customizable)
|
||||
let regionPriorityOrder = JSON.parse(localStorage.getItem('regionPriorityOrder')) ||
|
||||
['USA', 'Canada', 'World', 'Europe', 'Japan', 'Other'];
|
||||
['USA', 'Canada', 'Europe', 'France', 'Germany', 'Japan', 'Korea', 'World', 'Other'];
|
||||
|
||||
// Save filters to backend
|
||||
async function saveFiltersToBackend() {
|
||||
try {
|
||||
const regionFiltersObj = {};
|
||||
regionFilters.forEach((mode, region) => {
|
||||
regionFiltersObj[region] = mode;
|
||||
});
|
||||
|
||||
// Update saved states from checkboxes if they exist
|
||||
if (document.getElementById('hide-non-release')) {
|
||||
savedHideNonRelease = document.getElementById('hide-non-release').checked;
|
||||
}
|
||||
if (document.getElementById('one-rom-per-game')) {
|
||||
savedOneRomPerGame = document.getElementById('one-rom-per-game').checked;
|
||||
}
|
||||
if (document.getElementById('regex-mode')) {
|
||||
savedRegexMode = document.getElementById('regex-mode').checked;
|
||||
}
|
||||
|
||||
const response = await fetch('/api/save_filters', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
region_filters: regionFiltersObj,
|
||||
hide_non_release: savedHideNonRelease,
|
||||
one_rom_per_game: savedOneRomPerGame,
|
||||
regex_mode: savedRegexMode,
|
||||
region_priority: regionPriorityOrder
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!data.success) {
|
||||
console.warn('Failed to save filters:', data.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to save filters:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Load saved filters from settings
|
||||
async function loadSavedFilters() {
|
||||
try {
|
||||
const response = await fetch('/api/settings');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.settings.game_filters) {
|
||||
const filters = data.settings.game_filters;
|
||||
|
||||
// Load region filters
|
||||
if (filters.region_filters) {
|
||||
regionFilters.clear();
|
||||
Object.entries(filters.region_filters).forEach(([region, mode]) => {
|
||||
regionFilters.set(region, mode);
|
||||
});
|
||||
}
|
||||
|
||||
// Load region priority
|
||||
if (filters.region_priority) {
|
||||
regionPriorityOrder = filters.region_priority;
|
||||
localStorage.setItem('regionPriorityOrder', JSON.stringify(regionPriorityOrder));
|
||||
}
|
||||
|
||||
// Save checkbox states to global variables
|
||||
savedHideNonRelease = filters.hide_non_release || false;
|
||||
savedOneRomPerGame = filters.one_rom_per_game || false;
|
||||
savedRegexMode = filters.regex_mode || false;
|
||||
|
||||
// Load checkboxes when they exist (in games view)
|
||||
if (document.getElementById('hide-non-release')) {
|
||||
document.getElementById('hide-non-release').checked = savedHideNonRelease;
|
||||
}
|
||||
if (document.getElementById('one-rom-per-game')) {
|
||||
document.getElementById('one-rom-per-game').checked = savedOneRomPerGame;
|
||||
}
|
||||
if (document.getElementById('regex-mode')) {
|
||||
document.getElementById('regex-mode').checked = savedRegexMode;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to load saved filters:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore filter button states in the UI
|
||||
function restoreFilterStates() {
|
||||
// Restore region button states
|
||||
regionFilters.forEach((mode, region) => {
|
||||
const btn = document.querySelector(`.region-btn[data-region="${region}"]`);
|
||||
if (btn) {
|
||||
if (mode === 'include') {
|
||||
btn.classList.add('active');
|
||||
btn.classList.remove('excluded');
|
||||
} else if (mode === 'exclude') {
|
||||
btn.classList.remove('active');
|
||||
btn.classList.add('excluded');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Restore checkbox states
|
||||
if (document.getElementById('hide-non-release')) {
|
||||
document.getElementById('hide-non-release').checked = savedHideNonRelease;
|
||||
}
|
||||
if (document.getElementById('one-rom-per-game')) {
|
||||
document.getElementById('one-rom-per-game').checked = savedOneRomPerGame;
|
||||
}
|
||||
if (document.getElementById('regex-mode')) {
|
||||
document.getElementById('regex-mode').checked = savedRegexMode;
|
||||
}
|
||||
|
||||
// Apply filters to display the games correctly
|
||||
applyAllFilters();
|
||||
}
|
||||
|
||||
|
||||
// Helper: Extract region(s) from game name - returns array of regions
|
||||
function getGameRegions(gameName) {
|
||||
@@ -462,12 +661,16 @@
|
||||
// Common region patterns - check all, not just first match
|
||||
// Handle both "(USA)" and "(USA, Europe)" formats
|
||||
if (name.includes('USA') || name.includes('US)')) regions.push('USA');
|
||||
if (name.includes('CANADA')) regions.push('Canada');
|
||||
if (name.includes('EUROPE') || name.includes('EU)')) regions.push('Europe');
|
||||
if (name.includes('FRANCE') || name.includes('FR)')) regions.push('France');
|
||||
if (name.includes('GERMANY') || name.includes('DE)')) regions.push('Germany');
|
||||
if (name.includes('JAPAN') || name.includes('JP)') || name.includes('JPN)')) regions.push('Japan');
|
||||
if (name.includes('KOREA') || name.includes('KR)')) regions.push('Korea');
|
||||
if (name.includes('WORLD')) regions.push('World');
|
||||
|
||||
// Check for other regions
|
||||
if (name.match(/\b(AUSTRALIA|ASIA|KOREA|BRAZIL|CHINA|RUSSIA|SCANDINAVIA|SPAIN|FRANCE|GERMANY|ITALY)\b/)) {
|
||||
// Check for other regions (excluding the ones above)
|
||||
if (name.match(/\b(AUSTRALIA|ASIA|BRAZIL|CHINA|RUSSIA|SCANDINAVIA|SPAIN|ITALY)\b/)) {
|
||||
if (!regions.includes('Other')) regions.push('Other');
|
||||
}
|
||||
|
||||
@@ -550,7 +753,10 @@
|
||||
if (region === 'CANADA' && name.includes('CANADA')) return i;
|
||||
if (region === 'WORLD' && name.includes('WORLD')) return i;
|
||||
if (region === 'EUROPE' && (name.includes('EUROPE') || name.includes('EU)'))) return i;
|
||||
if (region === 'FRANCE' && (name.includes('FRANCE') || name.includes('FR)'))) return i;
|
||||
if (region === 'GERMANY' && (name.includes('GERMANY') || name.includes('DE)'))) return i;
|
||||
if (region === 'JAPAN' && (name.includes('JAPAN') || name.includes('JP)') || name.includes('JPN)'))) return i;
|
||||
if (region === 'KOREA' && (name.includes('KOREA') || name.includes('KR)'))) return i;
|
||||
}
|
||||
|
||||
return regionPriorityOrder.length; // Other regions (lowest priority)
|
||||
@@ -578,6 +784,7 @@
|
||||
[regionPriorityOrder[idx-1], regionPriorityOrder[idx]];
|
||||
saveRegionPriorityOrder();
|
||||
renderRegionPriorityConfig();
|
||||
saveFiltersToBackend();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,14 +796,16 @@
|
||||
[regionPriorityOrder[idx+1], regionPriorityOrder[idx]];
|
||||
saveRegionPriorityOrder();
|
||||
renderRegionPriorityConfig();
|
||||
saveFiltersToBackend();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset region priority to default
|
||||
function resetRegionPriority() {
|
||||
regionPriorityOrder = ['USA', 'Canada', 'World', 'Europe', 'Japan', 'Other'];
|
||||
regionPriorityOrder = ['USA', 'Canada', 'Europe', 'France', 'Germany', 'Japan', 'Korea', 'World', 'Other'];
|
||||
saveRegionPriorityOrder();
|
||||
renderRegionPriorityConfig();
|
||||
saveFiltersToBackend();
|
||||
}
|
||||
|
||||
// Render region priority configuration UI
|
||||
@@ -613,11 +822,11 @@
|
||||
<span style="font-weight: bold; color: #666; min-width: 25px;">${idx + 1}.</span>
|
||||
<span style="flex: 1; font-weight: 500;">${region}</span>
|
||||
<button onclick="moveRegionUp('${region}')"
|
||||
style="padding: 4px 8px; border: 1px solid #ccc; background: white; cursor: pointer; border-radius: 3px;"
|
||||
${idx === 0 ? 'disabled' : ''}>▲</button>
|
||||
style="padding: 4px 8px; border: 1px solid #ccc; background: white; cursor: pointer; border-radius: 3px; font-size: 14px;"
|
||||
${idx === 0 ? 'disabled' : ''}>🔼</button>
|
||||
<button onclick="moveRegionDown('${region}')"
|
||||
style="padding: 4px 8px; border: 1px solid #ccc; background: white; cursor: pointer; border-radius: 3px;"
|
||||
${idx === regionPriorityOrder.length - 1 ? 'disabled' : ''}>▼</button>
|
||||
style="padding: 4px 8px; border: 1px solid #ccc; background: white; cursor: pointer; border-radius: 3px; font-size: 14px;"
|
||||
${idx === regionPriorityOrder.length - 1 ? 'disabled' : ''}>🔽</button>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
@@ -678,14 +887,15 @@
|
||||
}
|
||||
|
||||
applyAllFilters();
|
||||
saveFiltersToBackend();
|
||||
}
|
||||
|
||||
// Apply all filters
|
||||
function applyAllFilters() {
|
||||
const searchInput = document.getElementById('game-search');
|
||||
const searchTerm = searchInput ? searchInput.value : '';
|
||||
const hideNonRelease = document.getElementById('hide-non-release')?.checked || false;
|
||||
const regexMode = document.getElementById('regex-mode')?.checked || false;
|
||||
const hideNonRelease = document.getElementById('hide-non-release')?.checked || savedHideNonRelease;
|
||||
const regexMode = document.getElementById('regex-mode')?.checked || savedRegexMode;
|
||||
|
||||
const items = document.querySelectorAll('.game-item');
|
||||
let visibleCount = 0;
|
||||
@@ -776,7 +986,7 @@
|
||||
});
|
||||
|
||||
// Apply one-rom-per-game filter (after other filters)
|
||||
const oneRomPerGame = document.getElementById('one-rom-per-game')?.checked || false;
|
||||
const oneRomPerGame = document.getElementById('one-rom-per-game')?.checked || savedOneRomPerGame;
|
||||
if (oneRomPerGame) {
|
||||
// Group currently visible games by base name
|
||||
const gameGroups = new Map();
|
||||
@@ -873,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;
|
||||
};
|
||||
@@ -1004,22 +1225,26 @@
|
||||
<div class="filter-row">
|
||||
<span class="filter-label">${t('web_filter_region')}:</span>
|
||||
<button class="region-btn" data-region="USA" onclick="toggleRegionFilter('USA')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1fa-1f1f8.svg" style="width:16px;height:16px" /> USA</button>
|
||||
<button class="region-btn" data-region="Europe" onclick="toggleRegionFilter('Europe')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1ea-1f1fa.svg" style="width:16px;height:16px" /> Europe</button>
|
||||
<button class="region-btn" data-region="Canada" onclick="toggleRegionFilter('Canada')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1e8-1f1e6.svg" style="width:16px;height:16px" /> Canada</button>
|
||||
<button class="region-btn" data-region="Europe" onclick="toggleRegionFilter('Europe')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1ea-1f1fa.svg" style="width:16px;height:16px" /> Europe</button>
|
||||
<button class="region-btn" data-region="France" onclick="toggleRegionFilter('France')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1eb-1f1f7.svg" style="width:16px;height:16px" /> France</button>
|
||||
<button class="region-btn" data-region="Germany" onclick="toggleRegionFilter('Germany')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1e9-1f1ea.svg" style="width:16px;height:16px" /> Germany</button>
|
||||
<button class="region-btn" data-region="Japan" onclick="toggleRegionFilter('Japan')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1ef-1f1f5.svg" style="width:16px;height:16px" /> Japan</button>
|
||||
<button class="region-btn" data-region="Korea" onclick="toggleRegionFilter('Korea')"><img src="https://images.emojiterra.com/google/noto-emoji/unicode-16.0/color/svg/1f1f0-1f1f7.svg" style="width:16px;height:16px" /> Korea</button>
|
||||
<button class="region-btn" data-region="World" onclick="toggleRegionFilter('World')">🌍 World</button>
|
||||
<button class="region-btn" data-region="Other" onclick="toggleRegionFilter('Other')">🌐 Other</button>
|
||||
</div>
|
||||
<div class="filter-row">
|
||||
<label class="filter-checkbox">
|
||||
<input type="checkbox" id="hide-non-release" onchange="applyAllFilters()">
|
||||
<input type="checkbox" id="hide-non-release" onchange="applyAllFilters(); saveFiltersToBackend();">
|
||||
<span>${t('web_filter_hide_non_release')}</span>
|
||||
</label>
|
||||
<label class="filter-checkbox">
|
||||
<input type="checkbox" id="regex-mode" onchange="applyAllFilters()">
|
||||
<input type="checkbox" id="regex-mode" onchange="applyAllFilters(); saveFiltersToBackend();">
|
||||
<span>${t('web_filter_regex_mode')}</span>
|
||||
</label>
|
||||
<label class="filter-checkbox">
|
||||
<input type="checkbox" id="one-rom-per-game" onchange="applyAllFilters()">
|
||||
<input type="checkbox" id="one-rom-per-game" onchange="applyAllFilters(); saveFiltersToBackend();">
|
||||
<span>${t('web_filter_one_rom_per_game')} (<span id="region-priority-display">USA → Canada → World → Europe → Japan → Other</span>)</span>
|
||||
<button onclick="showRegionPriorityConfig()" style="margin-left: 8px; padding: 2px 8px; font-size: 0.9em; background: #666; color: white; border: none; border-radius: 3px; cursor: pointer;" title="${t('web_filter_configure_priority')}">⚙️</button>
|
||||
</label>
|
||||
@@ -1054,6 +1279,9 @@
|
||||
`;
|
||||
container.innerHTML = html;
|
||||
|
||||
// Restore filter states from loaded settings
|
||||
restoreFilterStates();
|
||||
|
||||
// Appliquer le tri par défaut (A-Z)
|
||||
sortGames(currentGameSort);
|
||||
|
||||
@@ -1102,8 +1330,8 @@
|
||||
|
||||
// Afficher un toast de succès (pas de redirection de page)
|
||||
const toastMsg = mode === 'queue'
|
||||
? `📋 "${gameName}" ajouté à la queue`
|
||||
: `⬇️ Téléchargement de "${gameName}" lancé`;
|
||||
? `📋 "${gameName}" ${t('web_added_to_queue')}`
|
||||
: `⬇️ ${t('web_downloading')}: "${gameName}"`;
|
||||
showToast(toastMsg, 'success', 3000);
|
||||
|
||||
} else {
|
||||
@@ -1198,7 +1426,7 @@
|
||||
const speed = info.speed || 0;
|
||||
|
||||
// Utiliser game_name si disponible, sinon extraire de l'URL
|
||||
let fileName = info.game_name || 'Téléchargement';
|
||||
let fileName = info.game_name || t('web_downloading');
|
||||
if (!info.game_name) {
|
||||
try {
|
||||
fileName = decodeURIComponent(url.split('/').pop());
|
||||
@@ -1224,11 +1452,11 @@
|
||||
</div>
|
||||
<div style="display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.9em;">
|
||||
<span>${status} - ${percent.toFixed(1)}%</span>
|
||||
<span>${speed > 0 ? speed.toFixed(2) + ' Mo/s' : ''}</span>
|
||||
<span>${speed > 0 ? speed.toFixed(2) + ' ' + getSpeedUnit() : ''}</span>
|
||||
</div>
|
||||
${total > 0 ? `<div style="font-size: 0.85em; color: #666;">${(downloaded / 1024 / 1024).toFixed(1)} Mo / ${(total / 1024 / 1024).toFixed(1)} Mo</div>` : ''}
|
||||
${total > 0 ? `<div style="font-size: 0.85em; color: #666;">${formatSize(downloaded)} / ${formatSize(total)}</div>` : ''}
|
||||
<div style="margin-top: 3px; font-size: 0.85em; color: #666;">
|
||||
📅 Démarré: ${info.timestamp || 'N/A'}
|
||||
📅 ${t('web_started')}: ${info.timestamp || 'N/A'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1264,10 +1492,10 @@
|
||||
const percent = info.progress_percent || 0;
|
||||
const downloaded = info.downloaded_size || 0;
|
||||
const total = info.total_size || 0;
|
||||
const status = info.status || 'En cours';
|
||||
const status = info.status || t('web_in_progress');
|
||||
const speed = info.speed || 0;
|
||||
|
||||
let fileName = info.game_name || 'Téléchargement';
|
||||
let fileName = info.game_name || t('web_downloading');
|
||||
if (!info.game_name) {
|
||||
try {
|
||||
fileName = decodeURIComponent(url.split('/').pop());
|
||||
@@ -1292,11 +1520,11 @@
|
||||
</div>
|
||||
<div style="display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.9em;">
|
||||
<span>${status} - ${percent.toFixed(1)}%</span>
|
||||
<span>${speed > 0 ? speed.toFixed(2) + ' Mo/s' : ''}</span>
|
||||
<span>${speed > 0 ? speed.toFixed(2) + ' ' + getSpeedUnit() : ''}</span>
|
||||
</div>
|
||||
${total > 0 ? `<div style="font-size: 0.85em; color: #666;">${(downloaded / 1024 / 1024).toFixed(1)} Mo / ${(total / 1024 / 1024).toFixed(1)} Mo</div>` : ''}
|
||||
${total > 0 ? `<div style="font-size: 0.85em; color: #666;">${formatSize(downloaded)} / ${formatSize(total)}</div>` : ''}
|
||||
<div style="margin-top: 3px; font-size: 0.85em; color: #666;">
|
||||
📅 Démarré: ${info.timestamp || 'N/A'}
|
||||
📅 ${t('web_started')}: ${info.timestamp || 'N/A'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1446,13 +1674,13 @@
|
||||
// Si ce téléchargement n'était pas tracké et il est maintenant complété/erreur/etc
|
||||
if (!trackedDownloads[gameKey]) {
|
||||
if (status === 'Download_OK' || status === 'Completed') {
|
||||
showToast(`✅ "${entry.game_name}" téléchargé avec succès!`, 'success', 4000);
|
||||
showToast(`✅ "${entry.game_name}" ${t('web_download_success')}`, 'success', 4000);
|
||||
trackedDownloads[gameKey] = 'completed';
|
||||
} else if (status === 'Erreur' || status === 'error') {
|
||||
showToast(`❌ Erreur lors du téléchargement de "${entry.game_name}"`, 'error', 5000);
|
||||
showToast(`❌ ${t('web_download_error_for')} "${entry.game_name}"`, 'error', 5000);
|
||||
trackedDownloads[gameKey] = 'error';
|
||||
} else if (status === 'Already_Present') {
|
||||
showToast(`ℹ️ "${entry.game_name}" était déjà présent`, 'info', 3000);
|
||||
showToast(`ℹ️ "${entry.game_name}" ${t('web_already_present')}`, 'info', 3000);
|
||||
trackedDownloads[gameKey] = 'already_present';
|
||||
} else if (status === 'Canceled') {
|
||||
// Ne pas afficher de toast pour les téléchargements annulés
|
||||
@@ -1510,8 +1738,8 @@
|
||||
const isCanceled = status === 'Canceled';
|
||||
const isAlreadyPresent = status === 'Already_Present';
|
||||
const isQueued = status === 'Queued';
|
||||
const isDownloading = status === 'Downloading' || status === 'Téléchargement' || status === 'Downloading' ||
|
||||
status === 'Connecting' || status === 'Extracting' || status.startsWith('Try ');
|
||||
const isDownloading = status === 'Downloading' || status === 'Connecting' ||
|
||||
status === 'Extracting' || status.startsWith('Try ');
|
||||
const isSuccess = status === 'Download_OK' || status === 'Completed';
|
||||
|
||||
// Déterminer l'icône et la couleur
|
||||
@@ -1541,7 +1769,7 @@
|
||||
statusText = statusDownloading;
|
||||
}
|
||||
|
||||
const totalMo = h.total_size ? (h.total_size / 1024 / 1024).toFixed(1) : 'N/A';
|
||||
const sizeFormatted = h.total_size ? formatSize(h.total_size) : 'N/A';
|
||||
const platform = h.platform || 'N/A';
|
||||
const timestamp = h.timestamp || 'N/A';
|
||||
|
||||
@@ -1559,7 +1787,7 @@
|
||||
📦 ${platformLabel}: ${platform}
|
||||
</div>
|
||||
<div style="margin-top: 3px; font-size: 0.85em; color: #666;">
|
||||
💾 ${sizeLabel}: ${totalMo} Mo
|
||||
💾 ${sizeLabel}: ${sizeFormatted}
|
||||
</div>
|
||||
<div style="margin-top: 3px; font-size: 0.85em; color: #666;">
|
||||
📅 Date: ${timestamp}
|
||||
@@ -1744,12 +1972,12 @@
|
||||
<h3 style="margin-top: 30px; margin-bottom: 15px;">RGSX Configuration ⚙️</h3>
|
||||
|
||||
<div style="margin-bottom: 20px; background: #f0f8ff; padding: 15px; border-radius: 8px; border: 2px solid #007bff;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 10px; font-size: 1.1em;">📁 ${t('web_settings_roms_folder')}</label>
|
||||
<label style="display: block; margin-bottom: 10px; font-size: 1.1em;">📁 ${t('web_settings_roms_folder')}</label>
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap;">
|
||||
<input type="text" id="setting-roms-folder" value="${settings.roms_folder || ''}"
|
||||
data-translate-placeholder="web_settings_roms_placeholder"
|
||||
placeholder="${t('web_settings_roms_placeholder')}"
|
||||
style="flex: 1; min-width: 200px; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 16px;">
|
||||
style="flex: 1; min-width: 200px;">
|
||||
<button onclick="browseRomsFolder()"
|
||||
style="background: linear-gradient(135deg, #007bff 0%, #0056b3 100%); color: white; border: none; padding: 10px 20px; border-radius: 5px; font-weight: bold; cursor: pointer; white-space: nowrap; flex-shrink: 0;">
|
||||
📂 ${t('web_settings_browse')}
|
||||
@@ -1764,8 +1992,8 @@
|
||||
|
||||
<div style="background: #f9f9f9; padding: 20px; border-radius: 8px;">
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 5px;">🌍 ${t('web_settings_language')}</label>
|
||||
<select id="setting-language" style="width: 100%; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 16px;">
|
||||
<label>🌍 ${t('web_settings_language')}</label>
|
||||
<select id="setting-language">
|
||||
<option value="en" ${settings.language === 'en' ? 'selected' : ''}>English</option>
|
||||
<option value="fr" ${settings.language === 'fr' ? 'selected' : ''}>Français</option>
|
||||
<option value="es" ${settings.language === 'es' ? 'selected' : ''}>Español</option>
|
||||
@@ -1776,23 +2004,22 @@
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: flex; align-items: center; cursor: pointer;">
|
||||
<input type="checkbox" id="setting-music" ${settings.music_enabled ? 'checked' : ''}
|
||||
style="width: 20px; height: 20px; margin-right: 10px;">
|
||||
<span style="font-weight: bold;">🎵 ${t('web_settings_music')}</span>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="setting-music" ${settings.music_enabled ? 'checked' : ''}>
|
||||
<span>🎵 ${t('web_settings_music')}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 5px;">🔤 ${t('web_settings_font_scale')} (${settings.accessibility?.font_scale || 1.0})</label>
|
||||
<label>🔤 ${t('web_settings_font_scale')} (${settings.accessibility?.font_scale || 1.0})</label>
|
||||
<input type="range" id="setting-font-scale" min="0.5" max="2.0" step="0.1"
|
||||
value="${settings.accessibility?.font_scale || 1.0}"
|
||||
style="width: 100%;">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 5px;">📐 ${t('web_settings_grid')}</label>
|
||||
<select id="setting-grid" style="width: 100%; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 16px;">
|
||||
<label>📐 ${t('web_settings_grid')}</label>
|
||||
<select id="setting-grid">
|
||||
<option value="3x3" ${settings.display?.grid === '3x3' ? 'selected' : ''}>3x3</option>
|
||||
<option value="3x4" ${settings.display?.grid === '3x4' ? 'selected' : ''}>3x4</option>
|
||||
<option value="4x3" ${settings.display?.grid === '4x3' ? 'selected' : ''}>4x3</option>
|
||||
@@ -1801,54 +2028,50 @@
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 5px;">🖋️ ${t('web_settings_font_family')}</label>
|
||||
<select id="setting-font-family" style="width: 100%; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 16px;">
|
||||
<label>🖋️ ${t('web_settings_font_family')}</label>
|
||||
<select id="setting-font-family">
|
||||
<option value="pixel" ${settings.display?.font_family === 'pixel' ? 'selected' : ''}>Pixel</option>
|
||||
<option value="dejavu" ${settings.display?.font_family === 'dejavu' ? 'selected' : ''}>DejaVu</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: flex; align-items: center; cursor: pointer;">
|
||||
<input type="checkbox" id="setting-symlink" ${settings.symlink?.enabled ? 'checked' : ''}
|
||||
style="width: 20px; height: 20px; margin-right: 10px;">
|
||||
<span style="font-weight: bold;">🔗 ${t('web_settings_symlink')}</span>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="setting-symlink" ${settings.symlink?.enabled ? 'checked' : ''}>
|
||||
<span>🔗 ${t('web_settings_symlink')}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 5px;">📦 ${t('web_settings_source_mode')}</label>
|
||||
<select id="setting-sources-mode" style="width: 100%; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 16px;">
|
||||
<label>📦 ${t('web_settings_source_mode')}</label>
|
||||
<select id="setting-sources-mode">
|
||||
<option value="rgsx" ${settings.sources?.mode === 'rgsx' ? 'selected' : ''}>RGSX (default)</option>
|
||||
<option value="custom" ${settings.sources?.mode === 'custom' ? 'selected' : ''}>Custom</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: block; font-weight: bold; margin-bottom: 5px;">🔗 ${t('web_settings_custom_url')}</label>
|
||||
<label>🔗 ${t('web_settings_custom_url')}</label>
|
||||
<input type="text" id="setting-custom-url" value="${settings.sources?.custom_url || ''}"
|
||||
data-translate-placeholder="web_settings_custom_url_placeholder"
|
||||
placeholder="${t('web_settings_custom_url_placeholder')}"
|
||||
style="width: 100%; padding: 10px; border: 2px solid #ddd; border-radius: 5px; font-size: 16px;">
|
||||
placeholder="${t('web_settings_custom_url_placeholder')}">
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: flex; align-items: center; cursor: pointer;">
|
||||
<input type="checkbox" id="setting-show-unsupported" ${settings.show_unsupported_platforms ? 'checked' : ''}
|
||||
style="width: 20px; height: 20px; margin-right: 10px;">
|
||||
<span style="font-weight: bold;">👀 ${showUnsupportedLabel}</span>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="setting-show-unsupported" ${settings.show_unsupported_platforms ? 'checked' : ''}>
|
||||
<span>👀 ${showUnsupportedLabel}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<label style="display: flex; align-items: center; cursor: pointer;">
|
||||
<input type="checkbox" id="setting-allow-unknown" ${settings.allow_unknown_extensions ? 'checked' : ''}
|
||||
style="width: 20px; height: 20px; margin-right: 10px;">
|
||||
<span style="font-weight: bold;">⚠️ ${allowUnknownLabel}</span>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="setting-allow-unknown" ${settings.allow_unknown_extensions ? 'checked' : ''}>
|
||||
<span>⚠️ ${allowUnknownLabel}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button onclick="saveSettings()" style="width: 100%; background: linear-gradient(135deg, #28a745 0%, #20c997 100%); color: white; border: none; padding: 15px; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 10px;">
|
||||
<button id="save-settings-btn" style="width: 100%; background: linear-gradient(135deg, #28a745 0%, #20c997 100%); color: white; border: none; padding: 15px; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 10px;">
|
||||
💾 ${t('web_settings_save')}
|
||||
</button>
|
||||
</div>
|
||||
@@ -1860,14 +2083,31 @@
|
||||
label.textContent = `🔤 ${t('web_settings_font_scale')} (${e.target.value})`;
|
||||
});
|
||||
|
||||
// Attacher l'événement de sauvegarde au bouton
|
||||
document.getElementById('save-settings-btn').addEventListener('click', saveSettings);
|
||||
|
||||
} catch (error) {
|
||||
container.innerHTML = `<p style="color:red;">${t('web_error')}: ${error.message}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Sauvegarder les settings
|
||||
async function saveSettings() {
|
||||
async function saveSettings(event) {
|
||||
// Désactiver le bouton pendant la sauvegarde
|
||||
const saveButton = event?.target;
|
||||
const originalText = saveButton?.textContent;
|
||||
if (saveButton) {
|
||||
saveButton.disabled = true;
|
||||
saveButton.textContent = '⏳ Saving...';
|
||||
}
|
||||
|
||||
try {
|
||||
// Collect region filters
|
||||
const regionFiltersObj = {};
|
||||
regionFilters.forEach((mode, region) => {
|
||||
regionFiltersObj[region] = mode;
|
||||
});
|
||||
|
||||
const settings = {
|
||||
language: document.getElementById('setting-language').value,
|
||||
music_enabled: document.getElementById('setting-music').checked,
|
||||
@@ -1887,7 +2127,14 @@
|
||||
},
|
||||
show_unsupported_platforms: document.getElementById('setting-show-unsupported').checked,
|
||||
allow_unknown_extensions: document.getElementById('setting-allow-unknown').checked,
|
||||
roms_folder: document.getElementById('setting-roms-folder').value.trim()
|
||||
roms_folder: document.getElementById('setting-roms-folder').value.trim(),
|
||||
game_filters: {
|
||||
region_filters: regionFiltersObj,
|
||||
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: regionPriorityOrder
|
||||
}
|
||||
};
|
||||
|
||||
const response = await fetch('/api/settings', {
|
||||
@@ -1899,13 +2146,23 @@
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
// Réactiver le bouton
|
||||
if (saveButton) {
|
||||
saveButton.disabled = false;
|
||||
saveButton.textContent = originalText;
|
||||
}
|
||||
// Afficher le dialogue de confirmation de redémarrage
|
||||
showRestartDialog();
|
||||
} else {
|
||||
throw new Error(data.error || t('web_error_unknown'));
|
||||
}
|
||||
} catch (error) {
|
||||
alert('❌ ' + t('web_error_save_settings', error.message));
|
||||
// Réactiver le bouton en cas d'erreur
|
||||
if (saveButton) {
|
||||
saveButton.disabled = false;
|
||||
saveButton.textContent = originalText;
|
||||
}
|
||||
alert('❌ ' + t('web_error_save_settings') + ': ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1976,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');
|
||||
@@ -2019,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) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "2.3.2.1"
|
||||
"version": "2.3.2.8"
|
||||
}
|
||||
Reference in New Issue
Block a user