Help Overlay: implementación preliminar

This commit is contained in:
2025-10-12 07:02:22 +02:00
parent 35f29340db
commit 18a8812ad7
7 changed files with 362 additions and 8 deletions

76
source/ui/help_overlay.h Normal file
View File

@@ -0,0 +1,76 @@
#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);
/**
* @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 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 (90% de dimensión menor, cuadrado, centrado)
int box_size_;
int box_x_;
int box_y_;
// Calcular dimensiones del recuadro según tamaño de ventana
void calculateBoxDimensions();
// Renderizar texto de ayuda dentro del recuadro
void renderHelpText();
// 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_;
};