commit pollós

This commit is contained in:
2025-10-17 21:09:08 +02:00
parent 9b966a260c
commit 50ccb2ccc2
2 changed files with 73 additions and 1 deletions

View File

@@ -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<Type, std::vector<const Item *>> by_type;

70
source/ui/logger.h Normal file
View File

@@ -0,0 +1,70 @@
#pragma once
#include <iostream>
#include <string>
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