diff --git a/source/core/input/global_inputs.cpp b/source/core/input/global_inputs.cpp index 0e20c375..52215b8c 100644 --- a/source/core/input/global_inputs.cpp +++ b/source/core/input/global_inputs.cpp @@ -12,6 +12,10 @@ #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 @@ -101,10 +105,17 @@ void handleToggleVSync() { Notifier::get()->show({"V-SYNC " + std::string(Options::video.vertical_sync ? "ENABLED" : "DISABLED")}, NotificationText::CENTER); } +#ifdef _DEBUG void handleShowDebugInfo() { Screen::get()->toggleDebugInfo(); } +void handleToggleDebug() { + Debug::get()->toggleEnabled(); + Notifier::get()->show({"DEBUG " + std::string(Debug::get()->getEnabled() ? "ENABLED" : "DISABLED")}, NotificationText::CENTER); +} +#endif + // Detecta qué acción global ha sido presionada (si alguna) auto getPressedAction() -> InputAction { if (Input::get()->checkAction(InputAction::EXIT, Input::DO_NOT_ALLOW_REPEAT)) { @@ -140,6 +151,9 @@ auto getPressedAction() -> InputAction { if (Input::get()->checkAction(InputAction::TOGGLE_VSYNC, Input::DO_NOT_ALLOW_REPEAT)) { return InputAction::TOGGLE_VSYNC; } + if (Input::get()->checkAction(InputAction::TOGGLE_DEBUG, Input::DO_NOT_ALLOW_REPEAT)) { + return InputAction::TOGGLE_DEBUG; + } if (Input::get()->checkAction(InputAction::SHOW_DEBUG_INFO, Input::DO_NOT_ALLOW_REPEAT)) { return InputAction::SHOW_DEBUG_INFO; } @@ -201,6 +215,10 @@ void handle() { handleToggleVSync(); break; + case InputAction::TOGGLE_DEBUG: + handleToggleDebug(); + break; + case InputAction::SHOW_DEBUG_INFO: handleShowDebugInfo(); break; diff --git a/source/core/input/input.hpp b/source/core/input/input.hpp index 7159833d..1f8ba643 100644 --- a/source/core/input/input.hpp +++ b/source/core/input/input.hpp @@ -78,8 +78,8 @@ class Input { {Action::TOGGLE_MUSIC, KeyState(SDL_SCANCODE_F8)}, {Action::TOGGLE_BORDER, KeyState(SDL_SCANCODE_F9)}, {Action::TOGGLE_VSYNC, KeyState(SDL_SCANCODE_F10)}, - {Action::PAUSE, KeyState(SDL_SCANCODE_F11)}, - {Action::SHOW_DEBUG_INFO, KeyState(SDL_SCANCODE_F12)}} {} + {Action::TOGGLE_DEBUG, KeyState(SDL_SCANCODE_F12)}, + {Action::SHOW_DEBUG_INFO, KeyState(SDL_SCANCODE_F11)}} {} }; struct Gamepad { diff --git a/source/core/input/input_types.cpp b/source/core/input/input_types.cpp index 700a0350..563bfe43 100644 --- a/source/core/input/input_types.cpp +++ b/source/core/input/input_types.cpp @@ -22,6 +22,7 @@ const std::unordered_map ACTION_TO_STRING = { {InputAction::PREVIOUS_PALETTE, "PREVIOUS_PALETTE"}, {InputAction::TOGGLE_SHADERS, "TOGGLE_SHADERS"}, {InputAction::SHOW_DEBUG_INFO, "SHOW_DEBUG_INFO"}, + {InputAction::TOGGLE_DEBUG, "TOGGLE_DEBUG"}, {InputAction::NONE, "NONE"}}; const std::unordered_map STRING_TO_ACTION = { @@ -43,6 +44,7 @@ const std::unordered_map STRING_TO_ACTION = { {"PREVIOUS_PALETTE", InputAction::PREVIOUS_PALETTE}, {"TOGGLE_SHADERS", InputAction::TOGGLE_SHADERS}, {"SHOW_DEBUG_INFO", InputAction::SHOW_DEBUG_INFO}, + {"TOGGLE_DEBUG", InputAction::TOGGLE_DEBUG}, {"NONE", InputAction::NONE}}; const std::unordered_map BUTTON_TO_STRING = { diff --git a/source/core/input/input_types.hpp b/source/core/input/input_types.hpp index cae4cfa9..b1fc3f49 100644 --- a/source/core/input/input_types.hpp +++ b/source/core/input/input_types.hpp @@ -30,6 +30,7 @@ enum class InputAction : int { // Acciones de entrada posibles en el juego NEXT_PALETTE, PREVIOUS_PALETTE, SHOW_DEBUG_INFO, + TOGGLE_DEBUG, // Input obligatorio NONE, diff --git a/source/core/system/debug.hpp b/source/core/system/debug.hpp index b3e3fd4d..158f14c1 100644 --- a/source/core/system/debug.hpp +++ b/source/core/system/debug.hpp @@ -7,23 +7,6 @@ // Clase Debug class Debug { - private: - // [SINGLETON] Objeto privado - static Debug* debug; - - // Variables - std::vector slot_; // Vector con los textos a escribir - std::vector log_; // Vector con los textos a escribir - 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 - - // Constructor - Debug() = default; - - // Destructor - ~Debug() = default; - public: // [SINGLETON] Crearemos el objeto con esta función estática static void init(); @@ -50,4 +33,21 @@ class Debug { void clearLog() { log_.clear(); } void setEnabled(bool value) { enabled_ = value; } void toggleEnabled() { enabled_ = !enabled_; } + + private: + // [SINGLETON] Objeto privado + static Debug* debug; + + // Variables + std::vector slot_; // Vector con los textos a escribir + std::vector log_; // Vector con los textos a escribir + 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 + + // Constructor + Debug() = default; + + // Destructor + ~Debug() = default; }; \ No newline at end of file diff --git a/source/game/scene_manager.hpp b/source/game/scene_manager.hpp index f489c532..9ee627ac 100644 --- a/source/game/scene_manager.hpp +++ b/source/game/scene_manager.hpp @@ -34,7 +34,7 @@ enum class Options { // --- Variables de estado globales --- #ifdef _DEBUG -inline Scene current = Scene::LOGO; // Escena actual +inline Scene current = Scene::GAME; // Escena actual inline Options options = Options::LOGO_TO_LOADING_SCREEN; // Opciones de la escena actual #else inline Scene current = Scene::LOGO; // Escena actual diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 37bacd66..da261cfa 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -13,7 +13,6 @@ #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/resources/asset.hpp" // Para Asset #include "core/resources/resource.hpp" // Para ResourceRoom, Resource -#include "core/system/debug.hpp" // Para Debug #include "core/system/global_events.hpp" // Para check #include "game/gameplay/cheevos.hpp" // Para Cheevos #include "game/gameplay/item_tracker.hpp" // Para ItemTracker @@ -27,6 +26,10 @@ #include "utils/defines.hpp" // Para TILE_SIZE, PLAY_AREA_HEIGHT, RoomBorder::BOTTOM #include "utils/utils.hpp" // Para PaletteColor, stringToColor +#ifdef _DEBUG +#include "core/system/debug.hpp" // Para Debug +#endif + // Constructor Game::Game(Mode mode) : board_(std::make_shared(0, 9, 0, true, 0, SDL_GetTicks(), Options::cheats.jail_is_open == Options::Cheat::State::ENABLED)), @@ -42,10 +45,6 @@ Game::Game(Mode mode) spawn_data_(Player::SpawnData(25 * TILE_SIZE, 13 * TILE_SIZE, 0, 0, 0, Player::State::STANDING, SDL_FLIP_HORIZONTAL)) #endif { -#ifdef _DEBUG - Debug::get()->setEnabled(false); -#endif - // Crea objetos e inicializa variables ItemTracker::init(); demoInit(); diff --git a/source/game/scenes/logo.cpp b/source/game/scenes/logo.cpp index 7c07405c..7b389e3b 100644 --- a/source/game/scenes/logo.cpp +++ b/source/game/scenes/logo.cpp @@ -274,7 +274,8 @@ void Logo::initSprites() { jailgames_sprite_.back()->setClip(0, i, jailgames_surface_->getWidth(), 1); // Calcular posición inicial (alternando entre derecha e izquierda) - const int initial_x = (i % 2 == 0) ? (256 + (i * 3)) : (static_cast(-WIDTH) - (i * 3)); + constexpr int LINE_OFFSET = 6; + const int initial_x = (i % 2 == 0) ? (256 + (i * LINE_OFFSET)) : (static_cast(-WIDTH) - (i * LINE_OFFSET)); jailgames_initial_x_.push_back(initial_x); jailgames_sprite_.at(i)->setX(initial_x);