refactor: unificar log de consola y centralizar fuente de UI
- Formato uniforme [Tipo] nombre (pack/disco) en texture, textrenderer, png_shape - Eliminar logs verbosos de logo_scaler y app_logo (resolución, escalado, etc.) - Centralizar fuente de UI en APP_FONT (defines.hpp) con las 8 opciones comentadas - Actualizar carpeta data/fonts con nuevas fuentes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
BIN
data/fonts/Exo2-Regular.ttf
Normal file
BIN
data/fonts/Exo2-Regular.ttf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -25,6 +25,9 @@ constexpr float WINDOW_SCALE_MIN = 0.5f; // Escala mínima (50% de la resoluci
|
||||
// Configuración de física
|
||||
constexpr float GRAVITY_FORCE = 0.2f; // Fuerza de gravedad (píxeles/frame²)
|
||||
|
||||
// Fuente de la interfaz
|
||||
#define APP_FONT "data/fonts/Exo2-Regular.ttf"
|
||||
|
||||
// Configuración de interfaz
|
||||
constexpr float THEME_TRANSITION_DURATION = 0.5f; // Duración de transiciones LERP entre temas (segundos)
|
||||
|
||||
|
||||
6
source/external/texture.cpp
vendored
6
source/external/texture.cpp
vendored
@@ -50,11 +50,7 @@ bool Texture::loadFromFile(const std::string &file_path) {
|
||||
delete[] resourceData; // Liberar buffer temporal
|
||||
|
||||
if (data != nullptr) {
|
||||
if (ResourceManager::isPackLoaded()) {
|
||||
std::cout << "Imagen cargada desde pack: " << filename.c_str() << std::endl;
|
||||
} else {
|
||||
std::cout << "Imagen cargada desde disco: " << filename.c_str() << std::endl;
|
||||
}
|
||||
std::cout << "[Textura] " << filename << " (" << (ResourceManager::isPackLoaded() ? "pack" : "disco") << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ PNGShape::PNGShape(const char* png_path) {
|
||||
}
|
||||
|
||||
bool PNGShape::loadPNG(const char* resource_key) {
|
||||
std::cout << "[PNGShape] Cargando recurso: " << resource_key << std::endl;
|
||||
{
|
||||
std::string fn = std::string(resource_key);
|
||||
fn = fn.substr(fn.find_last_of("\\/") + 1);
|
||||
std::cout << "[PNGShape] " << fn << " (" << (ResourceManager::isPackLoaded() ? "pack" : "disco") << ")\n";
|
||||
}
|
||||
unsigned char* file_data = nullptr;
|
||||
size_t file_size = 0;
|
||||
if (!ResourceManager::loadResource(resource_key, file_data, file_size)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "textrenderer.hpp"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
#include <iostream>
|
||||
#include "resource_manager.hpp"
|
||||
|
||||
TextRenderer::TextRenderer() : renderer_(nullptr), font_(nullptr), font_size_(0), use_antialiasing_(true), font_data_buffer_(nullptr) {
|
||||
@@ -44,7 +45,11 @@ bool TextRenderer::init(SDL_Renderer* renderer, const char* font_path, int font_
|
||||
// CRÍTICO: NO eliminar fontData aquí - SDL_ttf necesita estos datos en memoria
|
||||
// mientras la fuente esté abierta. Se liberará en cleanup()
|
||||
font_data_buffer_ = fontData;
|
||||
SDL_Log("Fuente cargada desde ResourceManager: %s (%lu bytes)", font_path, (unsigned long)fontDataSize);
|
||||
{
|
||||
std::string fn = std::string(font_path);
|
||||
fn = fn.substr(fn.find_last_of("\\/") + 1);
|
||||
std::cout << "[Fuente] " << fn << " (" << (ResourceManager::isPackLoaded() ? "pack" : "disco") << ")\n";
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
delete[] fontData;
|
||||
@@ -102,7 +107,10 @@ bool TextRenderer::reinitialize(int new_font_size) {
|
||||
// Mantener buffer en memoria (NO eliminar)
|
||||
font_data_buffer_ = fontData;
|
||||
font_size_ = new_font_size;
|
||||
SDL_Log("Fuente recargada desde ResourceManager: %s (tamaño %d)", font_path_.c_str(), new_font_size);
|
||||
{
|
||||
std::string fn = font_path_.substr(font_path_.find_last_of("\\/") + 1);
|
||||
std::cout << "[Fuente] " << fn << " (" << (ResourceManager::isPackLoaded() ? "pack" : "disco") << ")\n";
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
delete[] fontData;
|
||||
|
||||
@@ -65,12 +65,6 @@ bool AppLogo::initialize(SDL_Renderer* renderer, int screen_width, int screen_he
|
||||
int logo_base_target_height = static_cast<int>(base_screen_height_ * APPLOGO_HEIGHT_PERCENT);
|
||||
int logo_native_target_height = static_cast<int>(native_screen_height_ * APPLOGO_HEIGHT_PERCENT);
|
||||
|
||||
std::cout << "Pre-escalando logos:" << std::endl;
|
||||
std::cout << " Base: " << base_screen_width_ << "x" << base_screen_height_
|
||||
<< " (altura logo: " << logo_base_target_height << "px)" << std::endl;
|
||||
std::cout << " Nativa: " << native_screen_width_ << "x" << native_screen_height_
|
||||
<< " (altura logo: " << logo_native_target_height << "px)" << std::endl;
|
||||
|
||||
// ========================================================================
|
||||
// 3. Cargar y escalar LOGO1 (data/logo/logo.png) a 2 versiones
|
||||
// ========================================================================
|
||||
@@ -193,7 +187,7 @@ bool AppLogo::initialize(SDL_Renderer* renderer, int screen_width, int screen_he
|
||||
logo2_current_width_ = logo2_base_width_;
|
||||
logo2_current_height_ = logo2_base_height_;
|
||||
|
||||
std::cout << "Logos pre-escalados exitosamente (4 texturas creadas)" << std::endl;
|
||||
std::cout << "[Logo] logo.png + logo2.png (base " << logo_base_target_height << "px, nativa " << logo_native_target_height << "px)\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <algorithm> // for std::min
|
||||
|
||||
#include "defines.hpp"
|
||||
#include "text/textrenderer.hpp"
|
||||
#include "theme_manager.hpp"
|
||||
|
||||
@@ -101,7 +102,7 @@ void HelpOverlay::initialize(SDL_Renderer* renderer, ThemeManager* theme_mgr, in
|
||||
|
||||
// Crear renderer de texto con tamaño dinámico
|
||||
text_renderer_ = new TextRenderer();
|
||||
text_renderer_->init(renderer, "data/fonts/FunnelSans-Regular.ttf", font_size, true);
|
||||
text_renderer_->init(renderer, APP_FONT, font_size, true);
|
||||
|
||||
calculateBoxDimensions();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ bool LogoScaler::detectNativeResolution(int& native_width, int& native_height) {
|
||||
|
||||
SDL_free(displays);
|
||||
|
||||
std::cout << "Resolución nativa detectada: " << native_width << "x" << native_height << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -73,8 +72,6 @@ unsigned char* LogoScaler::loadAndScale(const std::string& path,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::cout << "Imagen cargada: " << path << " (" << orig_width << "x" << orig_height << ")" << std::endl;
|
||||
|
||||
// 2. Calcular tamaño final manteniendo aspect ratio
|
||||
// El alto está fijado por target_height (APPLOGO_HEIGHT_PERCENT)
|
||||
// Calcular ancho proporcional al aspect ratio original
|
||||
@@ -82,8 +79,6 @@ unsigned char* LogoScaler::loadAndScale(const std::string& path,
|
||||
out_width = static_cast<int>(target_height * aspect_ratio);
|
||||
out_height = target_height;
|
||||
|
||||
std::cout << " Escalando a: " << out_width << "x" << out_height << std::endl;
|
||||
|
||||
// 3. Alocar buffer para imagen escalada (RGBA = 4 bytes por píxel)
|
||||
unsigned char* scaled_data = static_cast<unsigned char*>(malloc(out_width * out_height * 4));
|
||||
if (scaled_data == nullptr) {
|
||||
@@ -109,7 +104,6 @@ unsigned char* LogoScaler::loadAndScale(const std::string& path,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::cout << " Escalado completado correctamente" << std::endl;
|
||||
return scaled_data;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ void UIManager::initialize(SDL_Renderer* renderer, ThemeManager* theme_manager,
|
||||
text_renderer_notifier_ = new TextRenderer();
|
||||
|
||||
// Inicializar renderers con tamaño dinámico
|
||||
text_renderer_debug_->init(renderer, "data/fonts/FunnelSans-Regular.ttf", std::max(9, current_font_size_ - 2), true);
|
||||
text_renderer_notifier_->init(renderer, "data/fonts/FunnelSans-Regular.ttf", current_font_size_, true);
|
||||
text_renderer_debug_->init(renderer, APP_FONT, std::max(9, current_font_size_ - 2), true);
|
||||
text_renderer_notifier_->init(renderer, APP_FONT, current_font_size_, true);
|
||||
|
||||
// Crear y configurar sistema de notificaciones
|
||||
notifier_ = new Notifier();
|
||||
|
||||
Reference in New Issue
Block a user