diff --git a/source/core/rendering/render_info.cpp b/source/core/rendering/render_info.cpp index 6d8719f..ec7247b 100644 --- a/source/core/rendering/render_info.cpp +++ b/source/core/rendering/render_info.cpp @@ -114,9 +114,10 @@ void RenderInfo::render() const { // Fuente: preferir la de la consola si está disponible auto text_obj = (Console::get() != nullptr) ? Console::get()->getText() : Screen::get()->getText(); - // Posición Y: debajo de la consola + offset animado propio + // Posición Y: debajo de la consola + notificaciones + offset animado propio const int CONSOLE_Y = (Console::get() != nullptr) ? Console::get()->getVisibleHeight() : 0; - const int Y = CONSOLE_Y + static_cast(y_); + const int NOTIFIER_Y = (Notifier::get() != nullptr) ? Notifier::get()->getVisibleHeight() : 0; + const int Y = CONSOLE_Y + NOTIFIER_Y + static_cast(y_); text_obj->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, static_cast(Options::game.width / 2), @@ -126,17 +127,15 @@ void RenderInfo::render() const { MSG_COLOR); } -// Activa o desactiva el overlay y notifica a Notifier del cambio de offset +// Activa o desactiva el overlay void RenderInfo::toggle() { switch (status_) { case Status::HIDDEN: status_ = Status::RISING; Screen::get()->updateZoomFactor(); - if (Notifier::get() != nullptr) { Notifier::get()->addYOffset(HEIGHT); } break; case Status::ACTIVE: status_ = Status::VANISHING; - if (Notifier::get() != nullptr) { Notifier::get()->removeYOffset(HEIGHT); } break; default: break; diff --git a/source/core/rendering/screen.cpp b/source/core/rendering/screen.cpp index 8a3d612..4de28d2 100644 --- a/source/core/rendering/screen.cpp +++ b/source/core/rendering/screen.cpp @@ -474,8 +474,8 @@ void Screen::textureToRenderer() { // Renderiza todos los overlays (orden: último dibujado queda encima) void Screen::renderOverlays() { - renderNotifications(); // Notifier (abajo) - if (RenderInfo::get() != nullptr) { RenderInfo::get()->render(); } // RenderInfo (medio) + if (RenderInfo::get() != nullptr) { RenderInfo::get()->render(); } // RenderInfo (abajo) + renderNotifications(); // Notifier (medio) if (Console::get() != nullptr) { Console::get()->render(); } // Console (encima) } diff --git a/source/game/ui/notifier.cpp b/source/game/ui/notifier.cpp index 80eb29c..56ad1d0 100644 --- a/source/game/ui/notifier.cpp +++ b/source/game/ui/notifier.cpp @@ -277,9 +277,32 @@ void Notifier::clearNotifications() { clearFinishedNotifications(); } -// Ajusta el offset vertical base -void Notifier::addYOffset(int px) { y_offset_ += px; } -void Notifier::removeYOffset(int px) { y_offset_ -= px; } +// Ajusta el offset vertical base y desplaza las notificaciones existentes +void Notifier::addYOffset(int px) { + y_offset_ += px; + for (auto& n : notifications_) { + n.y += px; + n.rect.y += static_cast(px); + } +} +void Notifier::removeYOffset(int px) { + y_offset_ -= px; + for (auto& n : notifications_) { + n.y -= px; + n.rect.y -= static_cast(px); + } +} + +// Altura visible ocupada por las notificaciones activas (relativa al offset base) +auto Notifier::getVisibleHeight() const -> int { + int bottom = 0; + for (const auto& n : notifications_) { + if (n.state == Status::FINISHED) { continue; } + int n_bottom = static_cast(n.rect.y + n.rect.h) - y_offset_; + if (n_bottom > bottom) { bottom = n_bottom; } + } + return bottom; +} // Obtiene los códigos de las notificaciones auto Notifier::getCodes() -> std::vector { diff --git a/source/game/ui/notifier.hpp b/source/game/ui/notifier.hpp index 76b76b5..2dff264 100644 --- a/source/game/ui/notifier.hpp +++ b/source/game/ui/notifier.hpp @@ -57,8 +57,9 @@ class Notifier { const std::string& code = std::string()); // Mostrar notificación // Consultas - auto isActive() -> bool; // Indica si hay notificaciones activas - auto getCodes() -> std::vector; // Obtiene códigos de notificaciones + auto isActive() -> bool; // Indica si hay notificaciones activas + auto getCodes() -> std::vector; // Obtiene códigos de notificaciones + [[nodiscard]] auto getVisibleHeight() const -> int; // Altura ocupada por notificaciones activas // Offset vertical (para evitar solapamiento con Console y renderInfo) void addYOffset(int px); // Suma píxeles al offset base