From 5e013a8414a80ca51005387dddf83055f190f7ef Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 22 Mar 2026 10:16:09 +0100 Subject: [PATCH] =?UTF-8?q?revisi=C3=B3=20de=20metodes=20de=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/locale/ca.yaml | 2 -- data/locale/en.yaml | 2 -- source/core/input/global_inputs.cpp | 26 -------------------------- source/core/rendering/screen.cpp | 6 +++--- source/core/rendering/screen.hpp | 6 +++--- source/game/scenes/game.cpp | 22 +++++++++++----------- 6 files changed, 17 insertions(+), 47 deletions(-) diff --git a/data/locale/ca.yaml b/data/locale/ca.yaml index 9e6b43d..505b9d9 100644 --- a/data/locale/ca.yaml +++ b/data/locale/ca.yaml @@ -135,5 +135,3 @@ game: cheat_jail_open: "JAIL OBERTA" debug_enabled: "DEBUG ACTIVAT" debug_disabled: "DEBUG DESACTIVAT" - achievement_unlocked: "ASSOLIMENT DESBLOQUEJAT!" - c11: "M'AGRADEN ELS MEUS AMICS DE COLORS" diff --git a/data/locale/en.yaml b/data/locale/en.yaml index 26c4d1e..5b56f3d 100644 --- a/data/locale/en.yaml +++ b/data/locale/en.yaml @@ -134,5 +134,3 @@ game: cheat_jail_open: "JAIL IS OPEN" debug_enabled: "DEBUG ENABLED" debug_disabled: "DEBUG DISABLED" - achievement_unlocked: "ACHIEVEMENT UNLOCKED!" - c11: "I LIKE MY MULTICOLOURED FRIENDS" diff --git a/source/core/input/global_inputs.cpp b/source/core/input/global_inputs.cpp index fc64940..14ac06e 100644 --- a/source/core/input/global_inputs.cpp +++ b/source/core/input/global_inputs.cpp @@ -13,10 +13,6 @@ #include "game/ui/notifier.hpp" // Para Notifier, NotificationText #include "utils/utils.hpp" // Para stringInVector -#ifdef _DEBUG -#include "core/system/debug.hpp" // Para Debug -#endif - namespace GlobalInputs { // Funciones internas @@ -126,18 +122,6 @@ namespace GlobalInputs { Notifier::get()->show({Locale::get()->get(Options::video.vertical_sync ? "ui.vsync_enabled" : "ui.vsync_disabled")}); } -#ifdef _DEBUG - void handleShowDebugInfo() { - Screen::get()->toggleDebugInfo(); - } - -/* -void handleToggleDebug() { - Debug::get()->toggleEnabled(); - Notifier::get()->show({"DEBUG " + std::string(Debug::get()->isEnabled() ? "ENABLED" : "DISABLED")}, Notifier::TextAlign::CENTER); -} -*/ -#endif // Detecta qué acción global ha sido presionada (si alguna) auto getPressedAction() -> InputAction { @@ -257,16 +241,6 @@ void handleToggleDebug() { handleToggleVSync(); break; - case InputAction::TOGGLE_DEBUG: - // handleToggleDebug(); - break; - -#ifdef _DEBUG - case InputAction::SHOW_DEBUG_INFO: - handleShowDebugInfo(); - break; -#endif - case InputAction::NONE: default: // No se presionó ninguna acción global diff --git a/source/core/rendering/screen.cpp b/source/core/rendering/screen.cpp index 20ddfc6..6439625 100644 --- a/source/core/rendering/screen.cpp +++ b/source/core/rendering/screen.cpp @@ -393,7 +393,7 @@ auto Screen::findPalette(const std::string& name) -> size_t { // Muestra información por pantalla void Screen::renderInfo() const { - if (show_debug_info_ && (Resource::Cache::get() != nullptr)) { + if (show_fps_ && (Resource::Cache::get() != nullptr)) { auto text = Resource::Cache::get()->getText("smb2"); auto color = static_cast(PaletteColor::YELLOW); auto shadow = static_cast(PaletteColor::BLACK); @@ -428,8 +428,8 @@ void Screen::hide() { SDL_HideWindow(window_); } // Establece la visibilidad de las notificaciones void Screen::setNotificationsEnabled(bool value) { notifications_enabled_ = value; } -// Activa / desactiva la información de debug -void Screen::toggleDebugInfo() { show_debug_info_ = !show_debug_info_; } +// Activa / desactiva el contador de FPS +void Screen::toggleFPS() { show_fps_ = !show_fps_; } // Alterna entre activar y desactivar el escalado entero void Screen::toggleIntegerScale() { diff --git a/source/core/rendering/screen.hpp b/source/core/rendering/screen.hpp index 7dfc550..24d95c4 100644 --- a/source/core/rendering/screen.hpp +++ b/source/core/rendering/screen.hpp @@ -62,7 +62,7 @@ class Screen { // Surfaces y notificaciones void setRendererSurface(const std::shared_ptr& surface = nullptr); // Establece el renderizador para las surfaces void setNotificationsEnabled(bool value); // Establece la visibilidad de las notificaciones - void toggleDebugInfo(); // Activa o desactiva la información de debug + void toggleFPS(); // Activa o desactiva el contador de FPS // Getters auto getRenderer() -> SDL_Renderer*; @@ -158,8 +158,8 @@ class Screen { std::vector pixel_buffer_; // Buffer intermedio para SDL3GPU path (surface → ARGB) #ifdef _DEBUG - bool show_debug_info_{true}; // Indica si ha de mostrar la información de debug + bool show_fps_{true}; // Indica si ha de mostrar el contador de FPS #else - bool show_debug_info_{false}; // Indica si ha de mostrar la información de debug + bool show_fps_{false}; // Indica si ha de mostrar el contador de FPS #endif }; \ No newline at end of file diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 8343bde..14ea5ae 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -414,16 +414,6 @@ void Game::renderDebugInfo() { void Game::handleDebugEvents(const SDL_Event& event) { if (event.type == SDL_EVENT_KEY_DOWN && static_cast(event.key.repeat) == 0) { switch (event.key.key) { - case SDLK_F12: - Debug::get()->toggleEnabled(); - Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")}); - room_->redrawMap(); // Redibuja el tilemap para mostrar/ocultar líneas de colisión - Options::cheats.invincible = static_cast(Debug::get()->isEnabled()); - player_->setColor(); - scoreboard_data_->music = !Debug::get()->isEnabled(); - scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic(); - break; - case SDLK_R: Resource::Cache::get()->reload(); break; @@ -458,12 +448,22 @@ void Game::handleDebugEvents(const SDL_Event& event) { toggleCheat(Options::cheats.jail_is_open, Locale::get()->get("game.cheat_jail_open")); break; + case SDLK_4: + Screen::get()->toggleFPS(); + break; + case SDLK_7: Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); break; case SDLK_0: - Screen::get()->toggleDebugInfo(); + Debug::get()->toggleEnabled(); + Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")}); + room_->redrawMap(); + Options::cheats.invincible = static_cast(Debug::get()->isEnabled()); + player_->setColor(); + scoreboard_data_->music = !Debug::get()->isEnabled(); + scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic(); break; default: