Tres correcciones importantes para el Help Overlay: 1. Solapamiento de columnas corregido: - Añadidos column1_width_ y column2_width_ para anchos reales - calculateTextDimensions() ahora incluye encabezados en cálculo - rebuildCachedTexture() usa anchos reales de columnas - Columna 2 empieza en padding + column1_width_ + padding - Elimina cálculo erróneo column_width = (box_width_ - padding*3)/2 2. Layout en alta resolución corregido: - Eliminado ancho mínimo forzado del 90% de dimensión menor - box_width_ ahora usa directamente text_width (justo lo necesario) - Antes: 1920x1080 → min 972px aunque contenido necesite 600px - Ahora: box ajustado al contenido sin espacio vacío extra 3. Fullscreen/resize corregido: - reinitializeFontSize() ya NO llama a calculateBoxDimensions() - Evita recalcular con physical_width_ y physical_height_ antiguos - Confía en updatePhysicalWindowSize() que se llama después - Antes: textura cacheada creada con dimensiones incorrectas - Ahora: textura siempre creada con dimensiones correctas Resultado: - Columnas no se montan entre sí - Box ajustado al contenido sin espacio vacío derecha - Cambios fullscreen/ventana funcionan correctamente - Overlay se recalcula apropiadamente en todos los casos 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
97 lines
2.8 KiB
C++
97 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class ThemeManager;
|
|
class TextRenderer;
|
|
|
|
/**
|
|
* @class HelpOverlay
|
|
* @brief Overlay de ayuda con listado de controles de teclado
|
|
*
|
|
* Muestra un recuadro cuadrado centrado con todas las teclas y sus funciones.
|
|
* Usa los colores del tema actual (como las notificaciones).
|
|
* Toggle on/off con tecla H. La simulación continúa en el fondo.
|
|
*/
|
|
class HelpOverlay {
|
|
public:
|
|
HelpOverlay();
|
|
~HelpOverlay();
|
|
|
|
/**
|
|
* @brief Inicializa el overlay con renderer y theme manager
|
|
*/
|
|
void initialize(SDL_Renderer* renderer, ThemeManager* theme_mgr, int physical_width, int physical_height, int font_size);
|
|
|
|
/**
|
|
* @brief Renderiza el overlay si está visible
|
|
*/
|
|
void render(SDL_Renderer* renderer);
|
|
|
|
/**
|
|
* @brief Actualiza dimensiones físicas de ventana (zoom, fullscreen, etc.)
|
|
*/
|
|
void updatePhysicalWindowSize(int physical_width, int physical_height);
|
|
|
|
/**
|
|
* @brief Reinitializa el tamaño de fuente (cuando cambia el tamaño de ventana)
|
|
*/
|
|
void reinitializeFontSize(int new_font_size);
|
|
|
|
/**
|
|
* @brief Toggle visibilidad del overlay
|
|
*/
|
|
void toggle() { visible_ = !visible_; }
|
|
|
|
/**
|
|
* @brief Consulta si el overlay está visible
|
|
*/
|
|
bool isVisible() const { return visible_; }
|
|
|
|
private:
|
|
SDL_Renderer* renderer_;
|
|
ThemeManager* theme_mgr_;
|
|
TextRenderer* text_renderer_; // Renderer de texto para la ayuda
|
|
int physical_width_;
|
|
int physical_height_;
|
|
bool visible_;
|
|
|
|
// Dimensiones calculadas del recuadro (anchura dinámica según texto, centrado)
|
|
int box_width_;
|
|
int box_height_;
|
|
int box_x_;
|
|
int box_y_;
|
|
|
|
// Anchos individuales de cada columna (para evitar solapamiento)
|
|
int column1_width_;
|
|
int column2_width_;
|
|
|
|
// Sistema de caché para optimización de rendimiento
|
|
SDL_Texture* cached_texture_; // Textura cacheada del overlay completo
|
|
SDL_Color last_category_color_; // Último color de categorías renderizado
|
|
SDL_Color last_content_color_; // Último color de contenido renderizado
|
|
SDL_Color last_bg_color_; // Último color de fondo renderizado
|
|
bool texture_needs_rebuild_; // Flag para forzar regeneración de textura
|
|
|
|
// Calcular dimensiones del texto más largo
|
|
void calculateTextDimensions(int& max_width, int& total_height);
|
|
|
|
// Calcular dimensiones del recuadro según tamaño de ventana y texto
|
|
void calculateBoxDimensions();
|
|
|
|
// Regenerar textura cacheada del overlay
|
|
void rebuildCachedTexture();
|
|
|
|
// Estructura para par tecla-descripción
|
|
struct KeyBinding {
|
|
const char* key;
|
|
const char* description;
|
|
};
|
|
|
|
// Lista de todos los controles (se llena en constructor)
|
|
std::vector<KeyBinding> key_bindings_;
|
|
};
|