forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -276,7 +276,7 @@ void init() {
|
||||
|
||||
// Establece la ruta del fichero de configuración
|
||||
void setConfigFile(const std::string& path) {
|
||||
config_file_path_ = path;
|
||||
config_file_path = path;
|
||||
}
|
||||
|
||||
// Carga las opciones desde el fichero configurado
|
||||
@@ -286,10 +286,10 @@ auto loadFromFile() -> bool {
|
||||
version = "";
|
||||
|
||||
// Intenta abrir y leer el fichero
|
||||
std::ifstream file(config_file_path_);
|
||||
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;
|
||||
@@ -301,7 +301,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
try {
|
||||
if (console) {
|
||||
std::cout << "Reading config file: " << config_file_path_ << '\n';
|
||||
std::cout << "Reading config file: " << config_file_path << '\n';
|
||||
}
|
||||
|
||||
// Parsea el YAML
|
||||
@@ -351,7 +351,7 @@ auto loadFromFile() -> bool {
|
||||
// filter (ahora es string)
|
||||
if (vid.contains("filter")) {
|
||||
try {
|
||||
std::string filter_str = vid["filter"].get_value<std::string>();
|
||||
auto filter_str = vid["filter"].get_value<std::string>();
|
||||
video.filter = stringToFilter(filter_str);
|
||||
} catch (...) {
|
||||
video.filter = GameDefaults::VIDEO_FILTER;
|
||||
@@ -392,7 +392,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (vid.contains("palette")) {
|
||||
try {
|
||||
std::string palette_str = vid["palette"].get_value<std::string>();
|
||||
auto palette_str = vid["palette"].get_value<std::string>();
|
||||
if (isValidPalette(palette_str)) {
|
||||
video.palette = palette_str;
|
||||
} else {
|
||||
@@ -417,7 +417,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (border.contains("width")) {
|
||||
try {
|
||||
float val = border["width"].get_value<float>();
|
||||
auto val = border["width"].get_value<float>();
|
||||
video.border.width = (val > 0) ? val : GameDefaults::BORDER_WIDTH;
|
||||
} catch (...) {
|
||||
video.border.width = GameDefaults::BORDER_WIDTH;
|
||||
@@ -426,7 +426,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (border.contains("height")) {
|
||||
try {
|
||||
float val = border["height"].get_value<float>();
|
||||
auto val = border["height"].get_value<float>();
|
||||
video.border.height = (val > 0) ? val : GameDefaults::BORDER_HEIGHT;
|
||||
} catch (...) {
|
||||
video.border.height = GameDefaults::BORDER_HEIGHT;
|
||||
@@ -441,7 +441,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (ctrl.contains("key_left")) {
|
||||
try {
|
||||
std::string key_str = ctrl["key_left"].get_value<std::string>();
|
||||
auto key_str = ctrl["key_left"].get_value<std::string>();
|
||||
keyboard_controls.key_left = stringToScancode(key_str, GameDefaults::CONTROL_KEY_LEFT);
|
||||
} catch (...) {
|
||||
keyboard_controls.key_left = GameDefaults::CONTROL_KEY_LEFT;
|
||||
@@ -450,7 +450,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (ctrl.contains("key_right")) {
|
||||
try {
|
||||
std::string key_str = ctrl["key_right"].get_value<std::string>();
|
||||
auto key_str = ctrl["key_right"].get_value<std::string>();
|
||||
keyboard_controls.key_right = stringToScancode(key_str, GameDefaults::CONTROL_KEY_RIGHT);
|
||||
} catch (...) {
|
||||
keyboard_controls.key_right = GameDefaults::CONTROL_KEY_RIGHT;
|
||||
@@ -459,7 +459,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (ctrl.contains("key_jump")) {
|
||||
try {
|
||||
std::string key_str = ctrl["key_jump"].get_value<std::string>();
|
||||
auto key_str = ctrl["key_jump"].get_value<std::string>();
|
||||
keyboard_controls.key_jump = stringToScancode(key_str, GameDefaults::CONTROL_KEY_JUMP);
|
||||
} catch (...) {
|
||||
keyboard_controls.key_jump = GameDefaults::CONTROL_KEY_JUMP;
|
||||
@@ -473,7 +473,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (gp.contains("button_left")) {
|
||||
try {
|
||||
std::string button_str = gp["button_left"].get_value<std::string>();
|
||||
auto button_str = gp["button_left"].get_value<std::string>();
|
||||
gamepad_controls.button_left = stringToGamepadButton(button_str, GameDefaults::GAMEPAD_BUTTON_LEFT);
|
||||
} catch (...) {
|
||||
gamepad_controls.button_left = GameDefaults::GAMEPAD_BUTTON_LEFT;
|
||||
@@ -482,7 +482,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (gp.contains("button_right")) {
|
||||
try {
|
||||
std::string button_str = gp["button_right"].get_value<std::string>();
|
||||
auto button_str = gp["button_right"].get_value<std::string>();
|
||||
gamepad_controls.button_right = stringToGamepadButton(button_str, GameDefaults::GAMEPAD_BUTTON_RIGHT);
|
||||
} catch (...) {
|
||||
gamepad_controls.button_right = GameDefaults::GAMEPAD_BUTTON_RIGHT;
|
||||
@@ -491,7 +491,7 @@ auto loadFromFile() -> bool {
|
||||
|
||||
if (gp.contains("button_jump")) {
|
||||
try {
|
||||
std::string button_str = gp["button_jump"].get_value<std::string>();
|
||||
auto button_str = gp["button_jump"].get_value<std::string>();
|
||||
gamepad_controls.button_jump = stringToGamepadButton(button_str, GameDefaults::GAMEPAD_BUTTON_JUMP);
|
||||
} catch (...) {
|
||||
gamepad_controls.button_jump = GameDefaults::GAMEPAD_BUTTON_JUMP;
|
||||
@@ -519,16 +519,16 @@ auto loadFromFile() -> bool {
|
||||
// Guarda las opciones al fichero configurado
|
||||
auto saveToFile() -> bool {
|
||||
// Abre el fichero para escritura
|
||||
std::ofstream file(config_file_path_);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user