acabat amb SDL_Log

This commit is contained in:
2025-03-27 20:56:21 +01:00
parent 8afca398e9
commit 36b3048070
11 changed files with 340 additions and 128 deletions

View File

@@ -4,7 +4,7 @@
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_gamepad.h> // Para SDL_GamepadButton
#include <SDL3/SDL_init.h> // Para SDL_Init, SDL_Quit, SDL_INIT_AUDIO
#include <SDL3/SDL_log.h> // Para SDL_Log, SDL_LogCategory, SDL_LogE...
#include <SDL3/SDL.h> // Para SDL_Log, SDL_LogCategory, SDL_LogE...
#include <SDL3/SDL_scancode.h> // Para SDL_Scancode
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOOLONG
#include <stdio.h> // Para printf, perror
@@ -56,7 +56,11 @@ Director::Director(int argc, const char *argv[])
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
#endif
SDL_Log("Game start");
// Establece el nivel de prioridad de la categoría de registro
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
SDL_SetLogPriority(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR);
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Game start");
// Inicia la semilla aleatoria usando el tiempo actual en segundos
std::srand(static_cast<unsigned int>(std::time(nullptr)));
@@ -74,7 +78,7 @@ Director::Director(int argc, const char *argv[])
Director::~Director()
{
close();
SDL_Log("\nBye!");
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nBye!");
}
// Inicializa todo
@@ -258,6 +262,8 @@ void Director::initJailAudio()
}
else
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** SDL_AUDIO: INITIALIZING\n");
JA_Init(48000, SDL_AUDIO_S16LE, 2);
if (options.audio.enabled)
{
@@ -270,7 +276,7 @@ void Director::initJailAudio()
JA_SetSoundVolume(0);
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL_AUDIO: Initialization complete.");
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
}
}
@@ -683,7 +689,7 @@ int Director::run()
break;
}
SDL_Log("\nGame end %s", return_code.c_str());
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nGame end %s", return_code.c_str());
return (section::options == section::Options::QUIT_WITH_CONTROLLER) ? 1 : 0;
}