Passant std::cout a SDL_Log
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#include "options.h"
|
||||
#include <algorithm> // Para clamp
|
||||
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::opera...
|
||||
#include <iostream> // Para cout
|
||||
#include <utility> // Para swap
|
||||
#include <vector> // Para vector
|
||||
#include "input.h" // Para InputDeviceToUse
|
||||
#include "lang.h" // Para Code
|
||||
#include "screen.h" // Para ScreenFilter
|
||||
#include "utils.h" // Para boolToString, stringToBool, getFileName
|
||||
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogWarn
|
||||
#include <algorithm> // Para clamp
|
||||
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::...
|
||||
#include <utility> // Para swap
|
||||
#include <vector> // Para vector
|
||||
#include "input.h" // Para InputDeviceToUse
|
||||
#include "lang.h" // Para Code
|
||||
#include "screen.h" // Para ScreenFilter
|
||||
#include "utils.h" // Para boolToString, stringToBool, getFileName
|
||||
|
||||
// Variables
|
||||
Options options;
|
||||
@@ -65,31 +65,30 @@ bool loadOptionsFile(std::string file_path)
|
||||
// Si el fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
std::cout << "Reading file: " << getFileName(file_path) << std::endl;
|
||||
// Procesa el fichero línea a línea
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Reading file: %s", getFileName(file_path).c_str());
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Comprueba que la linea no sea un comentario
|
||||
// Comprueba que la línea no sea un comentario
|
||||
if (line.substr(0, 1) != "#")
|
||||
{
|
||||
// Encuentra la posición del caracter '='
|
||||
// Encuentra la posición del carácter '='
|
||||
int pos = line.find("=");
|
||||
// Procesa las dos subcadenas
|
||||
if (!setOptions(line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||||
{
|
||||
std::cout << "Warning: file " << getFileName(file_path) << std::endl;
|
||||
std::cout << "Unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: file %s", getFileName(file_path).c_str());
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Unknown parameter: %s", line.substr(0, pos).c_str());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
// El fichero no existe
|
||||
else
|
||||
{
|
||||
{
|
||||
// Crea el fichero con los valores por defecto
|
||||
saveOptionsFile(file_path);
|
||||
}
|
||||
@@ -112,11 +111,11 @@ bool saveOptionsFile(std::string file_path)
|
||||
|
||||
if (!file.good())
|
||||
{
|
||||
std::cout << getFileName(file_path) << " can't be opened" << std::endl;
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: %s can't be opened", getFileName(file_path).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Writing file: " << getFileName(file_path) << std::endl;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Writing file: %s", getFileName(file_path).c_str());
|
||||
|
||||
// Opciones de video
|
||||
file << "## VIDEO\n";
|
||||
|
||||
Reference in New Issue
Block a user