From e4a61a7241715cb0c1124f17d29bb8fc2e0cc042 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 16 Nov 2025 20:44:15 +0100 Subject: [PATCH] eliminada la clase Debug en Release --- CMakeLists.txt | 9 ++++++++- source/core/input/global_inputs.cpp | 2 ++ source/core/rendering/screen.cpp | 2 ++ source/core/system/debug.hpp | 6 +++++- source/core/system/director.cpp | 6 ++++++ source/game/entities/player.cpp | 2 ++ source/game/gameplay/collision_map.cpp | 2 ++ source/game/gameplay/tilemap_renderer.cpp | 2 ++ 8 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a79fc9c..1e4d12c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,6 @@ set(APP_SOURCES source/core/resources/resource_helper.cpp # Core - System - source/core/system/debug.cpp source/core/system/director.cpp source/core/system/global_events.cpp @@ -119,6 +118,11 @@ set(RENDERING_SOURCES source/core/rendering/opengl/opengl_shader.cpp ) +# Fuentes de debug (solo en modo Debug) +set(DEBUG_SOURCES + source/core/system/debug.cpp +) + # Configuración de SDL3 find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3) message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}") @@ -126,6 +130,9 @@ message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}") # --- 2. AÑADIR EJECUTABLE --- add_executable(${PROJECT_NAME} ${APP_SOURCES} ${EXTERNAL_SOURCES} ${RENDERING_SOURCES}) +# Añadir fuentes de debug solo en modo Debug +target_sources(${PROJECT_NAME} PRIVATE $<$:${DEBUG_SOURCES}>) + # --- 3. DIRECTORIOS DE INCLUSIÓN --- target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/source" diff --git a/source/core/input/global_inputs.cpp b/source/core/input/global_inputs.cpp index f2b0343..e354c25 100644 --- a/source/core/input/global_inputs.cpp +++ b/source/core/input/global_inputs.cpp @@ -221,9 +221,11 @@ void handle() { //handleToggleDebug(); break; +#ifdef _DEBUG case InputAction::SHOW_DEBUG_INFO: handleShowDebugInfo(); break; +#endif case InputAction::NONE: default: diff --git a/source/core/rendering/screen.cpp b/source/core/rendering/screen.cpp index 8acc03c..9749a7a 100644 --- a/source/core/rendering/screen.cpp +++ b/source/core/rendering/screen.cpp @@ -322,7 +322,9 @@ void Screen::textureToRenderer() { // Renderiza todos los overlays void Screen::renderOverlays() { renderNotifications(); +#ifdef _DEBUG renderInfo(); +#endif } // Localiza la paleta dentro del vector de paletas diff --git a/source/core/system/debug.hpp b/source/core/system/debug.hpp index 4652b90..88f10c5 100644 --- a/source/core/system/debug.hpp +++ b/source/core/system/debug.hpp @@ -1,5 +1,7 @@ #pragma once +#ifdef _DEBUG + #include #include // Para string @@ -37,4 +39,6 @@ class Debug { int x_ = 0; // Posicion donde escribir el texto de debug int y_ = 0; // Posición donde escribir el texto de debug bool enabled_ = false; // Indica si esta activo el modo debug -}; \ No newline at end of file +}; + +#endif // _DEBUG \ No newline at end of file diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index 19dfd4b..4ae4b6f 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -18,7 +18,9 @@ #include "core/resources/resource_helper.hpp" // Para ResourceHelper #include "core/resources/resource_list.hpp" // Para Asset, AssetType #include "core/resources/resource_loader.hpp" // Para ResourceLoader +#ifdef _DEBUG #include "core/system/debug.hpp" // Para Debug +#endif #include "game/gameplay/cheevos.hpp" // Para Cheevos #include "game/options.hpp" // Para Options, options, OptionsVideo #include "game/scene_manager.hpp" // Para SceneManager @@ -143,7 +145,9 @@ Director::Director(std::vector const& args) { // Aplica las teclas configuradas desde Options Input::get()->applyKeyboardBindingsFromOptions(); +#ifdef _DEBUG Debug::init(); +#endif // Special handling for cheevos.bin - also needs filesystem path #ifdef RELEASE_BUILD @@ -160,7 +164,9 @@ Director::~Director() { // Destruye los singletones Cheevos::destroy(); +#ifdef _DEBUG Debug::destroy(); +#endif Input::destroy(); Notifier::destroy(); Resource::Cache::destroy(); diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index 1707f2f..33e991a 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -82,8 +82,10 @@ void Player::move(float delta_time) { break; } syncSpriteAndCollider(); // Actualiza la posición del sprite y las colisiones +#ifdef _DEBUG Debug::get()->add(std::string("X: " + std::to_string(static_cast(x_)))); Debug::get()->add(std::string("Y: " + std::to_string(static_cast(y_)))); +#endif } void Player::handleConveyorBelts() { diff --git a/source/game/gameplay/collision_map.cpp b/source/game/gameplay/collision_map.cpp index 5acb10d..04e6dfb 100644 --- a/source/game/gameplay/collision_map.cpp +++ b/source/game/gameplay/collision_map.cpp @@ -2,7 +2,9 @@ #include // Para std::ranges::any_of +#ifdef _DEBUG #include "core/system/debug.hpp" // Para Debug +#endif #include "utils/defines.hpp" // Para Collision // Constructor diff --git a/source/game/gameplay/tilemap_renderer.cpp b/source/game/gameplay/tilemap_renderer.cpp index 1f86970..689ac40 100644 --- a/source/game/gameplay/tilemap_renderer.cpp +++ b/source/game/gameplay/tilemap_renderer.cpp @@ -3,7 +3,9 @@ #include "core/rendering/screen.hpp" #include "core/rendering/surface.hpp" #include "core/rendering/surface_sprite.hpp" +#ifdef _DEBUG #include "core/system/debug.hpp" +#endif #include "game/gameplay/collision_map.hpp" #include "utils/utils.hpp"