resolt bug en jail_audio
treballant en Screen::renderInfo() deixa el programa congelat
This commit is contained in:
@@ -99,6 +99,10 @@ void Director::init()
|
|||||||
bindInputs();
|
bindInputs();
|
||||||
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
||||||
OnScreenHelp::init();
|
OnScreenHelp::init();
|
||||||
|
#ifdef DEBUG
|
||||||
|
Screen::get()->initDebugInfo();
|
||||||
|
Screen::get()->setDebugInfoEnabled(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cierra todo
|
// Cierra todo
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ void JA_StopChannel(const int channel)
|
|||||||
{
|
{
|
||||||
if (channels[i].state != JA_CHANNEL_FREE)
|
if (channels[i].state != JA_CHANNEL_FREE)
|
||||||
SDL_DestroyAudioStream(channels[i].stream);
|
SDL_DestroyAudioStream(channels[i].stream);
|
||||||
channels[channel].stream = nullptr;
|
channels[i].stream = nullptr;
|
||||||
channels[i].state = JA_CHANNEL_FREE;
|
channels[i].state = JA_CHANNEL_FREE;
|
||||||
channels[i].pos = 0;
|
channels[i].pos = 0;
|
||||||
channels[i].sound = NULL;
|
channels[i].sound = NULL;
|
||||||
|
|||||||
@@ -214,23 +214,21 @@ void Screen::renderShake()
|
|||||||
SDL_SetRenderTarget(renderer_, current_target);
|
SDL_SetRenderTarget(renderer_, current_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
// Muestra información por pantalla
|
// Muestra información por pantalla
|
||||||
void Screen::renderInfo()
|
void Screen::renderInfo()
|
||||||
{
|
{
|
||||||
if (show_debug_info_ && Resource::get())
|
if (debug_info_.show)
|
||||||
{
|
{
|
||||||
auto text = Resource::get()->getText("smb2");
|
|
||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
||||||
text->writeColored(param.game.width - text->lenght(FPS_TEXT), 0, FPS_TEXT, ORANGE_SOFT_COLOR);
|
debug_info_.text->writeColored(param.game.width - debug_info_.text->lenght(FPS_TEXT), 0, FPS_TEXT, ORANGE_SOFT_COLOR);
|
||||||
|
|
||||||
// Resolution
|
// Resolution
|
||||||
text->writeColored(0, 0, options.video.info, ORANGE_SOFT_COLOR);
|
debug_info_.text->writeColored(0, 0, options.video.info, ORANGE_SOFT_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// Carga el contenido del archivo GLSL
|
// Carga el contenido del archivo GLSL
|
||||||
void Screen::loadShaders()
|
void Screen::loadShaders()
|
||||||
{
|
{
|
||||||
@@ -285,8 +283,10 @@ void Screen::renderOverlays()
|
|||||||
renderFlash();
|
renderFlash();
|
||||||
renderAttenuate();
|
renderAttenuate();
|
||||||
OnScreenHelp::get()->render();
|
OnScreenHelp::get()->render();
|
||||||
renderInfo();
|
|
||||||
Notifier::get()->render();
|
Notifier::get()->render();
|
||||||
|
#ifdef DEBUG
|
||||||
|
renderInfo();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atenua la pantalla
|
// Atenua la pantalla
|
||||||
|
|||||||
@@ -4,18 +4,25 @@
|
|||||||
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_SetRenderLogicalPrese...
|
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_SetRenderLogicalPrese...
|
||||||
#include <SDL3/SDL_stdinc.h> // Para Uint32
|
#include <SDL3/SDL_stdinc.h> // Para Uint32
|
||||||
#include <SDL3/SDL_video.h> // Para SDL_Window, SDL_HideWindow, SDL_ShowWindow
|
#include <SDL3/SDL_video.h> // Para SDL_Window, SDL_HideWindow, SDL_ShowWindow
|
||||||
|
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogError, SDL_L...
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
|
#include <memory> // Para shared_ptr
|
||||||
#include "options.h" // Para Options, VideoOptions, options
|
#include "options.h" // Para Options, VideoOptions, options
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "param.h" // Para Param, ParamGame, param
|
||||||
#include "utils.h" // Para Color
|
#include "utils.h" // Para Color
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include "text.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Constantes
|
// Constantes
|
||||||
static constexpr int WINDOWS_DECORATIONS_ = 35;
|
static constexpr int WINDOWS_DECORATIONS_ = 35;
|
||||||
|
|
||||||
// Estructuras
|
// Estructura para gestionar los fotogramas por segundo
|
||||||
struct FPS
|
struct FPS
|
||||||
{
|
{
|
||||||
Uint32 ticks; // Tiempo en milisegundos desde que se comenzó a contar.
|
Uint32 ticks; // Tiempo en milisegundos desde que se comenzó a contar.
|
||||||
@@ -44,6 +51,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para gestionar el efecto de flash en la pantalla
|
||||||
struct FlashEffect
|
struct FlashEffect
|
||||||
{
|
{
|
||||||
bool enabled; // Indica si el efecto está activo
|
bool enabled; // Indica si el efecto está activo
|
||||||
@@ -63,6 +71,7 @@ private:
|
|||||||
bool isRendarable() { return enabled && counter < lenght - delay; }
|
bool isRendarable() { return enabled && counter < lenght - delay; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para agitar la pantalla
|
||||||
struct ShakeEffect
|
struct ShakeEffect
|
||||||
{
|
{
|
||||||
int desp; // Pixels de desplazamiento para agitar la pantalla en el eje x
|
int desp; // Pixels de desplazamiento para agitar la pantalla en el eje x
|
||||||
@@ -139,7 +148,27 @@ private:
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Estructura pra mostrar la información de debug
|
||||||
|
struct Debug
|
||||||
|
{
|
||||||
|
std::shared_ptr<Text> text = nullptr; // Objeto de texto para escribir
|
||||||
|
bool show = false; // Indica si se ha de mostrar la informacion por pantalla
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
if (Resource::get())
|
||||||
|
{
|
||||||
|
text = Resource::get()->getText("smb2");
|
||||||
|
if (!text)
|
||||||
|
{
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to retrieve debug_.text object!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
// [SINGLETON] Objeto privado
|
// [SINGLETON] Objeto privado
|
||||||
static Screen *screen_;
|
static Screen *screen_;
|
||||||
|
|
||||||
@@ -156,13 +185,9 @@ private:
|
|||||||
FlashEffect flash_effect_; // Variable para gestionar el efecto de flash
|
FlashEffect flash_effect_; // Variable para gestionar el efecto de flash
|
||||||
ShakeEffect shake_effect_; // Variable para gestionar el efecto de agitar la pantalla
|
ShakeEffect shake_effect_; // Variable para gestionar el efecto de agitar la pantalla
|
||||||
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool show_debug_info_ = true; // Indica si ha de mostrar/ocultar la información de la pantalla
|
Debug debug_info_; // Variable para gestionar la informaciçón de debug
|
||||||
#else
|
|
||||||
bool show_debug_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Arranca SDL VIDEO y crea la ventana
|
// Arranca SDL VIDEO y crea la ventana
|
||||||
bool initSDL();
|
bool initSDL();
|
||||||
|
|
||||||
@@ -250,10 +275,12 @@ public:
|
|||||||
|
|
||||||
// Activa / desactiva los shaders
|
// Activa / desactiva los shaders
|
||||||
void toggleShaders() { options.video.shaders = !options.video.shaders; }
|
void toggleShaders() { options.video.shaders = !options.video.shaders; }
|
||||||
|
#ifdef DEBUG
|
||||||
// Activa / desactiva la información de debug
|
// Activa / desactiva la información de debug
|
||||||
void toggleDebugInfo() { show_debug_info_ = !show_debug_info_; }
|
void toggleDebugInfo() { debug_info_.show = !debug_info_.show; }
|
||||||
|
void setDebugInfoEnabled(bool value) { debug_info_.show = value; }
|
||||||
|
void initDebugInfo() { debug_info_.init(); }
|
||||||
|
#endif
|
||||||
// Activa / desactiva el escalado entero
|
// Activa / desactiva el escalado entero
|
||||||
void toggleIntegerScale();
|
void toggleIntegerScale();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user