Problemas resueltos: - Texto demasiado pequeño en resoluciones 2K/4K (1440p mostraba 36-41px) - Archivos generados (resources.pack, *.zip) siendo versionados - Carpetas temporales de empaquetado sin ignorar Cambios realizados: 1. UIManager: Escalado más agresivo para resoluciones altas - Proporción mejorada: 1/40 → 1/26 (incremento ~35%) - Límite máximo: 36px → 72px - Resultados: 1080p→42px, 1440p→55px, 2160p→72px - Resoluciones bajas sin cambios (10-18px) 2. .gitignore: Excluir archivos generados y temporales - resources.pack (archivo empaquetado) - Archivos de distribución (*.zip, *.dmg, *.tar.gz, *.AppImage) - Carpetas temporales (vibe3_release/, Frameworks/) - Binarios de herramientas (tools/*.exe) 3. defines.hpp: Resolución por defecto actualizada - 640x360 (zoom 2x) → 1280x720 (zoom 1x) Resultado: - Texto significativamente más legible en pantallas grandes - Repositorio limpio sin archivos generados 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
187 lines
7.0 KiB
C++
187 lines
7.0 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL_stdinc.h> // for Uint64
|
|
#include <string> // for std::string
|
|
|
|
// Forward declarations
|
|
struct SDL_Renderer;
|
|
class SceneManager;
|
|
class Shape;
|
|
class ThemeManager;
|
|
class TextRenderer;
|
|
class Notifier;
|
|
class HelpOverlay;
|
|
class Engine;
|
|
enum class SimulationMode;
|
|
enum class AppMode;
|
|
|
|
/**
|
|
* @class UIManager
|
|
* @brief Gestiona toda la interfaz de usuario (HUD, FPS, debug, notificaciones)
|
|
*
|
|
* Responsabilidad única: Renderizado y actualización de elementos UI
|
|
*
|
|
* Características:
|
|
* - HUD de debug (gravedad, velocidad, FPS, V-Sync)
|
|
* - Contador de FPS en tiempo real
|
|
* - Sistema de notificaciones (Notifier)
|
|
* - Texto obsoleto (sistema legacy)
|
|
* - Gestión de TextRenderers
|
|
*/
|
|
class UIManager {
|
|
public:
|
|
/**
|
|
* @brief Constructor
|
|
*/
|
|
UIManager();
|
|
|
|
/**
|
|
* @brief Destructor - Libera TextRenderers y Notifier
|
|
*/
|
|
~UIManager();
|
|
|
|
/**
|
|
* @brief Inicializa el UIManager con recursos SDL
|
|
* @param renderer Renderizador SDL3
|
|
* @param theme_manager Gestor de temas (para colores)
|
|
* @param physical_width Ancho físico de ventana (píxeles reales)
|
|
* @param physical_height Alto físico de ventana (píxeles reales)
|
|
* @param logical_width Ancho lógico (resolución interna)
|
|
* @param logical_height Alto lógico (resolución interna)
|
|
*/
|
|
void initialize(SDL_Renderer* renderer, ThemeManager* theme_manager,
|
|
int physical_width, int physical_height,
|
|
int logical_width, int logical_height);
|
|
|
|
/**
|
|
* @brief Actualiza UI (FPS counter, notificaciones, texto obsoleto)
|
|
* @param current_time Tiempo actual en milisegundos (SDL_GetTicks)
|
|
* @param delta_time Delta time en segundos
|
|
*/
|
|
void update(Uint64 current_time, float delta_time);
|
|
|
|
/**
|
|
* @brief Renderiza todos los elementos UI
|
|
* @param renderer Renderizador SDL3
|
|
* @param engine Puntero a Engine (para info de sistema)
|
|
* @param scene_manager SceneManager (para info de debug)
|
|
* @param current_mode Modo de simulación actual (PHYSICS/SHAPE)
|
|
* @param current_app_mode Modo de aplicación (SANDBOX/DEMO/LOGO)
|
|
* @param active_shape Figura 3D activa (para nombre en debug)
|
|
* @param shape_convergence % de convergencia en LOGO mode (0.0-1.0)
|
|
* @param physical_width Ancho físico de ventana (para texto absoluto)
|
|
* @param physical_height Alto físico de ventana (para texto absoluto)
|
|
* @param current_screen_width Ancho lógico de pantalla (para texto centrado)
|
|
*/
|
|
void render(SDL_Renderer* renderer,
|
|
const Engine* engine,
|
|
const SceneManager* scene_manager,
|
|
SimulationMode current_mode,
|
|
AppMode current_app_mode,
|
|
const Shape* active_shape,
|
|
float shape_convergence,
|
|
int physical_width,
|
|
int physical_height,
|
|
int current_screen_width);
|
|
|
|
/**
|
|
* @brief Toggle del debug HUD (tecla F12)
|
|
*/
|
|
void toggleDebug();
|
|
|
|
/**
|
|
* @brief Toggle del overlay de ayuda (tecla H)
|
|
*/
|
|
void toggleHelp();
|
|
|
|
/**
|
|
* @brief Muestra una notificación en pantalla
|
|
* @param text Texto a mostrar
|
|
* @param duration Duración en milisegundos (0 = usar default)
|
|
*/
|
|
void showNotification(const std::string& text, Uint64 duration = 0);
|
|
|
|
/**
|
|
* @brief Actualiza texto de V-Sync en HUD
|
|
* @param enabled true si V-Sync está activado
|
|
*/
|
|
void updateVSyncText(bool enabled);
|
|
|
|
/**
|
|
* @brief Actualiza tamaño físico de ventana (cambios de fullscreen)
|
|
* @param width Nuevo ancho físico
|
|
* @param height Nuevo alto físico
|
|
*/
|
|
void updatePhysicalWindowSize(int width, int height);
|
|
|
|
// === Getters ===
|
|
|
|
/**
|
|
* @brief Verifica si debug HUD está activo
|
|
*/
|
|
bool isDebugActive() const { return show_debug_; }
|
|
|
|
/**
|
|
* @brief Obtiene FPS actual
|
|
*/
|
|
int getCurrentFPS() const { return fps_current_; }
|
|
|
|
private:
|
|
/**
|
|
* @brief Renderiza HUD de debug (solo si show_debug_ == true)
|
|
* @param engine Puntero a Engine (para info de sistema)
|
|
* @param scene_manager SceneManager (para info de pelotas)
|
|
* @param current_mode Modo de simulación (PHYSICS/SHAPE)
|
|
* @param current_app_mode Modo de aplicación (SANDBOX/DEMO/LOGO)
|
|
* @param active_shape Figura 3D activa (puede ser nullptr)
|
|
* @param shape_convergence % de convergencia en LOGO mode
|
|
*/
|
|
void renderDebugHUD(const Engine* engine,
|
|
const SceneManager* scene_manager,
|
|
SimulationMode current_mode,
|
|
AppMode current_app_mode,
|
|
const Shape* active_shape,
|
|
float shape_convergence);
|
|
|
|
/**
|
|
* @brief Convierte dirección de gravedad a string
|
|
* @param direction Dirección como int (cast de GravityDirection)
|
|
* @return String en español ("Abajo", "Arriba", etc.)
|
|
*/
|
|
std::string gravityDirectionToString(int direction) const;
|
|
|
|
/**
|
|
* @brief Calcula tamaño de fuente apropiado según dimensiones lógicas
|
|
* @param logical_height Alto lógico (resolución interna, sin zoom)
|
|
* @return Tamaño de fuente (9-72px)
|
|
*/
|
|
int calculateFontSize(int logical_height) const;
|
|
|
|
// === Recursos de renderizado ===
|
|
TextRenderer* text_renderer_debug_; // HUD de debug
|
|
TextRenderer* text_renderer_notifier_; // Notificaciones
|
|
Notifier* notifier_; // Sistema de notificaciones
|
|
HelpOverlay* help_overlay_; // Overlay de ayuda (tecla H)
|
|
|
|
// === Estado de UI ===
|
|
bool show_debug_; // HUD de debug activo (tecla F12)
|
|
|
|
// === Sistema de FPS ===
|
|
Uint64 fps_last_time_; // Último tiempo de actualización de FPS
|
|
int fps_frame_count_; // Contador de frames
|
|
int fps_current_; // FPS actual
|
|
std::string fps_text_; // Texto "fps: XX"
|
|
std::string vsync_text_; // Texto "V-Sync: On/Off"
|
|
|
|
// === Referencias externas ===
|
|
SDL_Renderer* renderer_; // Renderizador SDL3 (referencia)
|
|
ThemeManager* theme_manager_; // Gestor de temas (para colores)
|
|
int physical_window_width_; // Ancho físico de ventana (píxeles reales)
|
|
int physical_window_height_; // Alto físico de ventana (píxeles reales)
|
|
int logical_window_width_; // Ancho lógico (resolución interna)
|
|
int logical_window_height_; // Alto lógico (resolución interna)
|
|
|
|
// === Sistema de escalado dinámico de texto ===
|
|
int current_font_size_; // Tamaño de fuente actual (9-72px)
|
|
};
|