From dbecd9a22bc413394a9a426e3cd5b878b342894b Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 30 Jul 2025 14:03:44 +0200 Subject: [PATCH] canvi de pc --- source/define_buttons.cpp | 19 ++-- source/define_buttons.h | 5 +- source/director.cpp | 88 +++++++-------- source/global_inputs.cpp | 2 +- source/input.cpp | 215 ++++++++++-------------------------- source/input.h | 101 ++++++++--------- source/options.cpp | 5 +- source/options.h | 26 ++++- source/sections/credits.cpp | 2 +- source/sections/game.cpp | 2 +- 10 files changed, 189 insertions(+), 276 deletions(-) diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 858ee22..e9235a1 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -12,8 +12,7 @@ // Constructor DefineButtons::DefineButtons() - : input_(Input::get()), - text_(Resource::get()->getText("8bithud")) { + : input_(Input::get()) { // Inicializa variables x_ = param.game.width / 2; y_ = param.title.press_start_position; @@ -27,10 +26,11 @@ DefineButtons::DefineButtons() // Dibuja el objeto en pantalla void DefineButtons::render() { + static auto text = Resource::get()->getText("8bithud"); if (enabled_) { - text_->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(Options::controllers.at(index_controller_).player_id)); - text_->writeCentered(x_, y_, controller_names_.at(index_controller_)); - text_->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label); + text->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(Options::controllers.at(index_controller_).player_id)); + text->writeCentered(x_, y_, controller_names_.at(index_controller_)); + text->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label); } } @@ -49,14 +49,14 @@ void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event) } // Asigna los botones definidos al input_ -void DefineButtons::bindButtons() { +void DefineButtons::bindButtons(std::shared_ptr gamepad) { for (const auto &button : buttons_) { - input_->bindGameControllerButton(index_controller_, button.action, button.button); + input_->bindGameControllerButton(gamepad, button.action, button.button); } // Remapea los inputs a inputs - input_->bindGameControllerButton(index_controller_, Input::Action::SM_SELECT, Input::Action::FIRE_LEFT); - input_->bindGameControllerButton(index_controller_, Input::Action::SM_BACK, Input::Action::FIRE_CENTER); + input_->bindGameControllerButton(gamepad, Input::Action::SM_SELECT, Input::Action::FIRE_LEFT); + input_->bindGameControllerButton(gamepad, Input::Action::SM_BACK, Input::Action::FIRE_CENTER); } // Comprueba los eventos @@ -80,7 +80,6 @@ auto DefineButtons::enable(int index) -> bool { if (index < input_->getNumControllers()) { enabled_ = true; finished_ = false; - index_controller_ = index; index_button_ = 0; clearButtons(); return true; diff --git a/source/define_buttons.h b/source/define_buttons.h index f14a488..59feb6e 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -9,7 +9,6 @@ #include // Para vector #include "input.h" -#include "text.h" // Clase DefineButtons class DefineButtons { @@ -35,13 +34,11 @@ class DefineButtons { private: // Objetos Input *input_ = nullptr; // Gestión de entrada - std::shared_ptr text_; // Renderizado de texto // Variables bool enabled_ = false; // Indica si está activo int x_ = 0, y_ = 0; // Coordenadas de texto std::vector