- 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
|
// Fuente: preferir la de la consola si está disponible
|
||||||
auto text_obj = (Console::get() != nullptr) ? Console::get()->getText() : Screen::get()->getText();
|
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 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,
|
text_obj->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||||
static_cast<int>(Options::game.width / 2),
|
static_cast<int>(Options::game.width / 2),
|
||||||
@@ -126,17 +127,15 @@ void RenderInfo::render() const {
|
|||||||
MSG_COLOR);
|
MSG_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activa o desactiva el overlay y notifica a Notifier del cambio de offset
|
// Activa o desactiva el overlay
|
||||||
void RenderInfo::toggle() {
|
void RenderInfo::toggle() {
|
||||||
switch (status_) {
|
switch (status_) {
|
||||||
case Status::HIDDEN:
|
case Status::HIDDEN:
|
||||||
status_ = Status::RISING;
|
status_ = Status::RISING;
|
||||||
Screen::get()->updateZoomFactor();
|
Screen::get()->updateZoomFactor();
|
||||||
if (Notifier::get() != nullptr) { Notifier::get()->addYOffset(HEIGHT); }
|
|
||||||
break;
|
break;
|
||||||
case Status::ACTIVE:
|
case Status::ACTIVE:
|
||||||
status_ = Status::VANISHING;
|
status_ = Status::VANISHING;
|
||||||
if (Notifier::get() != nullptr) { Notifier::get()->removeYOffset(HEIGHT); }
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -474,8 +474,8 @@ void Screen::textureToRenderer() {
|
|||||||
|
|
||||||
// Renderiza todos los overlays (orden: último dibujado queda encima)
|
// Renderiza todos los overlays (orden: último dibujado queda encima)
|
||||||
void Screen::renderOverlays() {
|
void Screen::renderOverlays() {
|
||||||
renderNotifications(); // Notifier (abajo)
|
if (RenderInfo::get() != nullptr) { RenderInfo::get()->render(); } // RenderInfo (abajo)
|
||||||
if (RenderInfo::get() != nullptr) { RenderInfo::get()->render(); } // RenderInfo (medio)
|
renderNotifications(); // Notifier (medio)
|
||||||
if (Console::get() != nullptr) { Console::get()->render(); } // Console (encima)
|
if (Console::get() != nullptr) { Console::get()->render(); } // Console (encima)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -277,9 +277,32 @@ void Notifier::clearNotifications() {
|
|||||||
clearFinishedNotifications();
|
clearFinishedNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajusta el offset vertical base
|
// Ajusta el offset vertical base y desplaza las notificaciones existentes
|
||||||
void Notifier::addYOffset(int px) { y_offset_ += px; }
|
void Notifier::addYOffset(int px) {
|
||||||
void Notifier::removeYOffset(int px) { y_offset_ -= 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
|
// Obtiene los códigos de las notificaciones
|
||||||
auto Notifier::getCodes() -> std::vector<std::string> {
|
auto Notifier::getCodes() -> std::vector<std::string> {
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class Notifier {
|
|||||||
// Consultas
|
// Consultas
|
||||||
auto isActive() -> bool; // Indica si hay notificaciones activas
|
auto isActive() -> bool; // Indica si hay notificaciones activas
|
||||||
auto getCodes() -> std::vector<std::string>; // Obtiene códigos de notificaciones
|
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)
|
// Offset vertical (para evitar solapamiento con Console y renderInfo)
|
||||||
void addYOffset(int px); // Suma píxeles al offset base
|
void addYOffset(int px); // Suma píxeles al offset base
|
||||||
|
|||||||
Reference in New Issue
Block a user