From 6aacb86d6ae641e53c4754c48e7f5ca885ff9909 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 12 Oct 2025 05:36:44 +0200 Subject: [PATCH] Fix: Mejoras de UX en modo boids (auto-exit + screen size) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implementadas 2 mejoras críticas para modo boids: **1. Auto-exit de boids al activar gravedad (G/cursores):** - handleGravityToggle(): Sale a PHYSICS si está en BOIDS - handleGravityDirectionChange(): Sale a PHYSICS y aplica dirección - Razón: La gravedad es conceptualmente incompatible con boids - UX esperada: Usuario pulsa G → vuelve automáticamente a física **2. Update screen size en F4 (real fullscreen):** - toggleRealFullscreen() ahora llama a boid_manager_->updateScreenSize() - Corrige bug: Boids no respetaban nuevas dimensiones tras F4 - Wrapping boundaries ahora se actualizan correctamente Cambios: - engine.cpp: Añadida comprobación de BOIDS en métodos de gravedad - engine.cpp: Actualización de boid_manager en F4 (línea 420) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- source/engine.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/engine.cpp b/source/engine.cpp index b4f6e2b..8a918c8 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -340,6 +340,12 @@ void Engine::update() { // Gravedad y física void Engine::handleGravityToggle() { + // Si estamos en modo boids, salir a modo física primero + if (current_mode_ == SimulationMode::BOIDS) { + toggleBoidsMode(); // Esto cambia a PHYSICS y activa gravedad + return; // La notificación ya se muestra en toggleBoidsMode + } + // Si estamos en modo figura, salir a modo física SIN GRAVEDAD if (current_mode_ == SimulationMode::SHAPE) { toggleShapeModeInternal(false); // Desactivar figura sin forzar gravedad ON @@ -354,6 +360,12 @@ void Engine::handleGravityToggle() { } void Engine::handleGravityDirectionChange(GravityDirection direction, const char* notification_text) { + // Si estamos en modo boids, salir a modo física primero + if (current_mode_ == SimulationMode::BOIDS) { + toggleBoidsMode(); // Esto cambia a PHYSICS y activa gravedad + // Continuar para aplicar la dirección de gravedad + } + // Si estamos en modo figura, salir a modo física CON gravedad if (current_mode_ == SimulationMode::SHAPE) { toggleShapeModeInternal(); // Desactivar figura (activa gravedad automáticamente) @@ -754,6 +766,9 @@ void Engine::toggleRealFullscreen() { // Reinicar la escena con nueva resolución scene_manager_->updateScreenSize(current_screen_width_, current_screen_height_); scene_manager_->changeScenario(scene_manager_->getCurrentScenario()); + + // Actualizar tamaño de pantalla para boids (wrapping boundaries) + boid_manager_->updateScreenSize(current_screen_width_, current_screen_height_); } SDL_free(displays); }