Passant std::cout a SDL_Log

This commit is contained in:
2025-03-27 19:57:30 +01:00
parent c6288918b2
commit 8afca398e9
27 changed files with 588 additions and 764 deletions
+5 -5
View File
@@ -1,8 +1,8 @@
#include "manage_hiscore_table.h"
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_iostream.h> // Para SDL_ReadIO, SDL_WriteIO, SDL_CloseIO
#include <SDL3/SDL_log.h> // Para SDL_LogCategory, SDL_LogError, SDL_Lo...
#include <algorithm> // Para find_if, sort
#include <iostream> // Para basic_ostream, operator<<, cout, endl
#include <iterator> // Para distance
#include "utils.h" // Para getFileName
@@ -116,12 +116,12 @@ bool ManageHiScoreTable::loadFromFile(const std::string &file_path)
table_.push_back(entry);
}
std::cout << "Reading file: " << getFileName(file_path) << std::endl;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Reading file: %s", getFileName(file_path).c_str());
SDL_CloseIO(file);
}
else
{
std::cout << "Error: Unable to load " << getFileName(file_path) << " file! " << SDL_GetError() << std::endl;
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Unable to load %s file! %s", getFileName(file_path).c_str(), SDL_GetError());
success = false;
}
return success;
@@ -157,12 +157,12 @@ bool ManageHiScoreTable::saveToFile(const std::string &file_path)
SDL_WriteIO(file, &occ_value, sizeof(int));
}
std::cout << "Writing file: " << getFileName(file_path) << std::endl;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Writing file: %s", getFileName(file_path).c_str());
SDL_CloseIO(file);
}
else
{
std::cout << "Error: Unable to save " << getFileName(file_path) << " 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;
}
return success;