diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 1100663..bd1c732 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -12,11 +12,12 @@ // Constructor DefineButtons::DefineButtons() - : input_(Input::get()) { - // Inicializa variables - x_ = param.game.width / 2; - y_ = param.title.press_start_position; - + : input_(Input::get()), + enabled_(false), + finished_(false), + x_(param.game.width / 2), + y_(param.title.press_start_position), + index_button_(0) { clearButtons(); auto gamepads = input_->getGamepads(); @@ -29,8 +30,8 @@ DefineButtons::DefineButtons() 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(static_cast(gamepad_options_->player_id))); - text->writeCentered(x_, y_, gamepad_options_->instance->name); + text->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(static_cast(gamepad_->player_id))); + text->writeCentered(x_, y_, gamepad_->name); text->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label); } } @@ -77,9 +78,9 @@ void DefineButtons::checkEvents(const SDL_Event &event) { } // Habilita el objeto -auto DefineButtons::enable(std::shared_ptr gamepad_options) -> bool { - if (gamepad_options != nullptr) { - gamepad_options_ = gamepad_options; +auto DefineButtons::enable(Options::Gamepad *gamepad) -> bool { + if (gamepad != nullptr) { + gamepad_ = gamepad; enabled_ = true; finished_ = false; index_button_ = 0; diff --git a/source/define_buttons.h b/source/define_buttons.h index dc46a16..fd4fc77 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -27,10 +27,10 @@ class DefineButtons { DefineButtons(); ~DefineButtons() = default; - void render(); // Dibuja el objeto en pantalla - void checkEvents(const SDL_Event &event); // Procesa los eventos - auto enable(std::shared_ptr gamepad_options) -> bool; // Habilita la redefinición de botones - [[nodiscard]] auto isEnabled() const -> bool { return enabled_; }; // Comprueba si está habilitado + void render(); // Dibuja el objeto en pantalla + void checkEvents(const SDL_Event &event); // Procesa los eventos + auto enable(Options::Gamepad *gamepad) -> bool; // Habilita la redefinición de botones + [[nodiscard]] auto isEnabled() const -> bool { return enabled_; }; // Comprueba si está habilitado private: // Objetos @@ -38,12 +38,13 @@ class DefineButtons { // Variables bool enabled_ = false; // Indica si está activo - int x_ = 0, y_ = 0; // Coordenadas de texto + bool finished_ = false; // Indica si ha terminado + int x_ = 0; // Coordenadas de texto + int y_ = 0; // Coordenadas de texto std::vector