eliminat molt de ruido de la consola de log

This commit is contained in:
2026-04-14 13:04:24 +02:00
parent f5da35bfb2
commit cf7ea6cc9c
27 changed files with 144 additions and 383 deletions

View File

@@ -5,6 +5,7 @@
#include <algorithm> // Para clamp
#include <cstddef> // Para size_t
#include <fstream> // Para ifstream, ofstream
#include <iostream> // Para std::cout
#include <string> // Para string
#include <vector> // Para vector
@@ -12,7 +13,6 @@
#include "external/fkyaml_node.hpp" // Para fkyaml::node
#include "input.hpp" // Para Input
#include "lang.hpp" // Para getText, Code
#include "ui/logger.hpp" // Para info
#include "utils.hpp" // Para boolToString, getFileName
namespace Options {
@@ -63,7 +63,6 @@ namespace Options {
std::ifstream file(postfx_file_path);
if (!file.good()) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "PostFX file not found, creating default: %s", postfx_file_path.c_str());
return savePostFXToFile();
}
@@ -110,11 +109,10 @@ namespace Options {
video.shader.current_postfx_preset = 0;
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "PostFX file loaded: %zu preset(s)", postfx_presets.size());
return true;
} catch (const fkyaml::exception& e) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Error parsing PostFX YAML: %s. Recreating defaults.", e.what());
std::cout << "Error parsing PostFX YAML: " << e.what() << ". Recreating defaults." << '\n';
return savePostFXToFile();
}
}
@@ -127,7 +125,7 @@ namespace Options {
std::ofstream file(postfx_file_path);
if (!file.is_open()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: %s can't be opened for writing", postfx_file_path.c_str());
std::cout << "Error: " << postfx_file_path << " can't be opened for writing" << '\n';
return false;
}
@@ -200,8 +198,6 @@ namespace Options {
file.close();
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "PostFX file created with defaults: %s", postfx_file_path.c_str());
// Cargar los presets recién escritos
postfx_presets.clear();
postfx_presets.push_back({"CRT", 0.15F, 0.7F, 0.2F, 0.5F, 0.1F, 0.0F, 0.0F, 0.0F});
@@ -247,7 +243,7 @@ namespace Options {
if (crtpi_file_path.empty()) { return false; }
std::ofstream file(crtpi_file_path);
if (!file.is_open()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: %s can't be opened for writing", crtpi_file_path.c_str());
std::cout << "Error: " << crtpi_file_path << " can't be opened for writing" << '\n';
return false;
}
file << "# Coffee Crisis Arcade Edition - CrtPi Shader Presets\n";
@@ -266,7 +262,6 @@ namespace Options {
file << " - name: \"Sharp\"\n scanline_weight: 6.0\n scanline_gap_brightness: 0.12\n bloom_factor: 3.5\n input_gamma: 2.4\n output_gamma: 2.2\n mask_brightness: 0.80\n curvature_x: 0.05\n curvature_y: 0.10\n mask_type: 2\n enable_scanlines: true\n enable_multisample: false\n enable_gamma: true\n enable_curvature: false\n enable_sharper: true\n";
file << " - name: \"Minimal\"\n scanline_weight: 8.0\n scanline_gap_brightness: 0.05\n bloom_factor: 2.0\n input_gamma: 2.4\n output_gamma: 2.2\n mask_brightness: 1.00\n curvature_x: 0.0\n curvature_y: 0.0\n mask_type: 0\n enable_scanlines: true\n enable_multisample: false\n enable_gamma: false\n enable_curvature: false\n enable_sharper: false\n";
file.close();
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "CrtPi file created with defaults: %s", crtpi_file_path.c_str());
populateDefaultCrtPiPresets();
return true;
}
@@ -277,7 +272,6 @@ namespace Options {
std::ifstream file(crtpi_file_path);
if (!file.good()) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "CrtPi file not found, creating default: %s", crtpi_file_path.c_str());
return saveCrtPiDefaults();
}
@@ -330,11 +324,10 @@ namespace Options {
video.shader.current_crtpi_preset = 0;
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "CrtPi file loaded: %zu preset(s)", crtpi_presets.size());
return true;
} catch (const fkyaml::exception& e) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Error parsing CrtPi YAML: %s. Recreating defaults.", e.what());
std::cout << "Error parsing CrtPi YAML: " << e.what() << ". Recreating defaults." << '\n';
return saveCrtPiDefaults();
}
}
@@ -581,12 +574,10 @@ namespace Options {
std::ifstream file(settings.config_file);
if (!file.is_open()) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Config file not found. Creating default settings.");
saveToFile();
return true;
}
Logger::info("Reading file: " + getFileName(settings.config_file));
std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
file.close();
@@ -601,7 +592,7 @@ namespace Options {
} catch (...) {}
}
if (file_version != Settings::CURRENT_CONFIG_VERSION) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Config version %d != expected %d. Recreating defaults.", file_version, Settings::CURRENT_CONFIG_VERSION);
std::cout << "Config version " << file_version << " != expected " << Settings::CURRENT_CONFIG_VERSION << ". Recreating defaults." << '\n';
init();
saveToFile();
return true;
@@ -615,7 +606,7 @@ namespace Options {
loadKeyboardFromYaml(yaml);
} catch (const fkyaml::exception& e) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Error parsing YAML config: %s. Using defaults.", e.what());
std::cout << "Error parsing YAML config: " << e.what() << ". Using defaults." << '\n';
init();
saveToFile();
return true;
@@ -630,12 +621,10 @@ namespace Options {
std::ofstream file(settings.config_file);
if (!file.good()) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: %s can't be opened", getFileName(settings.config_file).c_str());
std::cout << "Error: " << getFileName(settings.config_file) << " can't be opened" << '\n';
return false;
}
Logger::info("Writing file: " + getFileName(settings.config_file));
applyPendingChanges();
file << "# Coffee Crisis Arcade Edition - Configuration File\n";