forked from jaildesigner-jailgames/jaildoctors_dilemma
Transició a surface: barallantme amb tots els Color que hi ha pel codi
This commit is contained in:
@@ -36,7 +36,7 @@ Notifier *Notifier::get()
|
||||
|
||||
// Constructor
|
||||
Notifier::Notifier(const std::string &icon_file, const std::string &text)
|
||||
: icon_texture_(!icon_file.empty() ? Resource::get()->getSurface(icon_file) : nullptr),
|
||||
: icon_surface_(!icon_file.empty() ? Resource::get()->getSurface(icon_file) : nullptr),
|
||||
text_(Resource::get()->getText(text)),
|
||||
bg_color_(options.notifications.color),
|
||||
wait_time_(150),
|
||||
@@ -86,7 +86,7 @@ void Notifier::update()
|
||||
{
|
||||
// const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
|
||||
// const int alpha = 255 * step;
|
||||
constexpr int ALPHA = 255;
|
||||
//constexpr int ALPHA = 255;
|
||||
|
||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||
{
|
||||
@@ -96,12 +96,12 @@ void Notifier::update()
|
||||
{
|
||||
notifications_[i].rect.y--;
|
||||
}
|
||||
notifications_[i].texture->setAlpha(ALPHA);
|
||||
//notifications_[i].surface->setAlpha(ALPHA);
|
||||
|
||||
if (notifications_[i].rect.y == notifications_[i].y)
|
||||
{
|
||||
notifications_[i].state = NotificationStatus::STAY;
|
||||
notifications_[i].texture->setAlpha(255);
|
||||
//notifications_[i].surface->setAlpha(255);
|
||||
notifications_[i].counter = 0;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void Notifier::update()
|
||||
|
||||
// const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
||||
// const int ALPHA = 255 * (1 - step);
|
||||
constexpr int ALPHA = 255;
|
||||
//constexpr int ALPHA = 255;
|
||||
|
||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ void Notifier::update()
|
||||
{
|
||||
notifications_[i].rect.y++;
|
||||
}
|
||||
notifications_[i].texture->setAlpha(ALPHA);
|
||||
//notifications_[i].surface->setAlpha(ALPHA);
|
||||
|
||||
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist)
|
||||
{
|
||||
@@ -234,12 +234,12 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
||||
n.rect = {desp_h, y_pos, width, height};
|
||||
|
||||
// Crea la textura
|
||||
n.texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
n.texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
n.surface = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
n.surface->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||
n.surface->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Prepara para dibujar en la textura
|
||||
n.texture->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
n.surface->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
|
||||
// Dibuja el fondo de la notificación
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), bg_color_.r, bg_color_.g, bg_color_.b, 255);
|
||||
@@ -267,7 +267,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
||||
// Dibuja el icono de la notificación
|
||||
if (has_icons_ && icon >= 0 && texts.size() >= 2)
|
||||
{
|
||||
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_Rect){0, 0, ICON_SIZE_, ICON_SIZE_});
|
||||
auto sp = std::make_unique<Sprite>(icon_surface_, (SDL_Rect){0, 0, ICON_SIZE_, ICON_SIZE_});
|
||||
sp->setPosition({padding_in_h, padding_in_v, ICON_SIZE_, ICON_SIZE_});
|
||||
sp->setClip({ICON_SIZE_ * (icon % 10), ICON_SIZE_ * (icon / 10), ICON_SIZE_, ICON_SIZE_});
|
||||
sp->render();
|
||||
@@ -293,10 +293,10 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
|
||||
// Crea el sprite de la notificación
|
||||
n.sprite = std::make_shared<Sprite>(n.texture, n.rect);
|
||||
n.sprite = std::make_shared<Sprite>(n.surface, n.rect);
|
||||
|
||||
// Deja la notificación invisible
|
||||
n.texture->setAlpha(0);
|
||||
n.surface->setAlpha(0);
|
||||
|
||||
// Añade la notificación a la lista
|
||||
notifications_.emplace_back(n);
|
||||
|
||||
Reference in New Issue
Block a user