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 "sprite.h" // for Sprite
|
||||||
#include "texture.h" // for Texture
|
#include "texture.h" // for Texture
|
||||||
#include "utils.h" // for Color, stringToColor, Palette
|
#include "utils.h" // for Color, stringToColor, Palette
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
LoadingScreen::LoadingScreen()
|
LoadingScreen::LoadingScreen()
|
||||||
@@ -40,6 +41,16 @@ LoadingScreen::LoadingScreen()
|
|||||||
loading_sound2_ = resource_->getMusic("loading_sound2.ogg");
|
loading_sound2_ = resource_->getMusic("loading_sound2.ogg");
|
||||||
loading_sound3_ = resource_->getMusic("loading_sound3.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
|
// Inicializa variables
|
||||||
options.section.section = Section::LOADING_SCREEN;
|
options.section.section = Section::LOADING_SCREEN;
|
||||||
options.section.subsection = Subsection::NONE;
|
options.section.subsection = Subsection::NONE;
|
||||||
@@ -71,6 +82,7 @@ LoadingScreen::LoadingScreen()
|
|||||||
LoadingScreen::~LoadingScreen()
|
LoadingScreen::~LoadingScreen()
|
||||||
{
|
{
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
SDL_DestroyTexture(texture_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
@@ -193,6 +205,7 @@ void LoadingScreen::update()
|
|||||||
checkInput();
|
checkInput();
|
||||||
updateCounter();
|
updateCounter();
|
||||||
updateLoad();
|
updateLoad();
|
||||||
|
fillTexture();
|
||||||
screen_->update();
|
screen_->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,8 +225,8 @@ void LoadingScreen::render()
|
|||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen_->start();
|
screen_->start();
|
||||||
|
|
||||||
// Dibuja la pantalla de carga
|
// Copila la textura a la pantalla
|
||||||
renderLoad();
|
SDL_RenderCopy(renderer_, texture_, nullptr, nullptr);
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen_->render();
|
screen_->render();
|
||||||
@@ -279,3 +292,32 @@ void LoadingScreen::recreateLoadingScreen()
|
|||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen_->render();
|
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);
|
||||||
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||||
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
||||||
#include <SDL2/SDL_stdinc.h> // for Uint32
|
#include <SDL2/SDL_stdinc.h> // for Uint32
|
||||||
#include <memory> // for shared_ptr
|
#include <memory> // for shared_ptr
|
||||||
class Asset; // lines 8-8
|
class Asset; // lines 8-8
|
||||||
class Input; // lines 9-9
|
class Input; // lines 9-9
|
||||||
class Resource; // lines 10-10
|
class Resource; // lines 10-10
|
||||||
class Screen; // lines 11-11
|
class Screen; // lines 11-11
|
||||||
class Sprite; // lines 12-12
|
class Sprite; // lines 12-12
|
||||||
class Texture; // lines 13-13
|
class Texture; // lines 13-13
|
||||||
struct JA_Music_t; // lines 14-14
|
struct JA_Music_t; // lines 14-14
|
||||||
|
|
||||||
class LoadingScreen
|
class LoadingScreen
|
||||||
{
|
{
|
||||||
@@ -37,6 +37,7 @@ private:
|
|||||||
JA_Music_t *loading_sound3_; // Sonidos para imitar la carga tipo spectrum
|
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
|
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_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
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
@@ -65,6 +66,12 @@ private:
|
|||||||
// Reconstruye la pantalla de carga
|
// Reconstruye la pantalla de carga
|
||||||
void recreateLoadingScreen();
|
void recreateLoadingScreen();
|
||||||
|
|
||||||
|
// Dibuja sobre la textura
|
||||||
|
void fillTexture();
|
||||||
|
|
||||||
|
// Limpia la textura
|
||||||
|
void clearTexture();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
LoadingScreen();
|
LoadingScreen();
|
||||||
|
|||||||
Reference in New Issue
Block a user