nova clase renderInfo
afegit control de offset a les notificacions
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para Options
|
||||
#include "core/rendering/render_info.hpp" // Para RenderInfo
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "game/ui/notifier.hpp" // Para Notifier
|
||||
|
||||
// ── Sistema de comandos ────────────────────────────────────────────────────────
|
||||
|
||||
@@ -293,19 +295,19 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
||||
#ifdef _DEBUG
|
||||
// DEBUG [ON|OFF] — Overlay de debug (F12, solo en builds debug)
|
||||
{.keyword = "DEBUG", .execute = BOOL_TOGGLE_CMD("Debug overlay",
|
||||
Screen::get()->isFPSVisible(),
|
||||
Screen::get()->toggleFPS())},
|
||||
RenderInfo::get()->isActive(),
|
||||
RenderInfo::get()->toggle())},
|
||||
|
||||
// SHOW FPS / HIDE FPS — Aliases de DEBUG ON / DEBUG OFF
|
||||
{.keyword = "SHOW", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||
if (args.empty() || args[0] != "FPS") { return "Usage: SHOW FPS"; }
|
||||
if (Screen::get()->isFPSVisible()) { return "Debug overlay already ON"; }
|
||||
Screen::get()->toggleFPS(); return "Debug overlay ON";
|
||||
if (RenderInfo::get()->isActive()) { return "Debug overlay already ON"; }
|
||||
RenderInfo::get()->toggle(); return "Debug overlay ON";
|
||||
}},
|
||||
{.keyword = "HIDE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||
if (args.empty() || args[0] != "FPS") { return "Usage: HIDE FPS"; }
|
||||
if (!Screen::get()->isFPSVisible()) { return "Debug overlay already OFF"; }
|
||||
Screen::get()->toggleFPS(); return "Debug overlay OFF";
|
||||
if (!RenderInfo::get()->isActive()) { return "Debug overlay already OFF"; }
|
||||
RenderInfo::get()->toggle(); return "Debug overlay OFF";
|
||||
}},
|
||||
#endif
|
||||
|
||||
@@ -629,6 +631,7 @@ void Console::toggle() {
|
||||
cursor_timer_ = 0.0F;
|
||||
cursor_visible_ = true;
|
||||
SDL_StartTextInput(SDL_GetKeyboardFocus());
|
||||
if (Notifier::get() != nullptr) { Notifier::get()->addYOffset(static_cast<int>(height_)); }
|
||||
break;
|
||||
case Status::ACTIVE:
|
||||
status_ = Status::VANISHING;
|
||||
@@ -636,6 +639,7 @@ void Console::toggle() {
|
||||
history_index_ = -1;
|
||||
saved_input_.clear();
|
||||
SDL_StopTextInput(SDL_GetKeyboardFocus());
|
||||
if (Notifier::get() != nullptr) { Notifier::get()->removeYOffset(static_cast<int>(height_)); }
|
||||
break;
|
||||
default:
|
||||
// Durante RISING o VANISHING no se hace nada
|
||||
|
||||
@@ -26,6 +26,7 @@ class Console {
|
||||
// Consultas
|
||||
auto isActive() -> bool; // true si RISING, ACTIVE o VANISHING
|
||||
auto getVisibleHeight() -> int; // Píxeles visibles actuales (0 = oculta, height_ = totalmente visible)
|
||||
[[nodiscard]] auto getText() const -> std::shared_ptr<Text> { return text_; }
|
||||
|
||||
private:
|
||||
enum class Status {
|
||||
|
||||
@@ -173,7 +173,7 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
;
|
||||
|
||||
// Posición vertical
|
||||
const int DESP_V = PADDING_OUT;
|
||||
const int DESP_V = y_offset_;
|
||||
|
||||
// Offset
|
||||
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT;
|
||||
@@ -278,6 +278,10 @@ 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; }
|
||||
|
||||
// Obtiene los códigos de las notificaciones
|
||||
auto Notifier::getCodes() -> std::vector<std::string> {
|
||||
std::vector<std::string> codes;
|
||||
|
||||
@@ -59,6 +59,10 @@ class Notifier {
|
||||
auto isActive() -> bool; // Indica si hay notificaciones activas
|
||||
auto getCodes() -> std::vector<std::string>; // Obtiene códigos de notificaciones
|
||||
|
||||
// Offset vertical (para evitar solapamiento con Console y renderInfo)
|
||||
void addYOffset(int px); // Suma píxeles al offset base
|
||||
void removeYOffset(int px); // Resta píxeles al offset base
|
||||
|
||||
private:
|
||||
// Tipos anidados
|
||||
enum class Status {
|
||||
@@ -107,4 +111,5 @@ class Notifier {
|
||||
std::vector<Notification> notifications_; // Lista de notificaciones activas
|
||||
bool stack_{false}; // Indica si las notificaciones se apilan
|
||||
bool has_icons_{false}; // Indica si el notificador tiene textura para iconos
|
||||
int y_offset_{0}; // Offset vertical base (ajustado por Console y renderInfo)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user