eliminat Options::console

This commit is contained in:
2026-03-29 18:14:51 +02:00
parent fd9be2066d
commit 3b233f0e12
6 changed files with 34 additions and 111 deletions

View File

@@ -618,15 +618,6 @@ namespace Options {
}
}
// Crea e inicializa las opciones del programa
void init() {
#ifdef _DEBUG
console = true;
#else
console = false;
#endif
}
// Establece la ruta del fichero de configuración
void setConfigFile(const std::string& path) {
config_file_path = path;
@@ -641,9 +632,7 @@ namespace Options {
// Intenta abrir y leer el fichero
std::ifstream file(config_file_path);
if (!file.good()) {
if (console) {
std::cout << "Config file not found, creating default: " << config_file_path << '\n';
}
std::cout << "Config file not found, creating default: " << config_file_path << '\n';
saveToFile();
return true;
}
@@ -653,9 +642,7 @@ namespace Options {
file.close();
try {
if (console) {
std::cout << "Reading config file: " << config_file_path << '\n';
}
std::cout << "Reading config file: " << config_file_path << '\n';
// Parsea el YAML
auto yaml = fkyaml::node::deserialize(content);
@@ -667,10 +654,7 @@ namespace Options {
// Si la versión no coincide, crea un fichero nuevo con valores por defecto
if (CONFIG_VERSION != version) {
if (console) {
std::cout << "Config version mismatch (expected: " << CONFIG_VERSION << ", got: " << version << "), creating new config\n";
}
init();
std::cout << "Config version mismatch (expected: " << CONFIG_VERSION << ", got: " << version << "), creating new config\n";
saveToFile();
return true;
}
@@ -685,18 +669,13 @@ namespace Options {
loadKioskConfigFromYaml(yaml);
loadLocalizationFromYaml(yaml);
if (console) {
std::cout << "Config file loaded successfully\n\n";
}
std::cout << "Config file loaded successfully\n\n";
return true;
} catch (const fkyaml::exception& e) {
if (console) {
std::cerr << "Error parsing YAML config: " << e.what() << '\n';
std::cerr << "Creating new config with defaults\n";
}
init();
std::cerr << "Error parsing YAML config: " << e.what() << '\n';
std::cerr << "Creating new config with defaults\n";
saveToFile();
return true;
}
@@ -707,15 +686,11 @@ namespace Options {
// Abre el fichero para escritura
std::ofstream file(config_file_path);
if (!file.is_open()) {
if (console) {
std::cerr << "Error: Unable to open file " << config_file_path << " for writing\n";
}
std::cerr << "Error: Unable to open file " << config_file_path << " for writing\n";
return false;
}
if (console) {
std::cout << "Writing config file: " << config_file_path << '\n';
}
std::cout << "Writing config file: " << config_file_path << '\n';
// Escribe el fichero manualmente para controlar el orden y los comentarios
file << "# JailDoctor's Dilemma - Configuration File\n";
@@ -807,9 +782,7 @@ namespace Options {
file.close();
if (console) {
std::cout << "Config file saved successfully\n\n";
}
std::cout << "Config file saved successfully\n\n";
return true;
}
@@ -834,9 +807,7 @@ namespace Options {
std::ifstream file(postfx_file_path);
if (!file.good()) {
if (console) {
std::cout << "PostFX file not found, creating default: " << postfx_file_path << '\n';
}
std::cout << "PostFX file not found, creating default: " << postfx_file_path << '\n';
return savePostFXToFile();
}
@@ -877,16 +848,12 @@ namespace Options {
current_postfx_preset = 0;
}
if (console) {
std::cout << "PostFX file loaded: " << postfx_presets.size() << " preset(s)\n";
}
std::cout << "PostFX file loaded: " << postfx_presets.size() << " preset(s)\n";
return true;
} catch (const fkyaml::exception& e) {
if (console) {
std::cerr << "Error parsing PostFX YAML: " << e.what() << '\n';
}
std::cerr << "Error parsing PostFX YAML: " << e.what() << '\n';
return savePostFXToFile();
}
}
@@ -899,9 +866,7 @@ namespace Options {
std::ofstream file(postfx_file_path);
if (!file.is_open()) {
if (console) {
std::cerr << "Error: Unable to open file " << postfx_file_path << " for writing\n";
}
std::cerr << "Error: Unable to open file " << postfx_file_path << " for writing\n";
return false;
}
@@ -975,9 +940,7 @@ namespace Options {
file.close();
if (console) {
std::cout << "PostFX file created with defaults: " << postfx_file_path << '\n';
}
std::cout << "PostFX file created with defaults: " << postfx_file_path << '\n';
// Cargar los presets recién creados
postfx_presets.clear();
@@ -1002,9 +965,7 @@ namespace Options {
std::ifstream file(crtpi_file_path);
if (!file.good()) {
if (console) {
std::cout << "CrtPi file not found, creating default: " << crtpi_file_path << '\n';
}
std::cout << "CrtPi file not found, creating default: " << crtpi_file_path << '\n';
// Crear directorio padre si no existe
const std::filesystem::path p(crtpi_file_path);
if (p.has_parent_path()) {
@@ -1014,9 +975,7 @@ namespace Options {
// Escribir defaults
std::ofstream out(crtpi_file_path);
if (!out.is_open()) {
if (console) {
std::cerr << "Error: Cannot create CrtPi file: " << crtpi_file_path << '\n';
}
std::cerr << "Error: Cannot create CrtPi file: " << crtpi_file_path << '\n';
// Cargar defaults en memoria aunque no se pueda escribir
crtpi_presets.push_back({"DEFAULT", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, false, false});
crtpi_presets.push_back({"CURVED", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, true, false});
@@ -1098,9 +1057,7 @@ namespace Options {
out << " enable_curvature: false\n";
out << " enable_sharper: false\n";
out.close();
if (console) {
std::cout << "CrtPi file created with defaults: " << crtpi_file_path << '\n';
}
std::cout << "CrtPi file created with defaults: " << crtpi_file_path << '\n';
crtpi_presets.push_back({"DEFAULT", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, false, false});
crtpi_presets.push_back({"CURVED", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, true, false});
crtpi_presets.push_back({"SHARP", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, false, true, false, true});
@@ -1173,15 +1130,11 @@ namespace Options {
current_crtpi_preset = 0;
}
if (console) {
std::cout << "CrtPi file loaded: " << crtpi_presets.size() << " preset(s)\n";
}
std::cout << "CrtPi file loaded: " << crtpi_presets.size() << " preset(s)\n";
return true;
} catch (const fkyaml::exception& e) {
if (console) {
std::cerr << "Error parsing CrtPi YAML: " << e.what() << '\n';
}
std::cerr << "Error parsing CrtPi YAML: " << e.what() << '\n';
// Cargar defaults en memoria en caso de error
crtpi_presets.clear();
crtpi_presets.push_back({"DEFAULT", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, false, false});