corregida la carrega de config.txt
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <utility> // Para pair
|
||||
|
||||
#include "utils/utils.hpp" // Para stringToBool, boolToString, safeStoi
|
||||
#include "game/defaults.hpp" // Para GameDefaults::VERSION
|
||||
|
||||
namespace Options {
|
||||
// Declaración de funciones internas
|
||||
@@ -97,8 +98,8 @@ auto readConfigFile(const std::string& file_path) -> bool {
|
||||
|
||||
// Carga las opciones desde un fichero
|
||||
auto loadFromFile(const std::string& file_path) -> bool {
|
||||
// Versión actual del fichero
|
||||
const std::string CONFIG_VERSION = version;
|
||||
// Versión esperada del fichero
|
||||
const std::string CONFIG_VERSION = GameDefaults::VERSION;
|
||||
version = "";
|
||||
|
||||
// Intenta leer el fichero
|
||||
@@ -144,9 +145,6 @@ auto saveToFile(const std::string& file_path) -> bool {
|
||||
file << "# Versión de la configuración\n";
|
||||
file << "version " << version << "\n";
|
||||
|
||||
file << "\n## CONTROL\n";
|
||||
file << "# Esquema de control: 0 = Cursores, 1 = OPQ, 2 = WAD\n";
|
||||
file << "keys " << static_cast<int>(keys) << "\n";
|
||||
|
||||
file << "\n## WINDOW\n";
|
||||
file << "# Zoom de la ventana: 1 = Normal, 2 = Doble, 3 = Triple, ...\n";
|
||||
@@ -183,6 +181,10 @@ auto saveToFile(const std::string& file_path) -> bool {
|
||||
auto setOptions(const std::string& var, const std::string& value) -> bool {
|
||||
static const std::unordered_map<std::string, std::function<void(const std::string&)>> OPTION_HANDLERS = {
|
||||
{"version", [](const std::string& v) { version = v; }},
|
||||
{"keys", [](const std::string& v) {
|
||||
// Parámetro obsoleto, se ignora silenciosamente para compatibilidad con archivos antiguos
|
||||
(void)v;
|
||||
}},
|
||||
{"window.zoom", [](const std::string& v) {
|
||||
int val = safeStoi(v, GameDefaults::WINDOW_ZOOM);
|
||||
if (val > 0) {
|
||||
|
||||
Reference in New Issue
Block a user