1
0
forked from Mirrors/RGSX

Optimisation de map_controls et ajout de touches dans controls_mapper.py

This commit is contained in:
skymike03
2025-07-06 20:57:36 +02:00
parent 4b13bb6b6e
commit 6558a5d256

View File

@@ -3,6 +3,7 @@ import json
import os
import logging
import config
from config import CONTROLS_CONFIG_PATH
from display import draw_gradient
logger = logging.getLogger(__name__)
@@ -239,7 +240,15 @@ def get_readable_input_name(event):
return MOUSE_BUTTON_NAMES.get(event.button, f"Souris Bouton {event.button}")
return "Inconnu"
ACTIONS = ["start", "confirm", "cancel"]
def map_controls(screen):
mapping = True
current_action = 0
clock = pygame.time.Clock()
while mapping:
clock.tick(100) # 100 FPS
for event in pygame.event.get():
"""Interface de mappage des contrôles avec validation par maintien de 3 secondes."""
controls_config = load_controls_config()
current_action_index = 0
@@ -399,6 +408,18 @@ def map_controls(screen):
save_controls_config(controls_config)
config.controls_config = controls_config
return True
pass
def save_controls_config(config):
"""Enregistre la configuration des contrôles dans un fichier JSON."""
try:
with open(CONTROLS_CONFIG_PATH, "w") as f:
json.dump(config, f, indent=4)
logging.debug("Configuration des contrôles enregistrée")
except Exception as e:
logging.error(f"Erreur lors de l'enregistrement de controls.json : {e}")
return False
return True
def draw_controls_mapping(screen, action, last_input, waiting_for_input, hold_progress):
"""Affiche l'interface de mappage des contrôles avec une barre de progression pour le maintien."""