forked from Mirrors/RGSX
Optimisation de map_controls et ajout de touches dans controls_mapper.py
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user