From ed91bff7dfe6ed9d0da36427802adc40a47d606c Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 26 Jun 2025 22:26:38 +0200 Subject: [PATCH] =?UTF-8?q?Options:=20afegida=20opci=C3=B3=20per=20inverti?= =?UTF-8?q?r=20el=20y=5Faxis=20(la=20recre=20te=20els=20mandos=20mal=20cab?= =?UTF-8?q?lejats)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/director.cpp | 8 ++++---- source/options.cpp | 6 ++++++ source/options.h | 3 ++- source/param.cpp | 10 +++++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index b24d10c..0fae52a 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -160,8 +160,8 @@ void Director::loadScoreFile() void Director::bindInputs() { // Teclado - Movimiento del jugador - Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP); - Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN); + Input::get()->bindKey(InputAction::UP, Options::settings.is_y_axis_inverted ? SDL_SCANCODE_DOWN : SDL_SCANCODE_UP); + Input::get()->bindKey(InputAction::DOWN, Options::settings.is_y_axis_inverted ? SDL_SCANCODE_UP : SDL_SCANCODE_DOWN); Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT); Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT); @@ -202,8 +202,8 @@ void Director::bindInputs() for (int i = 0; i < NUM_GAMEPADS; ++i) { // Mando - Movimiento del jugador - Input::get()->bindGameControllerButton(i, InputAction::UP, SDL_GAMEPAD_BUTTON_DPAD_UP); - Input::get()->bindGameControllerButton(i, InputAction::DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN); + Input::get()->bindGameControllerButton(i, InputAction::UP, Options::settings.is_y_axis_inverted ? SDL_GAMEPAD_BUTTON_DPAD_DOWN : SDL_GAMEPAD_BUTTON_DPAD_UP); + Input::get()->bindGameControllerButton(i, InputAction::DOWN, Options::settings.is_y_axis_inverted ? SDL_GAMEPAD_BUTTON_DPAD_UP : SDL_GAMEPAD_BUTTON_DPAD_DOWN); Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT); Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT); diff --git a/source/options.cpp b/source/options.cpp index a180eee..e96891e 100644 --- a/source/options.cpp +++ b/source/options.cpp @@ -55,6 +55,7 @@ namespace Options settings.language = Lang::Code::VALENCIAN; settings.autofire = true; settings.shutdown_enabled = false; + settings.is_y_axis_inverted = false; settings.clearLastHiScoreEntries(); settings.config_file = Asset::get()->get("config.txt"); @@ -172,6 +173,7 @@ namespace Options file << "game.difficulty=" << static_cast(settings.difficulty) << "\n"; file << "game.autofire=" << boolToString(settings.autofire) << "\n"; file << "game.shutdown_enabled=" << boolToString(settings.shutdown_enabled) << "\n"; + file << "game.is_y_axis_inverted=" << boolToString(settings.is_y_axis_inverted) << "\n"; // Opciones de mandos file << "\n\n## CONTROLLERS\n"; @@ -276,6 +278,10 @@ namespace Options { settings.shutdown_enabled = stringToBool(value); } + else if (var == "game.is_y_axis_inverted") + { + settings.is_y_axis_inverted = stringToBool(value); + } // Opciones de mandos else if (var == "controller.0.name") diff --git a/source/options.h b/source/options.h index 6f4d783..c79ab71 100644 --- a/source/options.h +++ b/source/options.h @@ -81,6 +81,7 @@ namespace Options Lang::Code language; // Idioma usado en el juego bool autofire; // Indicador de autofire bool shutdown_enabled; // Especifica si se puede apagar el sistema + bool is_y_axis_inverted; // Indica si hay que invertir el eje Y de los controles std::vector hi_score_table; // Tabla de mejores puntuaciones std::vector last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla std::string config_file; // Ruta al fichero donde guardar la configuracion y las opciones del juego @@ -138,6 +139,6 @@ namespace Options int getPlayerWhoUsesKeyboard(); // Averigua quién está usando el teclado void applyPendingChanges(); // Aplica los cambios pendientes copiando los valores a sus variables void checkPendingChanges(); - DifficultyCode getDifficultyCodeFromName(const std::string& name); + DifficultyCode getDifficultyCodeFromName(const std::string &name); std::string getDifficultyNameFromCode(DifficultyCode code); } // namespace Options \ No newline at end of file diff --git a/source/param.cpp b/source/param.cpp index 1c7aa4a..4063e0d 100644 --- a/source/param.cpp +++ b/source/param.cpp @@ -30,7 +30,15 @@ void initParam() precalculateZones(); // SCOREBOARD - param.scoreboard = {0, 216, param.game.width, 40}; + param.scoreboard.rect = {0, 216, param.game.width, 40}; + param.scoreboard.separator_autocolor = false; + param.scoreboard.separator_color = Color(); + param.scoreboard.easy_color = Color(); + param.scoreboard.normal_color = Color(); + param.scoreboard.hard_color = Color(); + param.scoreboard.text_autocolor = false; + param.scoreboard.text_color1 = Color(); + param.scoreboard.text_color2 = Color(); // FADE param.fade.num_squares_width = param.game.width / 2;