style: arreglant capçaleres
This commit is contained in:
@@ -24,9 +24,9 @@ LoadingScreen::LoadingScreen()
|
||||
color_loading_screen_sprite_(std::make_shared<SurfaceSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
||||
screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()),
|
||||
state_(LoadingState::SILENT1),
|
||||
state_(State::SILENT1),
|
||||
state_time_(0.0F),
|
||||
current_border_type_(BorderType::NONE),
|
||||
current_border_type_(Border::NONE),
|
||||
load_rect_{0, 0, 0, 1.0F} {
|
||||
// Configura la superficie donde se van a pintar los sprites
|
||||
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));
|
||||
@@ -40,7 +40,7 @@ LoadingScreen::LoadingScreen()
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor("white"));
|
||||
transitionToState(LoadingState::SILENT1);
|
||||
transitionToState(State::SILENT1);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -75,41 +75,41 @@ void LoadingScreen::initLineIndexArray() {
|
||||
}
|
||||
|
||||
// Transiciona a un nuevo estado
|
||||
void LoadingScreen::transitionToState(LoadingState new_state) {
|
||||
void LoadingScreen::transitionToState(State new_state) {
|
||||
state_ = new_state;
|
||||
state_time_ = 0.0F;
|
||||
|
||||
// Acciones específicas al entrar en cada estado
|
||||
switch (new_state) {
|
||||
case LoadingState::SILENT1:
|
||||
case LoadingState::SILENT2:
|
||||
current_border_type_ = BorderType::WHITE;
|
||||
case State::SILENT1:
|
||||
case State::SILENT2:
|
||||
current_border_type_ = Border::WHITE;
|
||||
Audio::get()->stopMusic();
|
||||
break;
|
||||
|
||||
case LoadingState::HEADER1:
|
||||
case LoadingState::HEADER2:
|
||||
current_border_type_ = BorderType::RED;
|
||||
case State::HEADER1:
|
||||
case State::HEADER2:
|
||||
current_border_type_ = Border::RED;
|
||||
// Reproducir sonido de cargar el header
|
||||
Audio::get()->playMusic("loading_sound1.ogg");
|
||||
break;
|
||||
|
||||
case LoadingState::BYTES1:
|
||||
case LoadingState::BYTES2:
|
||||
case LoadingState::LOADING_MONO:
|
||||
current_border_type_ = BorderType::YELLOW;
|
||||
case State::BYTES1:
|
||||
case State::BYTES2:
|
||||
case State::LOADING_MONO:
|
||||
current_border_type_ = Border::YELLOW;
|
||||
// Reproducir sonido de carga monocromática
|
||||
Audio::get()->playMusic("loading_sound2.ogg");
|
||||
break;
|
||||
|
||||
case LoadingState::LOADING_COLOR:
|
||||
current_border_type_ = BorderType::YELLOW;
|
||||
case State::LOADING_COLOR:
|
||||
current_border_type_ = Border::YELLOW;
|
||||
// Reproducir sonido de carga en color
|
||||
Audio::get()->playMusic("loading_sound3.ogg");
|
||||
break;
|
||||
|
||||
case LoadingState::COMPLETE:
|
||||
current_border_type_ = BorderType::WHITE;
|
||||
case State::COMPLETE:
|
||||
current_border_type_ = Border::WHITE;
|
||||
// Transicionar a la pantalla de título
|
||||
SceneManager::current = SceneManager::Scene::TITLE;
|
||||
SceneManager::options = SceneManager::Options::TITLE_WITH_LOADING_SCREEN;
|
||||
@@ -125,45 +125,45 @@ void LoadingScreen::updateState(float delta_time) {
|
||||
// Transiciones automáticas por tiempo para los estados iniciales
|
||||
// LOADING_MONO y LOADING_COLOR transicionan en sus propias funciones
|
||||
switch (state_) {
|
||||
case LoadingState::SILENT1:
|
||||
case State::SILENT1:
|
||||
if (state_time_ >= SILENT1_DURATION) {
|
||||
transitionToState(LoadingState::HEADER1);
|
||||
transitionToState(State::HEADER1);
|
||||
}
|
||||
break;
|
||||
|
||||
case LoadingState::HEADER1:
|
||||
case State::HEADER1:
|
||||
if (state_time_ >= HEADER1_DURATION) {
|
||||
transitionToState(LoadingState::BYTES1);
|
||||
transitionToState(State::BYTES1);
|
||||
}
|
||||
break;
|
||||
|
||||
case LoadingState::BYTES1:
|
||||
case State::BYTES1:
|
||||
if (state_time_ >= BYTES1_DURATION) {
|
||||
transitionToState(LoadingState::SILENT2);
|
||||
transitionToState(State::SILENT2);
|
||||
}
|
||||
break;
|
||||
|
||||
case LoadingState::SILENT2:
|
||||
case State::SILENT2:
|
||||
if (state_time_ >= SILENT2_DURATION) {
|
||||
transitionToState(LoadingState::HEADER2);
|
||||
transitionToState(State::HEADER2);
|
||||
}
|
||||
break;
|
||||
|
||||
case LoadingState::HEADER2:
|
||||
case State::HEADER2:
|
||||
if (state_time_ >= HEADER2_DURATION) {
|
||||
transitionToState(LoadingState::LOADING_MONO);
|
||||
transitionToState(State::LOADING_MONO);
|
||||
}
|
||||
break;
|
||||
|
||||
case LoadingState::BYTES2:
|
||||
case State::BYTES2:
|
||||
if (state_time_ >= BYTES2_DURATION) {
|
||||
transitionToState(LoadingState::COMPLETE);
|
||||
transitionToState(State::COMPLETE);
|
||||
}
|
||||
break;
|
||||
|
||||
case LoadingState::LOADING_MONO:
|
||||
case LoadingState::LOADING_COLOR:
|
||||
case LoadingState::COMPLETE:
|
||||
case State::LOADING_MONO:
|
||||
case State::LOADING_COLOR:
|
||||
case State::COMPLETE:
|
||||
// Estos estados se gestionan en updateMonoLoad/updateColorLoad
|
||||
break;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ void LoadingScreen::updateMonoLoad(float delta_time) {
|
||||
|
||||
// Verificar si ha completado todas las líneas
|
||||
if (CURRENT_LINE >= MONO_TOTAL_LINES) {
|
||||
transitionToState(LoadingState::LOADING_COLOR);
|
||||
transitionToState(State::LOADING_COLOR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ void LoadingScreen::updateColorLoad(float delta_time) {
|
||||
|
||||
// Verificar si ha completado todos los bloques
|
||||
if (CURRENT_BLOCK >= COLOR_TOTAL_BLOCKS) {
|
||||
transitionToState(LoadingState::BYTES2);
|
||||
transitionToState(State::BYTES2);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -328,25 +328,25 @@ void LoadingScreen::update() {
|
||||
|
||||
// Actualizar la carga según el estado actual
|
||||
switch (state_) {
|
||||
case LoadingState::SILENT1:
|
||||
case LoadingState::HEADER1:
|
||||
case LoadingState::BYTES1:
|
||||
case LoadingState::SILENT2:
|
||||
case LoadingState::HEADER2:
|
||||
case LoadingState::BYTES2:
|
||||
case State::SILENT1:
|
||||
case State::HEADER1:
|
||||
case State::BYTES1:
|
||||
case State::SILENT2:
|
||||
case State::HEADER2:
|
||||
case State::BYTES2:
|
||||
// Por ahora no hacen nada específico
|
||||
// Tú definirás la lógica de cada estado aquí
|
||||
break;
|
||||
|
||||
case LoadingState::LOADING_MONO:
|
||||
case State::LOADING_MONO:
|
||||
updateMonoLoad(DELTA_TIME);
|
||||
break;
|
||||
|
||||
case LoadingState::LOADING_COLOR:
|
||||
case State::LOADING_COLOR:
|
||||
updateColorLoad(DELTA_TIME);
|
||||
break;
|
||||
|
||||
case LoadingState::COMPLETE:
|
||||
case State::COMPLETE:
|
||||
// No hay más actualizaciones
|
||||
break;
|
||||
}
|
||||
@@ -396,16 +396,16 @@ void LoadingScreen::renderBorder() {
|
||||
if (Options::video.border.enabled) {
|
||||
// Dibuja el efecto de carga en el borde según el tipo actual
|
||||
switch (current_border_type_) {
|
||||
case BorderType::YELLOW:
|
||||
case Border::YELLOW:
|
||||
renderYellowBorder();
|
||||
break;
|
||||
case BorderType::RED:
|
||||
case Border::RED:
|
||||
renderRedBorder();
|
||||
break;
|
||||
case BorderType::WHITE:
|
||||
case Border::WHITE:
|
||||
renderWhiteBorder();
|
||||
break;
|
||||
case BorderType::NONE:
|
||||
case Border::NONE:
|
||||
// No renderizar borde
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -9,32 +9,35 @@
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
|
||||
// Estados de la secuencia de carga
|
||||
enum class LoadingState {
|
||||
SILENT1, // Pausa inicial antes de empezar
|
||||
HEADER1, // Cabecera
|
||||
BYTES1, // Datos
|
||||
SILENT2, // Segunda pausa
|
||||
HEADER2, // Cabecera pantalla
|
||||
LOADING_MONO, // Carga de pantalla monocromática (escaneo de líneas)
|
||||
LOADING_COLOR, // Carga de pantalla en color (bloques)
|
||||
BYTES2, // Datos
|
||||
COMPLETE // Carga completa
|
||||
};
|
||||
|
||||
// Tipos de borde para la pantalla de carga
|
||||
enum class BorderType {
|
||||
NONE,
|
||||
YELLOW,
|
||||
RED,
|
||||
WHITE
|
||||
};
|
||||
|
||||
class LoadingScreen {
|
||||
public:
|
||||
LoadingScreen(); // Constructor
|
||||
~LoadingScreen(); // Destructor
|
||||
void run(); // Bucle principal
|
||||
// Estados de la secuencia de carga
|
||||
enum class State {
|
||||
SILENT1, // Pausa inicial antes de empezar
|
||||
HEADER1, // Cabecera
|
||||
BYTES1, // Datos
|
||||
SILENT2, // Segunda pausa
|
||||
HEADER2, // Cabecera pantalla
|
||||
LOADING_MONO, // Carga de pantalla monocromática (escaneo de líneas)
|
||||
LOADING_COLOR, // Carga de pantalla en color (bloques)
|
||||
BYTES2, // Datos
|
||||
COMPLETE // Carga completa
|
||||
};
|
||||
|
||||
// Tipos de borde para la pantalla de carga
|
||||
enum class Border {
|
||||
NONE,
|
||||
YELLOW,
|
||||
RED,
|
||||
WHITE
|
||||
};
|
||||
|
||||
// --- Constructor y Destructor ---
|
||||
LoadingScreen();
|
||||
~LoadingScreen();
|
||||
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
|
||||
private:
|
||||
// --- Constantes de tiempo (en segundos) ---
|
||||
@@ -65,24 +68,24 @@ class LoadingScreen {
|
||||
|
||||
// --- Variables de estado ---
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
LoadingState state_; // Estado actual de la secuencia
|
||||
State state_; // Estado actual de la secuencia
|
||||
float state_time_; // Tiempo acumulado en el estado actual
|
||||
BorderType current_border_type_; // Tipo de borde actual
|
||||
Border current_border_type_; // Tipo de borde actual
|
||||
std::array<int, MONO_TOTAL_LINES> line_index_; // El orden en el que se procesan las 192 líneas de la pantalla de carga
|
||||
SDL_FRect load_rect_; // Rectángulo para dibujar la pantalla de carga
|
||||
|
||||
// --- Funciones ---
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Dibuja en pantalla
|
||||
static void checkEvents(); // Comprueba el manejador de eventos
|
||||
static void checkInput(); // Comprueba las entradas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(LoadingState new_state); // Transiciona a un nuevo estado
|
||||
void updateMonoLoad(float delta_time); // Gestiona la carga monocromática (time-based)
|
||||
void updateColorLoad(float delta_time); // Gestiona la carga en color (time-based)
|
||||
void renderBorder(); // Pinta el borde
|
||||
static void renderYellowBorder(); // Dibuja el efecto de carga amarillo y azul en el borde
|
||||
static void renderRedBorder(); // Dibuja el efecto de carga rojo y azul en el borde
|
||||
static void renderWhiteBorder(); // Dibuja el borde de color blanco
|
||||
void initLineIndexArray(); // Inicializa el array de índices de líneas
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Dibuja en pantalla
|
||||
static void checkEvents(); // Comprueba el manejador de eventos
|
||||
static void checkInput(); // Comprueba las entradas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(State new_state); // Transiciona a un nuevo estado
|
||||
void updateMonoLoad(float delta_time); // Gestiona la carga monocromática (time-based)
|
||||
void updateColorLoad(float delta_time); // Gestiona la carga en color (time-based)
|
||||
void renderBorder(); // Pinta el borde
|
||||
static void renderYellowBorder(); // Dibuja el efecto de carga amarillo y azul en el borde
|
||||
static void renderRedBorder(); // Dibuja el efecto de carga rojo y azul en el borde
|
||||
static void renderWhiteBorder(); // Dibuja el borde de color blanco
|
||||
void initLineIndexArray(); // Inicializa el array de índices de líneas
|
||||
};
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, SectionState, options, Section
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
|
||||
// Constructor
|
||||
@@ -21,7 +21,7 @@ Logo::Logo()
|
||||
since_1998_surface_(Resource::get()->getSurface("since_1998.gif")),
|
||||
since_1998_sprite_(std::make_shared<SurfaceSprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()),
|
||||
state_(LogoState::INITIAL),
|
||||
state_(State::INITIAL),
|
||||
state_time_(0.0F) {
|
||||
// Configura variables
|
||||
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
||||
@@ -54,7 +54,7 @@ void Logo::checkInput() {
|
||||
// Gestiona el logo de JAILGAME (time-based)
|
||||
void Logo::updateJAILGAMES(float delta_time) {
|
||||
// Solo actualizar durante el estado JAILGAMES_SLIDE_IN
|
||||
if (state_ != LogoState::JAILGAMES_SLIDE_IN) {
|
||||
if (state_ != State::JAILGAMES_SLIDE_IN) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,21 +97,21 @@ auto Logo::getColorIndex(float progress) const -> int {
|
||||
// Gestiona el color de las texturas
|
||||
void Logo::updateTextureColors() {
|
||||
switch (state_) {
|
||||
case LogoState::SINCE_1998_FADE_IN: {
|
||||
case State::SINCE_1998_FADE_IN: {
|
||||
// Fade-in de "Since 1998" de negro a blanco
|
||||
const float PROGRESS = state_time_ / SINCE_1998_FADE_DURATION;
|
||||
since_1998_color_ = color_[getColorIndex(PROGRESS)];
|
||||
break;
|
||||
}
|
||||
|
||||
case LogoState::DISPLAY: {
|
||||
case State::DISPLAY: {
|
||||
// Asegurar que ambos logos estén en blanco durante el display
|
||||
jailgames_color_ = color_.back(); // BRIGHT_WHITE
|
||||
since_1998_color_ = color_.back(); // BRIGHT_WHITE
|
||||
break;
|
||||
}
|
||||
|
||||
case LogoState::FADE_OUT: {
|
||||
case State::FADE_OUT: {
|
||||
// Fade-out de ambos logos de blanco a negro
|
||||
const float PROGRESS = 1.0F - (state_time_ / FADE_OUT_DURATION);
|
||||
const int COLOR_INDEX = getColorIndex(PROGRESS);
|
||||
@@ -127,7 +127,7 @@ void Logo::updateTextureColors() {
|
||||
}
|
||||
|
||||
// Transiciona a un nuevo estado
|
||||
void Logo::transitionToState(LogoState new_state) {
|
||||
void Logo::transitionToState(State new_state) {
|
||||
state_ = new_state;
|
||||
state_time_ = 0.0F;
|
||||
}
|
||||
@@ -138,38 +138,38 @@ void Logo::updateState(float delta_time) {
|
||||
|
||||
// Gestionar transiciones entre estados basándose en el tiempo
|
||||
switch (state_) {
|
||||
case LogoState::INITIAL:
|
||||
case State::INITIAL:
|
||||
if (state_time_ >= INITIAL_DELAY) {
|
||||
transitionToState(LogoState::JAILGAMES_SLIDE_IN);
|
||||
transitionToState(State::JAILGAMES_SLIDE_IN);
|
||||
}
|
||||
break;
|
||||
|
||||
case LogoState::JAILGAMES_SLIDE_IN:
|
||||
case State::JAILGAMES_SLIDE_IN:
|
||||
if (state_time_ >= JAILGAMES_SLIDE_DURATION) {
|
||||
transitionToState(LogoState::SINCE_1998_FADE_IN);
|
||||
transitionToState(State::SINCE_1998_FADE_IN);
|
||||
}
|
||||
break;
|
||||
|
||||
case LogoState::SINCE_1998_FADE_IN:
|
||||
case State::SINCE_1998_FADE_IN:
|
||||
if (state_time_ >= SINCE_1998_FADE_DURATION) {
|
||||
transitionToState(LogoState::DISPLAY);
|
||||
transitionToState(State::DISPLAY);
|
||||
}
|
||||
break;
|
||||
|
||||
case LogoState::DISPLAY:
|
||||
case State::DISPLAY:
|
||||
if (state_time_ >= DISPLAY_DURATION) {
|
||||
transitionToState(LogoState::FADE_OUT);
|
||||
transitionToState(State::FADE_OUT);
|
||||
}
|
||||
break;
|
||||
|
||||
case LogoState::FADE_OUT:
|
||||
case State::FADE_OUT:
|
||||
if (state_time_ >= FADE_OUT_DURATION) {
|
||||
transitionToState(LogoState::END);
|
||||
transitionToState(State::END);
|
||||
endSection();
|
||||
}
|
||||
break;
|
||||
|
||||
case LogoState::END:
|
||||
case State::END:
|
||||
// Estado final, no hacer nada
|
||||
break;
|
||||
}
|
||||
@@ -180,11 +180,11 @@ void Logo::update() {
|
||||
// Obtener delta time desde el último frame
|
||||
const float DELTA_TIME = delta_timer_->tick();
|
||||
|
||||
checkInput(); // Comprueba las entradas
|
||||
updateState(DELTA_TIME); // Actualiza el estado y gestiona transiciones
|
||||
updateJAILGAMES(DELTA_TIME); // Gestiona el logo de JAILGAME
|
||||
updateTextureColors(); // Gestiona el color de las texturas
|
||||
Screen::get()->update(DELTA_TIME); // Actualiza el objeto Screen
|
||||
checkInput(); // Comprueba las entradas
|
||||
updateState(DELTA_TIME); // Actualiza el estado y gestiona transiciones
|
||||
updateJAILGAMES(DELTA_TIME); // Gestiona el logo de JAILGAME
|
||||
updateTextureColors(); // Gestiona el color de las texturas
|
||||
Screen::get()->update(DELTA_TIME); // Actualiza el objeto Screen
|
||||
}
|
||||
|
||||
// Dibuja en pantalla
|
||||
|
||||
@@ -9,21 +9,24 @@
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
|
||||
// Estados de la secuencia del logo
|
||||
enum class LogoState {
|
||||
INITIAL, // Espera inicial
|
||||
JAILGAMES_SLIDE_IN, // Las líneas de JAILGAMES se deslizan hacia el centro
|
||||
SINCE_1998_FADE_IN, // Aparición gradual del texto "Since 1998"
|
||||
DISPLAY, // Logo completo visible
|
||||
FADE_OUT, // Desaparición gradual
|
||||
END // Fin de la secuencia
|
||||
};
|
||||
|
||||
class Logo {
|
||||
public:
|
||||
Logo(); // Constructor
|
||||
~Logo() = default; // Destructor
|
||||
void run(); // Bucle principal
|
||||
// --- Enumeraciones ---
|
||||
enum class State {
|
||||
INITIAL, // Espera inicial
|
||||
JAILGAMES_SLIDE_IN, // Las líneas de JAILGAMES se deslizan hacia el centro
|
||||
SINCE_1998_FADE_IN, // Aparición gradual del texto "Since 1998"
|
||||
DISPLAY, // Logo completo visible
|
||||
FADE_OUT, // Desaparición gradual
|
||||
END // Fin de la secuencia
|
||||
};
|
||||
|
||||
// --- Constructor y Destructor ---
|
||||
Logo();
|
||||
~Logo() = default;
|
||||
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
|
||||
private:
|
||||
// --- Constantes de tiempo (en segundos) ---
|
||||
@@ -38,30 +41,30 @@ class Logo {
|
||||
static constexpr int JAILGAMES_DEST_X = 37; // Posición X de destino para JAILGAMES
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
std::shared_ptr<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
|
||||
std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998"
|
||||
std::shared_ptr<Surface> jailgames_surface_ = nullptr; // Textura con los graficos "JAILGAMES"
|
||||
std::shared_ptr<Surface> since_1998_surface_ = nullptr; // Textura con los graficos "Since 1998"
|
||||
std::vector<std::shared_ptr<SurfaceSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||
std::shared_ptr<SurfaceSprite> since_1998_sprite_; // SSprite para manejar la textura2
|
||||
std::shared_ptr<SurfaceSprite> since_1998_sprite_ = nullptr; // SSprite para manejar la textura2
|
||||
Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES"
|
||||
Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998"
|
||||
|
||||
// --- Variables de estado ---
|
||||
std::vector<Uint8> color_; // Vector con los colores para el fadeF
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
LogoState state_; // Estado actual de la secuencia
|
||||
float state_time_; // Tiempo acumulado en el estado actual
|
||||
std::vector<Uint8> color_; // Vector con los colores para el fadeF
|
||||
std::unique_ptr<DeltaTimer> delta_timer_ = nullptr; // Timer para delta time
|
||||
State state_ = State::INITIAL; // Estado actual de la secuencia
|
||||
float state_time_ = 0.0F; // Tiempo acumulado en el estado actual
|
||||
|
||||
// --- Funciones ---
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Dibuja en pantalla
|
||||
static void checkEvents(); // Comprueba el manejador de eventos
|
||||
static void checkInput(); // Comprueba las entradas
|
||||
void updateJAILGAMES(float delta_time); // Gestiona el logo de JAILGAME (time-based)
|
||||
void updateTextureColors(); // Gestiona el color de las texturas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(LogoState new_state); // Transiciona a un nuevo estado
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Dibuja en pantalla
|
||||
static void checkEvents(); // Comprueba el manejador de eventos
|
||||
static void checkInput(); // Comprueba las entradas
|
||||
void updateJAILGAMES(float delta_time); // Gestiona el logo de JAILGAME (time-based)
|
||||
void updateTextureColors(); // Gestiona el color de las texturas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(State new_state); // Transiciona a un nuevo estado
|
||||
[[nodiscard]] auto getColorIndex(float progress) const -> int; // Calcula el índice de color según el progreso (0.0-1.0)
|
||||
static void endSection(); // Termina la sección
|
||||
void initColors(); // Inicializa el vector de colores
|
||||
void initSprites(); // Crea los sprites de cada linea
|
||||
static void endSection(); // Termina la sección
|
||||
void initColors(); // Inicializa el vector de colores
|
||||
void initSprites(); // Crea los sprites de cada linea
|
||||
};
|
||||
@@ -11,11 +11,11 @@
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement
|
||||
#include "game/options.hpp" // Para Options, options, SectionState, Section
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "utils/utils.hpp" // Para stringToColor, PaletteColor, playMusic
|
||||
|
||||
// Constructor
|
||||
@@ -33,7 +33,7 @@ Title::Title()
|
||||
fade_accumulator_(0.0F),
|
||||
current_delta_(0.0F) {
|
||||
// Inicializa variables
|
||||
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
||||
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? State::SHOW_LOADING_SCREEN : State::SHOW_MENU;
|
||||
SceneManager::current = SceneManager::Scene::TITLE;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
initMarquee();
|
||||
@@ -58,10 +58,10 @@ void Title::initMarquee() {
|
||||
|
||||
// Pre-calcular anchos de caracteres para eficiencia
|
||||
for (size_t i = 0; i < long_text_.length(); ++i) {
|
||||
TitleLetter l;
|
||||
l.letter = long_text_[i]; // char directo, no substring
|
||||
l.x = MARQUEE_START_X; // Usar constante
|
||||
l.width = marquee_text_->lenght(std::string(1, long_text_[i])); // Pre-calcular ancho
|
||||
Glyph l;
|
||||
l.letter = long_text_[i]; // char directo, no substring
|
||||
l.x = MARQUEE_START_X; // Usar constante
|
||||
l.width = marquee_text_->lenght(std::string(1, long_text_[i])); // Pre-calcular ancho
|
||||
l.enabled = false;
|
||||
letters_.push_back(l);
|
||||
}
|
||||
@@ -111,8 +111,8 @@ void Title::checkInput() {
|
||||
}
|
||||
|
||||
if (Input::get()->checkInput(InputAction::ACCEPT, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
||||
if (state_ == TitleState::SHOW_LOADING_SCREEN) {
|
||||
transitionToState(TitleState::FADE_LOADING_SCREEN);
|
||||
if (state_ == State::SHOW_LOADING_SCREEN) {
|
||||
transitionToState(State::FADE_LOADING_SCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,11 +158,10 @@ void Title::renderMarquee() {
|
||||
const auto& letter = letters_[i];
|
||||
if (letter.enabled) {
|
||||
marquee_text_->writeColored(
|
||||
static_cast<int>(letter.x), // Conversión explícita float→int
|
||||
static_cast<int>(MARQUEE_Y), // Usar constante
|
||||
std::string(1, letter.letter), // Convertir char a string
|
||||
static_cast<Uint8>(PaletteColor::BRIGHT_RED)
|
||||
);
|
||||
static_cast<int>(letter.x), // Conversión explícita float→int
|
||||
static_cast<int>(MARQUEE_Y), // Usar constante
|
||||
std::string(1, letter.letter), // Convertir char a string
|
||||
static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,23 +186,23 @@ void Title::updateState(float delta_time) {
|
||||
state_time_ += delta_time;
|
||||
|
||||
switch (state_) {
|
||||
case TitleState::SHOW_LOADING_SCREEN:
|
||||
case State::SHOW_LOADING_SCREEN:
|
||||
if (state_time_ >= SHOW_LOADING_DURATION) {
|
||||
transitionToState(TitleState::FADE_LOADING_SCREEN);
|
||||
transitionToState(State::FADE_LOADING_SCREEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case TitleState::FADE_LOADING_SCREEN:
|
||||
case State::FADE_LOADING_SCREEN:
|
||||
fade_accumulator_ += delta_time;
|
||||
if (fade_accumulator_ >= FADE_STEP_INTERVAL) {
|
||||
fade_accumulator_ = 0.0F;
|
||||
if (loading_screen_surface_->fadeSubPalette()) {
|
||||
transitionToState(TitleState::SHOW_MENU);
|
||||
transitionToState(State::SHOW_MENU);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TitleState::SHOW_MENU:
|
||||
case State::SHOW_MENU:
|
||||
// Actualiza la marquesina
|
||||
updateMarquee(delta_time);
|
||||
|
||||
@@ -220,7 +219,7 @@ void Title::updateState(float delta_time) {
|
||||
}
|
||||
|
||||
// Transiciona a un nuevo estado
|
||||
void Title::transitionToState(TitleState new_state) {
|
||||
void Title::transitionToState(State new_state) {
|
||||
state_ = new_state;
|
||||
state_time_ = 0.0F;
|
||||
fade_accumulator_ = 0.0F;
|
||||
@@ -233,7 +232,7 @@ void Title::render() {
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
switch (state_) {
|
||||
case TitleState::SHOW_MENU:
|
||||
case State::SHOW_MENU:
|
||||
// Dibuja la textura de fondo
|
||||
bg_surface_->render(0, 0);
|
||||
|
||||
@@ -246,8 +245,8 @@ void Title::render() {
|
||||
}
|
||||
break;
|
||||
|
||||
case TitleState::SHOW_LOADING_SCREEN:
|
||||
case TitleState::FADE_LOADING_SCREEN:
|
||||
case State::SHOW_LOADING_SCREEN:
|
||||
case State::FADE_LOADING_SCREEN:
|
||||
loading_screen_sprite_->render();
|
||||
title_logo_sprite_->render();
|
||||
break;
|
||||
|
||||
@@ -7,20 +7,29 @@
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
class Text; // Forward declaration
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
class Text; // Forward declaration
|
||||
|
||||
class Title {
|
||||
public:
|
||||
// --- Constructor y Destructor ---
|
||||
Title();
|
||||
~Title() = default;
|
||||
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
|
||||
private:
|
||||
struct TitleLetter {
|
||||
// --- Estructuras y enumeraciones ---
|
||||
struct Glyph {
|
||||
char letter; // Letra a escribir (char es más eficiente que std::string)
|
||||
float x; // Posición en el eje x (float para precisión con delta time)
|
||||
float width; // Ancho pre-calculado del carácter
|
||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||
};
|
||||
|
||||
enum class TitleState {
|
||||
enum class State {
|
||||
SHOW_LOADING_SCREEN,
|
||||
FADE_LOADING_SCREEN,
|
||||
SHOW_MENU
|
||||
@@ -39,7 +48,7 @@ class Title {
|
||||
static constexpr float MARQUEE_Y = 184.0F; // Posición Y
|
||||
static constexpr float MARQUEE_LETTER_SPACING = 1.0F; // Espaciado entre letras
|
||||
|
||||
// Objetos y punteros
|
||||
// --- Objetos y punteros ---
|
||||
std::shared_ptr<Surface> title_logo_surface_; // Textura con los graficos
|
||||
std::shared_ptr<SurfaceSprite> title_logo_sprite_; // SSprite para manejar la surface
|
||||
std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga
|
||||
@@ -49,47 +58,31 @@ class Title {
|
||||
std::shared_ptr<SurfaceSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
|
||||
|
||||
// --- Variables de estado ---
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
std::shared_ptr<Text> marquee_text_; // Cache del texto para marquesina
|
||||
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
||||
std::vector<TitleLetter> letters_; // Vector con las letras de la marquesina
|
||||
int first_active_letter_; // Primera letra activa (optimización)
|
||||
int last_active_letter_; // Última letra activa (optimización)
|
||||
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
|
||||
SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
|
||||
TitleState state_; // Estado en el que se encuentra el bucle principal
|
||||
float state_time_; // Tiempo acumulado en el estado actual
|
||||
float fade_accumulator_; // Acumulador para controlar el fade por tiempo
|
||||
float current_delta_; // Delta time del frame actual
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
std::shared_ptr<Text> marquee_text_; // Cache del texto para marquesina
|
||||
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
||||
std::vector<Glyph> letters_; // Vector con las letras de la marquesina
|
||||
int first_active_letter_; // Primera letra activa (optimización)
|
||||
int last_active_letter_; // Última letra activa (optimización)
|
||||
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
|
||||
SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
|
||||
State state_; // Estado en el que se encuentra el bucle principal
|
||||
float state_time_; // Tiempo acumulado en el estado actual
|
||||
float fade_accumulator_; // Acumulador para controlar el fade por tiempo
|
||||
float current_delta_; // Delta time del frame actual
|
||||
|
||||
// --- Funciones ---
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Dibuja en pantalla
|
||||
void checkEvents(); // Comprueba el manejador de eventos
|
||||
void checkInput(); // Comprueba las entradas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(TitleState new_state); // Transiciona a un nuevo estado
|
||||
void initMarquee(); // Inicializa la marquesina
|
||||
void updateMarquee(float delta_time); // Actualiza la marquesina (time-based)
|
||||
void renderMarquee(); // Dibuja la marquesina
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Dibuja en pantalla
|
||||
void checkEvents(); // Comprueba el manejador de eventos
|
||||
void checkInput(); // Comprueba las entradas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(State new_state); // Transiciona a un nuevo estado
|
||||
void initMarquee(); // Inicializa la marquesina
|
||||
void updateMarquee(float delta_time); // Actualiza la marquesina (time-based)
|
||||
void renderMarquee(); // Dibuja la marquesina
|
||||
void moveCheevosList(int direction, float delta_time); // Desplaza la lista de logros (time-based)
|
||||
|
||||
// Rellena la surface de fondo con todos los gráficos
|
||||
void fillSurface();
|
||||
|
||||
// Crea y rellena la surface para mostrar los logros
|
||||
void createCheevosTexture();
|
||||
|
||||
// Oculta la lista de logros
|
||||
void hideCheevosList();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Title();
|
||||
|
||||
// Destructor
|
||||
~Title() = default;
|
||||
|
||||
// Bucle principal
|
||||
void run();
|
||||
void fillSurface(); // Rellena la surface de fondo con todos los gráficos
|
||||
void createCheevosTexture(); // Crea y rellena la surface para mostrar los logros
|
||||
void hideCheevosList(); // Oculta la lista de logros
|
||||
};
|
||||
Reference in New Issue
Block a user