linter
This commit is contained in:
@@ -55,41 +55,41 @@ void Notifier::update() {
|
||||
// Si la notificación anterior está "saliendo", no hagas nada
|
||||
if (!notifications_.empty() && ¬ification != ¬ifications_.front()) {
|
||||
const auto& previous_notification = *(std::prev(¬ification));
|
||||
if (previous_notification.state == NotificationStatus::RISING) {
|
||||
if (previous_notification.state == Status::RISING) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (notification.state) {
|
||||
case NotificationStatus::RISING: {
|
||||
case Status::RISING: {
|
||||
const int DIRECTION = 1;
|
||||
notification.rect.y += DIRECTION;
|
||||
|
||||
if (notification.rect.y == notification.y) {
|
||||
notification.state = NotificationStatus::STAY;
|
||||
notification.state = Status::STAY;
|
||||
notification.start_time = SDL_GetTicks();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NotificationStatus::STAY: {
|
||||
case Status::STAY: {
|
||||
notification.elapsed_time = SDL_GetTicks() - notification.start_time;
|
||||
if (notification.elapsed_time >= notification.display_duration) {
|
||||
notification.state = NotificationStatus::VANISHING;
|
||||
notification.state = Status::VANISHING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NotificationStatus::VANISHING: {
|
||||
case Status::VANISHING: {
|
||||
const int DIRECTION = -1;
|
||||
notification.rect.y += DIRECTION;
|
||||
|
||||
if (notification.rect.y == notification.y - notification.travel_dist) {
|
||||
notification.state = NotificationStatus::FINISHED;
|
||||
notification.state = Status::FINISHED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NotificationStatus::FINISHED:
|
||||
case Status::FINISHED:
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -106,7 +106,7 @@ void Notifier::update() {
|
||||
void Notifier::clearFinishedNotifications() {
|
||||
notifications_.erase(
|
||||
std::remove_if(notifications_.begin(), notifications_.end(), [](const Notification& notification) {
|
||||
return notification.state == NotificationStatus::FINISHED;
|
||||
return notification.state == Status::FINISHED;
|
||||
}),
|
||||
notifications_.end());
|
||||
}
|
||||
@@ -142,7 +142,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
||||
text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is;
|
||||
const float WIDTH = Options::game.width - (PADDING_OUT * 2);
|
||||
const float HEIGHT = (TEXT_SIZE * texts.size()) + (PADDING_IN_V * 2);
|
||||
const auto SHAPE = NotificationShape::SQUARED;
|
||||
const auto SHAPE = Shape::SQUARED;
|
||||
|
||||
// Posición horizontal
|
||||
float desp_h = ((Options::game.width / 2) - (WIDTH / 2));
|
||||
@@ -179,7 +179,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
||||
|
||||
// Dibuja el fondo de la notificación
|
||||
SDL_FRect rect;
|
||||
if (SHAPE == NotificationShape::ROUNDED) {
|
||||
if (SHAPE == Shape::ROUNDED) {
|
||||
rect = {4, 0, WIDTH - (4 * 2), HEIGHT};
|
||||
n.surface->fillRect(&rect, bg_color_);
|
||||
|
||||
@@ -193,7 +193,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
||||
n.surface->fillRect(&rect, bg_color_);
|
||||
}
|
||||
|
||||
else if (SHAPE == NotificationShape::SQUARED) {
|
||||
else if (SHAPE == Shape::SQUARED) {
|
||||
n.surface->clear(bg_color_);
|
||||
SDL_FRect squared_rect = {0, 0, n.surface->getWidth(), n.surface->getHeight()};
|
||||
n.surface->drawRectBorder(&squared_rect, static_cast<Uint8>(PaletteColor::CYAN));
|
||||
@@ -245,7 +245,7 @@ bool Notifier::isActive() { return !notifications_.empty(); }
|
||||
void Notifier::clearNotifications() {
|
||||
for (auto& notification : notifications_) {
|
||||
if (notification.can_be_removed) {
|
||||
notification.state = NotificationStatus::FINISHED;
|
||||
notification.state = Status::FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,50 +28,36 @@ class Notifier {
|
||||
// [SINGLETON] Objeto notifier
|
||||
static Notifier* notifier;
|
||||
|
||||
enum class NotificationStatus {
|
||||
enum class Status {
|
||||
RISING,
|
||||
STAY,
|
||||
VANISHING,
|
||||
FINISHED,
|
||||
};
|
||||
|
||||
enum class NotificationShape {
|
||||
enum class Shape {
|
||||
ROUNDED,
|
||||
SQUARED,
|
||||
};
|
||||
|
||||
struct Notification {
|
||||
std::shared_ptr<Surface> surface; // Superficie asociada a la notificación
|
||||
std::shared_ptr<SurfaceSprite> sprite; // Sprite asociado para gráficos o animaciones
|
||||
std::vector<std::string> texts; // Lista de textos incluidos en la notificación
|
||||
NotificationStatus state; // Estado actual de la notificación (RISING, SHOWING, etc.)
|
||||
NotificationShape shape; // Forma de la notificación (ej. SQUARED o ROUNDED)
|
||||
SDL_FRect rect; // Dimensiones y posición de la notificación en pantalla
|
||||
int y; // Posición actual en el eje Y
|
||||
int travel_dist; // Distancia a recorrer (por ejemplo, en animaciones)
|
||||
std::string code; // Código identificador único para esta notificación
|
||||
bool can_be_removed; // Indica si la notificación puede ser eliminada
|
||||
int height; // Altura de la notificación
|
||||
Uint32 start_time; // Momento en que se creó la notificación
|
||||
Uint32 elapsed_time; // Tiempo transcurrido desde la creación
|
||||
Uint32 display_duration; // Duración total para mostrar la notificación
|
||||
std::shared_ptr<Surface> surface{nullptr}; // Superficie asociada a la notificación
|
||||
std::shared_ptr<SurfaceSprite> sprite{nullptr}; // Sprite asociado para gráficos o animaciones
|
||||
std::vector<std::string> texts; // Lista de textos incluidos en la notificación
|
||||
Status state{Status::RISING}; // Estado actual de la notificación (RISING, SHOWING, etc.)
|
||||
Shape shape{Shape::SQUARED}; // Forma de la notificación (ej. SQUARED o ROUNDED)
|
||||
SDL_FRect rect{0, 0, 0, 0}; // Dimensiones y posición de la notificación en pantalla
|
||||
int y{0}; // Posición actual en el eje Y
|
||||
int travel_dist{0}; // Distancia a recorrer (por ejemplo, en animaciones)
|
||||
std::string code; // Código identificador único para esta notificación
|
||||
bool can_be_removed{true}; // Indica si la notificación puede ser eliminada
|
||||
int height{0}; // Altura de la notificación
|
||||
Uint32 start_time{0}; // Momento en que se creó la notificación
|
||||
Uint32 elapsed_time{0}; // Tiempo transcurrido desde la creación
|
||||
Uint32 display_duration{0}; // Duración total para mostrar la notificación
|
||||
|
||||
// Constructor
|
||||
explicit Notification()
|
||||
: surface(nullptr), // Inicializar superficie como nula
|
||||
sprite(nullptr), // Inicializar lista de textos vacía
|
||||
state(NotificationStatus::RISING), // Estado inicial como "RISING"
|
||||
shape(NotificationShape::SQUARED), // Forma inicial como "SQUARED"
|
||||
rect{0, 0, 0, 0}, // Rectángulo inicial vacío
|
||||
y(0), // Posición Y inicializada a 0
|
||||
travel_dist(0), // Código identificador vacío
|
||||
can_be_removed(true), // Inicialmente se puede eliminar
|
||||
height(0), // Altura inicializada a 0
|
||||
start_time(0), // Tiempo de creación inicializado a 0
|
||||
elapsed_time(0), // Tiempo transcurrido inicializado a 0
|
||||
display_duration(0) // Duración inicializada a 0
|
||||
{
|
||||
}
|
||||
explicit Notification() = default;
|
||||
};
|
||||
|
||||
std::shared_ptr<Surface> icon_surface_; // Textura para los iconos de las notificaciones
|
||||
|
||||
Reference in New Issue
Block a user