define_buttons: modificada logica de final per a poder mostrar la animació d'eixida
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
#include "ui/window_message.h"
|
||||
|
||||
namespace Options {
|
||||
@@ -19,12 +18,12 @@ struct Gamepad;
|
||||
class DefineButtons {
|
||||
public:
|
||||
struct Button {
|
||||
std::string label;
|
||||
Input::Action action;
|
||||
SDL_GamepadButton button;
|
||||
std::string label;
|
||||
Input::Action action;
|
||||
SDL_GamepadButton button;
|
||||
|
||||
Button(std::string label, Input::Action action, SDL_GamepadButton button)
|
||||
: label(std::move(label)), action(action), button(button) {}
|
||||
Button(std::string label, Input::Action action, SDL_GamepadButton button)
|
||||
: label(std::move(label)), action(action), button(button) {}
|
||||
};
|
||||
|
||||
DefineButtons();
|
||||
@@ -35,20 +34,34 @@ class DefineButtons {
|
||||
void checkEvents(const SDL_Event &event);
|
||||
auto enable(Options::Gamepad *options_gamepad) -> bool;
|
||||
void disable();
|
||||
bool isReadyToClose() const;
|
||||
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; }
|
||||
[[nodiscard]] auto isFinished() const -> bool { return finished_; }
|
||||
|
||||
private:
|
||||
Input *input_ = nullptr;
|
||||
std::unique_ptr<WindowMessage> window_message_;
|
||||
// Constante para cuánto tiempo mostrar el mensaje (en frames)
|
||||
static constexpr size_t MESSAGE_DISPLAY_FRAMES = 180; // ~3 segundos a 60fps
|
||||
|
||||
bool enabled_ = false;
|
||||
bool finished_ = false;
|
||||
std::vector<Button> buttons_;
|
||||
size_t index_button_ = 0;
|
||||
std::vector<std::string> controller_names_;
|
||||
Options::Gamepad *options_gamepad_ = nullptr;
|
||||
// Punteros
|
||||
Input *input_ = nullptr; // Entrada del usuario
|
||||
Options::Gamepad *options_gamepad_ = nullptr; // Opciones del gamepad
|
||||
std::unique_ptr<WindowMessage> window_message_; // Mensaje de ventana
|
||||
|
||||
// Vectores y strings
|
||||
std::vector<Button> buttons_; // Lista de botones
|
||||
std::vector<std::string> controller_names_; // Nombres de los controladores
|
||||
|
||||
// size_t
|
||||
size_t index_button_ = 0; // Índice del botón seleccionado
|
||||
size_t message_timer_ = 0; // Contador de frames para el mensaje
|
||||
|
||||
// bools
|
||||
bool enabled_ = false; // Flag para indicar si está activo
|
||||
bool finished_ = false; // Flag para indicar si ha terminado
|
||||
bool closing_ = false; // Flag para indicar que está cerrando
|
||||
bool message_shown_ = false; // Flag para indicar que ya mostró el mensaje
|
||||
|
||||
// Métodos
|
||||
void incIndexButton();
|
||||
void doControllerButtonDown(const SDL_GamepadButtonEvent &event);
|
||||
void bindButtons(Options::Gamepad *options_gamepad);
|
||||
|
||||
Reference in New Issue
Block a user