fix: el fitxer de config el trobava i despres deia que no el trobava
This commit is contained in:
@@ -59,9 +59,10 @@ auto loadFromFile() -> bool {
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
std::ifstream file(settings.config_file);
|
std::ifstream file(settings.config_file);
|
||||||
|
bool file_exists = file.is_open(); // Guardamos si el fichero existía al abrirlo
|
||||||
|
|
||||||
// 2. Si el fichero existe, lo leemos para obtener los nombres de los mandos.
|
// 2. Si el fichero existe, lo leemos para obtener los nombres de los mandos.
|
||||||
if (file.good()) {
|
if (file_exists) {
|
||||||
// --- CASO: EL FICHERO EXISTE ---
|
// --- CASO: EL FICHERO EXISTE ---
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nReading file: %s", getFileName(settings.config_file).c_str());
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nReading file: %s", getFileName(settings.config_file).c_str());
|
||||||
std::string line;
|
std::string line;
|
||||||
@@ -96,7 +97,7 @@ auto loadFromFile() -> bool {
|
|||||||
gamepad_manager.assignAndLinkGamepads();
|
gamepad_manager.assignAndLinkGamepads();
|
||||||
|
|
||||||
// 4. Si el fichero no existía, lo creamos ahora con la configuración por defecto.
|
// 4. Si el fichero no existía, lo creamos ahora con la configuración por defecto.
|
||||||
if (!file.good()) {
|
if (!file_exists) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Config file not found. Creating default settings.");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Config file not found. Creating default settings.");
|
||||||
saveToFile();
|
saveToFile();
|
||||||
}
|
}
|
||||||
@@ -104,6 +105,7 @@ auto loadFromFile() -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Guarda el fichero de configuración
|
// Guarda el fichero de configuración
|
||||||
auto saveToFile() -> bool {
|
auto saveToFile() -> bool {
|
||||||
std::ofstream file(settings.config_file);
|
std::ofstream file(settings.config_file);
|
||||||
|
|||||||
Reference in New Issue
Block a user