diff --git a/source/asset.cpp b/source/asset.cpp index 4f18be2..baf9810 100644 --- a/source/asset.cpp +++ b/source/asset.cpp @@ -12,6 +12,7 @@ #include "resource_helper.h" // Para ResourceHelper #include "utils.h" // Para getFileName +#include "ui/logger.h" // Pâra Logger // Singleton Asset *Asset::instance = nullptr; @@ -162,7 +163,8 @@ auto Asset::exists(const std::string &filename) const -> bool { auto Asset::check() const -> bool { bool success = true; - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES"); + //SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES"); + Logger::section("CHECKING FILES", Logger::CYAN); // Agrupar por tipo para mostrar organizado std::unordered_map> by_type; diff --git a/source/ui/logger.h b/source/ui/logger.h new file mode 100644 index 0000000..21e3673 --- /dev/null +++ b/source/ui/logger.h @@ -0,0 +1,70 @@ +#pragma once + +#include +#include + +namespace Logger { + + // Colores ANSI + inline constexpr const char* RESET = "\033[0m"; + inline constexpr const char* RED = "\033[31m"; + inline constexpr const char* GREEN = "\033[32m"; + inline constexpr const char* YELLOW = "\033[33m"; + inline constexpr const char* BLUE = "\033[34m"; + inline constexpr const char* MAGENTA = "\033[35m"; + inline constexpr const char* CYAN = "\033[36m"; + inline constexpr const char* WHITE = "\033[37m"; + + // Ancho total global para alineación + inline constexpr size_t TOTAL_WIDTH = 52; + + // Sección + inline void section(const std::string& title, const std::string& color = CYAN) { + std::cout << "\n" << color + << "========================================\n" + << " " << title << "\n" + << "========================================" + << RESET << "\n"; + } + + // Info + inline void info(const std::string& msg, const std::string& color = WHITE) { + std::cout << " " << color << msg << RESET << "\n"; + } + + // Dots genérico + inline void dots(const std::string& prefix, + const std::string& middle, + const std::string& suffix, + const std::string& suffixColor = GREEN) + { + size_t field_width = TOTAL_WIDTH > (prefix.size() + suffix.size()) + ? TOTAL_WIDTH - prefix.size() - suffix.size() + : 0; + + std::string field_text; + if (middle.size() < field_width) { + field_text = middle + std::string(field_width - middle.size(), '.'); + } else { + field_text = middle.substr(0, field_width); + } + + std::cout << prefix << field_text + << suffixColor << suffix << RESET + << "\n"; + } + + // Status con true/false, usando dots y sufijos fijos + inline void status(const std::string& name, bool ok) { + // Ambos sufijos tienen 9 caracteres → alineación perfecta + constexpr const char* OK_LABEL = "[ OK ]"; + constexpr const char* ERROR_LABEL = "[ ERROR ]"; + + if (ok) { + dots(" ", name, OK_LABEL, GREEN); + } else { + dots(" ", name, ERROR_LABEL, RED); + } + } + +} // namespace Logger