revisió de capçaleres
This commit is contained in:
110
source/fade.h
110
source/fade.h
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_rect.h> // Para SDL_FRect
|
||||
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
|
||||
#include <SDL3/SDL_stdinc.h> // Para Uint8, Uint16
|
||||
#include <vector> // Para vector
|
||||
#include <SDL3/SDL_rect.h>
|
||||
#include <SDL3/SDL_render.h>
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <vector>
|
||||
|
||||
// Tipos de fundido
|
||||
enum class FadeType : Uint8
|
||||
@@ -31,72 +31,62 @@ enum class FadeState : Uint8
|
||||
FINISHED = 4,
|
||||
};
|
||||
|
||||
// Clase Fade
|
||||
class Fade
|
||||
{
|
||||
private:
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Texture *backbuffer_; // Textura para usar como backbuffer con SDL_TEXTUREACCESS_TARGET
|
||||
|
||||
// Variables
|
||||
FadeType type_; // Tipo de fade a realizar
|
||||
FadeMode mode_; // Modo de fade a realizar
|
||||
FadeState state_ = FadeState::NOT_ENABLED; // Estado actual del objeto
|
||||
Uint16 counter_; // Contador interno
|
||||
Uint8 r_, g_, b_, a_; // Colores para el fade
|
||||
SDL_FRect rect1_; // Rectangulo usado para crear los efectos de transición
|
||||
SDL_FRect rect2_; // Rectangulo usado para crear los efectos de transición
|
||||
int num_squares_width_; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE
|
||||
int num_squares_height_; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE
|
||||
std::vector<SDL_FRect> square_; // Vector con los indices de los cuadrados para el FadeType::RANDOM_SQUARE
|
||||
int fade_random_squares_delay_; // Duración entre cada pintado de cuadrados
|
||||
int fade_random_squares_mult_; // Cantidad de cuadrados que se pintaran cada vez
|
||||
int post_duration_ = 0; // Duración posterior del fade tras finalizar
|
||||
int post_counter_ = 0; // Contador para la duración posterior
|
||||
int pre_duration_ = 0; // Duración previa del fade antes de iniciar
|
||||
int pre_counter_ = 0; // Contador para la duración previa
|
||||
int value_ = 0; // Estado actual del fade entre 0 y 100
|
||||
|
||||
// Inicializa las variables
|
||||
void init();
|
||||
|
||||
// Limpia el backbuffer
|
||||
void cleanBackbuffer(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
// Calcula el valor del estado del fade
|
||||
int calculateValue(int min, int max, int current);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
// --- Constructores y destructor ---
|
||||
Fade();
|
||||
|
||||
// Destructor
|
||||
~Fade();
|
||||
|
||||
// Resetea algunas variables para volver a hacer el fade sin perder ciertos parametros
|
||||
void reset();
|
||||
// --- Métodos principales ---
|
||||
void reset(); // Resetea variables para reutilizar el fade
|
||||
void render(); // Dibuja la transición en pantalla
|
||||
void update(); // Actualiza el estado interno
|
||||
void activate(); // Activa el fade
|
||||
|
||||
// Pinta una transición en pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza las variables internas
|
||||
void update();
|
||||
|
||||
// Activa el fade
|
||||
void activate();
|
||||
|
||||
// Establece el color del fade
|
||||
// --- Configuración ---
|
||||
void setColor(Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
// Getters
|
||||
int getValue() const { return value_; }
|
||||
bool isEnabled() const { return state_ != FadeState::NOT_ENABLED; }
|
||||
bool hasEnded() const { return state_ == FadeState::FINISHED; }
|
||||
|
||||
// Setters
|
||||
void setType(FadeType type) { type_ = type; }
|
||||
void setMode(FadeMode mode) { mode_ = mode; }
|
||||
void setPostDuration(int value) { post_duration_ = value; }
|
||||
void setPreDuration(int value) { pre_duration_ = value; }
|
||||
|
||||
// --- Getters ---
|
||||
int getValue() const { return value_; }
|
||||
bool isEnabled() const { return state_ != FadeState::NOT_ENABLED; }
|
||||
bool hasEnded() const { return state_ == FadeState::FINISHED; }
|
||||
|
||||
private:
|
||||
// --- Objetos y punteros ---
|
||||
SDL_Renderer *renderer_; // Renderizador de la ventana
|
||||
SDL_Texture *backbuffer_; // Backbuffer para efectos
|
||||
|
||||
// --- Variables de estado ---
|
||||
FadeType type_; // Tipo de fade
|
||||
FadeMode mode_; // Modo de fade
|
||||
FadeState state_ = FadeState::NOT_ENABLED; // Estado actual
|
||||
Uint16 counter_; // Contador interno
|
||||
|
||||
// --- Parámetros de color y geometría ---
|
||||
Uint8 r_, g_, b_, a_; // Color del fade
|
||||
SDL_FRect rect1_, rect2_; // Rectángulos para efectos
|
||||
|
||||
// --- Parámetros para RANDOM_SQUARE ---
|
||||
int num_squares_width_; // Cuadrados en horizontal
|
||||
int num_squares_height_; // Cuadrados en vertical
|
||||
std::vector<SDL_FRect> square_; // Vector de cuadrados
|
||||
int fade_random_squares_delay_; // Delay entre cuadrados
|
||||
int fade_random_squares_mult_; // Cuadrados por paso
|
||||
|
||||
// --- Temporizadores ---
|
||||
int post_duration_ = 0, post_counter_ = 0;
|
||||
int pre_duration_ = 0, pre_counter_ = 0;
|
||||
|
||||
// --- Valor de progreso ---
|
||||
int value_ = 0; // Estado del fade (0-100)
|
||||
|
||||
// --- Métodos internos ---
|
||||
void init(); // Inicializa variables
|
||||
void cleanBackbuffer(Uint8 r, Uint8 g, Uint8 b, Uint8 a); // Limpia el backbuffer
|
||||
int calculateValue(int min, int max, int current); // Calcula el valor del fade
|
||||
};
|
||||
Reference in New Issue
Block a user