merdes varies

This commit is contained in:
2025-11-08 13:21:59 +01:00
parent 85d34fb907
commit 1f01268dcf
8 changed files with 47 additions and 26 deletions

View File

@@ -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;

View File

@@ -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 {

View File

@@ -22,6 +22,7 @@ const std::unordered_map<InputAction, std::string> 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<std::string, InputAction> STRING_TO_ACTION = {
@@ -43,6 +44,7 @@ const std::unordered_map<std::string, InputAction> 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<SDL_GamepadButton, std::string> BUTTON_TO_STRING = {

View File

@@ -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,

View File

@@ -7,23 +7,6 @@
// Clase Debug
class Debug {
private:
// [SINGLETON] Objeto privado
static Debug* debug;
// Variables
std::vector<std::string> slot_; // Vector con los textos a escribir
std::vector<std::string> 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<std::string> slot_; // Vector con los textos a escribir
std::vector<std::string> 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;
};

View File

@@ -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

View File

@@ -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<ScoreboardData>(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();

View File

@@ -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<int>(-WIDTH) - (i * 3));
constexpr int LINE_OFFSET = 6;
const int initial_x = (i % 2 == 0) ? (256 + (i * LINE_OFFSET)) : (static_cast<int>(-WIDTH) - (i * LINE_OFFSET));
jailgames_initial_x_.push_back(initial_x);
jailgames_sprite_.at(i)->setX(initial_x);