les tecles de control estan definides al fitxer de configuracio

This commit is contained in:
2025-11-02 17:08:56 +01:00
parent 9102c6a65e
commit ba06bccabc
7 changed files with 57 additions and 19 deletions

View File

@@ -171,6 +171,14 @@ auto saveToFile(const std::string& file_path) -> bool {
file << "# Paleta\n";
file << "video.palette " << video.palette << "\n";
file << "\n## CONTROLS\n";
file << "# Tecla para mover a la izquierda (SDL_Scancode)\n";
file << "controls.left " << static_cast<int>(controls.key_left) << "\n\n";
file << "# Tecla para mover a la derecha (SDL_Scancode)\n";
file << "controls.right " << static_cast<int>(controls.key_right) << "\n\n";
file << "# Tecla para saltar (SDL_Scancode)\n";
file << "controls.jump " << static_cast<int>(controls.key_jump) << "\n";
// Cierra el fichero
file.close();
@@ -224,6 +232,18 @@ auto setOptions(const std::string& var, const std::string& value) -> bool {
}},
{"video.palette", [](const std::string& v) {
video.palette = v;
}},
{"controls.left", [](const std::string& v) {
int val = safeStoi(v, SDL_SCANCODE_LEFT);
controls.key_left = static_cast<SDL_Scancode>(val);
}},
{"controls.right", [](const std::string& v) {
int val = safeStoi(v, SDL_SCANCODE_RIGHT);
controls.key_right = static_cast<SDL_Scancode>(val);
}},
{"controls.jump", [](const std::string& v) {
int val = safeStoi(v, SDL_SCANCODE_UP);
controls.key_jump = static_cast<SDL_Scancode>(val);
}}};
auto it = OPTION_HANDLERS.find(var);