forked from jaildesigner-jailgames/jaildoctors_dilemma
fix: les notificacions ja no embruten la pantalla de càrrega
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "texture.h" // for Texture
|
||||
#include "utils.h" // for Color, stringToColor, Palette
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
LoadingScreen::LoadingScreen()
|
||||
@@ -40,6 +41,16 @@ LoadingScreen::LoadingScreen()
|
||||
loading_sound2_ = resource_->getMusic("loading_sound2.ogg");
|
||||
loading_sound3_ = resource_->getMusic("loading_sound3.ogg");
|
||||
|
||||
texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, options.game.width, options.game.height);
|
||||
if (texture_ == nullptr)
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "LoadingScreen::texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
clearTexture();
|
||||
|
||||
// Inicializa variables
|
||||
options.section.section = Section::LOADING_SCREEN;
|
||||
options.section.subsection = Subsection::NONE;
|
||||
@@ -71,6 +82,7 @@ LoadingScreen::LoadingScreen()
|
||||
LoadingScreen::~LoadingScreen()
|
||||
{
|
||||
JA_StopMusic();
|
||||
SDL_DestroyTexture(texture_);
|
||||
}
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
@@ -193,6 +205,7 @@ void LoadingScreen::update()
|
||||
checkInput();
|
||||
updateCounter();
|
||||
updateLoad();
|
||||
fillTexture();
|
||||
screen_->update();
|
||||
}
|
||||
}
|
||||
@@ -212,8 +225,8 @@ void LoadingScreen::render()
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen_->start();
|
||||
|
||||
// Dibuja la pantalla de carga
|
||||
renderLoad();
|
||||
// Copila la textura a la pantalla
|
||||
SDL_RenderCopy(renderer_, texture_, nullptr, nullptr);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen_->render();
|
||||
@@ -279,3 +292,32 @@ void LoadingScreen::recreateLoadingScreen()
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen_->render();
|
||||
}
|
||||
|
||||
// Dibuja sobre la textura
|
||||
void LoadingScreen::fillTexture()
|
||||
{
|
||||
// Empieza a dibujar en la textura
|
||||
auto temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, texture_);
|
||||
|
||||
// Dibuja la pantalla de carga
|
||||
renderLoad();
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
}
|
||||
|
||||
// Limpia la textura
|
||||
void LoadingScreen::clearTexture()
|
||||
{
|
||||
// Empieza a dibujar en la textura
|
||||
auto temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, texture_);
|
||||
|
||||
// Limpia
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
}
|
||||
@@ -37,6 +37,7 @@ private:
|
||||
JA_Music_t *loading_sound3_; // Sonidos para imitar la carga tipo spectrum
|
||||
int line_index_[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
|
||||
SDL_Rect load_rect_ = {0, 0, 51, 1}; // Rectangulo para dibujar la pantalla de carga
|
||||
SDL_Texture *texture_; // Textura para dibujar la pantalla de carga
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
@@ -65,6 +66,12 @@ private:
|
||||
// Reconstruye la pantalla de carga
|
||||
void recreateLoadingScreen();
|
||||
|
||||
// Dibuja sobre la textura
|
||||
void fillTexture();
|
||||
|
||||
// Limpia la textura
|
||||
void clearTexture();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
LoadingScreen();
|
||||
|
||||
Reference in New Issue
Block a user