- canvi en el ordre dels overlays
- les notificacions ja segueixen al resto de elements (no tenen una posició fixa)
This commit is contained in:
@@ -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<int>(y_);
|
||||
const int NOTIFIER_Y = (Notifier::get() != nullptr) ? Notifier::get()->getVisibleHeight() : 0;
|
||||
const int Y = CONSOLE_Y + NOTIFIER_Y + static_cast<int>(y_);
|
||||
|
||||
text_obj->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||
static_cast<int>(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;
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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<float>(px);
|
||||
}
|
||||
}
|
||||
void Notifier::removeYOffset(int px) {
|
||||
y_offset_ -= px;
|
||||
for (auto& n : notifications_) {
|
||||
n.y -= px;
|
||||
n.rect.y -= static_cast<float>(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<int>(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<std::string> {
|
||||
|
||||
@@ -59,6 +59,7 @@ class Notifier {
|
||||
// Consultas
|
||||
auto isActive() -> bool; // Indica si hay notificaciones activas
|
||||
auto getCodes() -> std::vector<std::string>; // 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
|
||||
|
||||
Reference in New Issue
Block a user