Fix: Ajustar dimensionamiento de HelpOverlay para resoluciones bajas
Problemas resueltos: - En 640x360, el overlay generaba textura enorme con letras grandes - El cálculo de font size usaba dimensiones físicas (con zoom aplicado) en lugar de dimensiones lógicas (resolución interna) - No había límite máximo de ancho para el overlay - Padding fijo de 25px era excesivo en pantallas pequeñas Cambios realizados: 1. UIManager: Usar dimensiones lógicas para calcular font size - Nuevo parámetro logical_width/logical_height en initialize() - calculateFontSize() ahora usa altura lógica sin zoom - Escalado híbrido: proporcional en extremos, escalonado en rango medio - Para 640x360: 10px (antes 18px con zoom 2x) - Para 640x480: 12px (antes 24px con zoom 2x) 2. HelpOverlay: Agregar límites máximos de dimensiones - Box width limitado al 95% del ancho físico - Box height limitado al 90% de la altura física - Padding dinámico: 25px para >=600px, escalado para menores - Para 360px altura: padding de 15px (antes 25px fijo) 3. Engine: Pasar dimensiones lógicas a UIManager - initialize() ahora recibe current_screen_width/height Resultado: - 640x360: Overlay compacto con fuente 10px que cabe en pantalla - 640x480: Overlay con fuente 12px (tamaño apropiado) - Tamaño de fuente consistente independiente del zoom de ventana 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,8 @@ UIManager::UIManager()
|
||||
, theme_manager_(nullptr)
|
||||
, physical_window_width_(0)
|
||||
, physical_window_height_(0)
|
||||
, logical_window_width_(0)
|
||||
, logical_window_height_(0)
|
||||
, current_font_size_(18) { // Tamaño por defecto (medium)
|
||||
}
|
||||
|
||||
@@ -65,14 +67,17 @@ UIManager::~UIManager() {
|
||||
}
|
||||
|
||||
void UIManager::initialize(SDL_Renderer* renderer, ThemeManager* theme_manager,
|
||||
int physical_width, int physical_height) {
|
||||
int physical_width, int physical_height,
|
||||
int logical_width, int logical_height) {
|
||||
renderer_ = renderer;
|
||||
theme_manager_ = theme_manager;
|
||||
physical_window_width_ = physical_width;
|
||||
physical_window_height_ = physical_height;
|
||||
logical_window_width_ = logical_width;
|
||||
logical_window_height_ = logical_height;
|
||||
|
||||
// Calcular tamaño de fuente apropiado según dimensiones físicas
|
||||
current_font_size_ = calculateFontSize(physical_width, physical_height);
|
||||
// Calcular tamaño de fuente apropiado según dimensiones LÓGICAS (sin zoom)
|
||||
current_font_size_ = calculateFontSize(logical_height);
|
||||
|
||||
// Crear renderers de texto
|
||||
text_renderer_debug_ = new TextRenderer();
|
||||
@@ -165,8 +170,9 @@ void UIManager::updatePhysicalWindowSize(int width, int height) {
|
||||
physical_window_width_ = width;
|
||||
physical_window_height_ = height;
|
||||
|
||||
// Calcular nuevo tamaño de fuente apropiado
|
||||
int new_font_size = calculateFontSize(width, height);
|
||||
// Calcular nuevo tamaño de fuente apropiado basado en altura LÓGICA
|
||||
// (las dimensiones lógicas no cambian con zoom, solo con cambios explícitos de resolución)
|
||||
int new_font_size = calculateFontSize(logical_window_height_);
|
||||
|
||||
// Si el tamaño cambió, reinicializar todos los text renderers
|
||||
if (new_font_size != current_font_size_) {
|
||||
@@ -406,20 +412,37 @@ std::string UIManager::gravityDirectionToString(int direction) const {
|
||||
}
|
||||
}
|
||||
|
||||
int UIManager::calculateFontSize(int physical_width, int physical_height) const {
|
||||
// Calcular área física de la ventana
|
||||
int area = physical_width * physical_height;
|
||||
int UIManager::calculateFontSize(int logical_height) const {
|
||||
// Escalado híbrido basado en ALTURA LÓGICA (resolución interna, sin zoom)
|
||||
// Esto asegura que el tamaño de fuente sea consistente independientemente del zoom de ventana
|
||||
// - Proporcional en extremos (muy bajo/alto)
|
||||
// - Escalonado en rango medio (estabilidad)
|
||||
|
||||
// Stepped scaling con 3 tamaños:
|
||||
// - SMALL: < 800x600 (480,000 pixels) → 14px
|
||||
// - MEDIUM: 800x600 a 1920x1080 (2,073,600 pixels) → 18px
|
||||
// - LARGE: > 1920x1080 → 24px
|
||||
int font_size = 14; // Default fallback
|
||||
|
||||
if (area < 480000) {
|
||||
return 14; // Ventanas pequeñas
|
||||
} else if (area < 2073600) {
|
||||
return 18; // Ventanas medianas (default)
|
||||
if (logical_height < 300) {
|
||||
// Rango bajo: proporcional (240px→9.6, 280px→11.2)
|
||||
font_size = logical_height / 25;
|
||||
} else if (logical_height < 380) {
|
||||
// Rango muy bajo (300-379px) → 10px (crítico para 640x360)
|
||||
font_size = 10;
|
||||
} else if (logical_height < 500) {
|
||||
// Rango medio-bajo (380-499px) → 12px
|
||||
font_size = 12;
|
||||
} else if (logical_height < 700) {
|
||||
// Rango medio (500-699px) → 14px
|
||||
font_size = 14;
|
||||
} else if (logical_height < 900) {
|
||||
// Rango medio-alto (700-899px) → 18px
|
||||
font_size = 18;
|
||||
} else {
|
||||
return 24; // Ventanas grandes
|
||||
// Rango alto: proporcional (1080px→27, 1440px→36)
|
||||
font_size = logical_height / 40;
|
||||
}
|
||||
|
||||
// Aplicar límites: mínimo 9px, máximo 36px
|
||||
if (font_size < 9) font_size = 9;
|
||||
if (font_size > 36) font_size = 36;
|
||||
|
||||
return font_size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user