Passant std::cout a SDL_Log
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "utils.h"
|
||||
#include <SDL3/SDL_iostream.h> // Para SDL_CloseIO, SDL_IOFromFile, SDL_ReadIO
|
||||
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogError, SDL_Lo...
|
||||
#include <stddef.h> // Para size_t
|
||||
#include <algorithm> // Para min, clamp, find_if_not, find, transform
|
||||
#include <cctype> // Para tolower, isspace
|
||||
#include <cmath> // Para pow, sin, M_PI, cos
|
||||
#include <compare> // Para operator<
|
||||
#include <filesystem> // Para path
|
||||
#include <iostream> // Para basic_ostream, cout, basic_ios, endl
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para basic_string, string, char_traits
|
||||
#include <string> // Para basic_string, string, operator==, ope...
|
||||
#include "lang.h" // Para getText
|
||||
|
||||
// Variables
|
||||
Overrides overrides = Overrides();
|
||||
|
||||
// Colores
|
||||
const Color bg_color = Color(0X27, 0X27, 0X36);
|
||||
const Color no_color = Color(0XFF, 0XFF, 0XFF);
|
||||
const Color shdw_txt_color = Color(0X43, 0X43, 0X4F);
|
||||
const Color separator_color = Color(0X0D, 0X1A, 0X2B);
|
||||
const Color scoreboard_easy_color = Color(0X4B, 0X69, 0X2F);
|
||||
const Color scoreboard_normal_color = Color(0X2E, 0X3F, 0X47);
|
||||
const Color scoreboard_hard_color = Color(0X76, 0X42, 0X8A);
|
||||
const Color flash_color = Color(0XFF, 0XFF, 0XFF);
|
||||
const Color fade_color = Color(0X27, 0X27, 0X36);
|
||||
const Color orange_color = Color(0XFF, 0X7A, 0X00);
|
||||
const Color orange_soft_color = Color(0XFF, 0XA0, 0X33);
|
||||
const Color green_color = Color(0X5B, 0XEC, 0X95);
|
||||
const Color blue_sky_color = Color(0X02, 0X88, 0XD1);
|
||||
const Color pink_sky_color = Color(0XFF, 0X6B, 0X97);
|
||||
const Color green_sky_color = Color(0X00, 0X79, 0X6B);
|
||||
const Color BG_COLOR = Color(0X27, 0X27, 0X36);
|
||||
const Color NO_COLOR = Color(0XFF, 0XFF, 0XFF);
|
||||
const Color SHADOW_TEXT_COLOR = Color(0X43, 0X43, 0X4F);
|
||||
const Color SEPARATOR_COLOR = Color(0X0D, 0X1A, 0X2B);
|
||||
const Color SCOREBOARD_EASY_COLOR = Color(0X4B, 0X69, 0X2F);
|
||||
const Color SCOREBOARD_NORMAL_COLOR = Color(0X2E, 0X3F, 0X47);
|
||||
const Color SCOREBOARD_HARD_COLOR = Color(0X76, 0X42, 0X8A);
|
||||
const Color FLASH_COLOR = Color(0XFF, 0XFF, 0XFF);
|
||||
const Color FADE_COLOR = Color(0X27, 0X27, 0X36);
|
||||
const Color ORANGE_COLOR = Color(0XFF, 0X7A, 0X00);
|
||||
const Color ORANGE_SOFT_COLOR = Color(0XFF, 0XA0, 0X33);
|
||||
const Color GREEN_COLOR = Color(0X5B, 0XEC, 0X95);
|
||||
const Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1);
|
||||
const Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97);
|
||||
const Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B);
|
||||
|
||||
// Obtiene un color del vector de colores imitando al Coche Fantástico
|
||||
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_)
|
||||
@@ -299,17 +299,16 @@ bool stringInVector(const std::vector<std::string> &vec, const std::string &str)
|
||||
return std::find(vec.begin(), vec.end(), str) != vec.end();
|
||||
}
|
||||
|
||||
// Imprime por pantalla una linea de texto de tamaño fijo rellena con puntos
|
||||
// Imprime por pantalla una línea de texto de tamaño fijo rellena con puntos
|
||||
void printWithDots(const std::string &text1, const std::string &text2, const std::string &text3)
|
||||
{
|
||||
std::cout.setf(std::ios::left, std::ios::adjustfield);
|
||||
std::cout << text1;
|
||||
std::string output = text1;
|
||||
size_t dots_count = 50 - text1.length() - text3.length();
|
||||
output.append(dots_count, '.');
|
||||
output.append(text2);
|
||||
output.append(text3);
|
||||
|
||||
std::cout.width(50 - text1.length() - text3.length());
|
||||
std::cout.fill('.');
|
||||
std::cout << text2;
|
||||
|
||||
std::cout << text3 << std::endl;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s", output.c_str());
|
||||
}
|
||||
|
||||
// Carga el fichero de datos para la demo
|
||||
@@ -321,7 +320,7 @@ DemoData loadDemoDataFromFile(const std::string &file_path)
|
||||
auto file = SDL_IOFromFile(file_path.c_str(), "r+b");
|
||||
if (!file)
|
||||
{
|
||||
std::cerr << "Error: Fichero no encontrado " << file_path << std::endl;
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Fichero no encontrado %s", file_path.c_str());
|
||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||
}
|
||||
else
|
||||
@@ -357,21 +356,21 @@ bool saveDemoFile(const std::string &file_path, const DemoData &dd)
|
||||
{
|
||||
if (SDL_RWwrite(file, &data, sizeof(DemoKeys), 1) != 1)
|
||||
{
|
||||
std::cerr << "Error al escribir el fichero " << getFileName(file_path) << std::endl;
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error al escribir el fichero %s", getFileName(file_path).c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
std::cout << "Writing file " << getFileName(file_path).c_str() << std::endl;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Writing file %s", getFileName(file_path).c_str());
|
||||
}
|
||||
// Cierra el fichero
|
||||
SDL_CloseIO(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Unable to save " << getFileName(file_path).c_str() << " file! " << SDL_GetError() << std::endl;
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Unable to save %s file! %s", getFileName(file_path).c_str(), SDL_GetError());
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user