claude: treballant en el nou define_buttons

This commit is contained in:
2025-08-06 14:12:29 +02:00
parent 1224af2a9b
commit 6d36291f51
12 changed files with 650 additions and 190 deletions

View File

@@ -1,58 +1,59 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_Event, SDL_GamepadButtonEvent
#include <SDL3/SDL.h>
#include <cstddef> // Para size_t
#include <string> // Para string
#include <utility> // Para move
#include <vector> // Para vector
#include <cstddef>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "input.h" // Para Input
#include "input.h"
class WindowMessage;
namespace Options {
struct Gamepad;
} // namespace Options
}
// Clase DefineButtons
class DefineButtons {
public:
// Estructura para definir botones
struct Button {
std::string label; // Texto en pantalla
Input::Action action; // Acción asociada
SDL_GamepadButton button; // Botón del mando
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();
~DefineButtons() = default;
void render(); // Dibuja el objeto en pantalla
void checkEvents(const SDL_Event &event); // Procesa los eventos
auto enable(Options::Gamepad *options_gamepad) -> bool; // Habilita la redefinición de botones
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; }; // Comprueba si está habilitado
void render();
void update();
void checkEvents(const SDL_Event &event);
auto enable(Options::Gamepad *options_gamepad) -> bool;
void disable();
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; }
[[nodiscard]] auto isFinished() const -> bool { return finished_; }
private:
// Objetos
Input *input_ = nullptr; // Gestión de entrada
Input *input_ = nullptr;
std::unique_ptr<WindowMessage> window_message_;
// Variables
bool enabled_ = false; // Indica si está activo
bool finished_ = false; // Indica si ha terminado
int x_ = 0; // Coordenadas de texto
int y_ = 0; // Coordenadas de texto
std::vector<Button> buttons_; // Definiciones de botones
size_t index_button_ = 0; // Índice del botón en proceso
std::vector<std::string> controller_names_; // Nombres de los mandos
Options::Gamepad *options_gamepad_;
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;
// Métodos internos
void incIndexButton(); // Incrementa el índice de botones
void doControllerButtonDown(const SDL_GamepadButtonEvent &event); // Procesa pulsaciones
void bindButtons(Options::Gamepad *options_gamepad); // Asigna botones al sistema de entrada
auto checkButtonNotInUse(SDL_GamepadButton button) -> bool; // Verifica uso de botones
void clearButtons(); // Limpia asignaciones actuales
void checkEnd(); // Comprueba si ha finalizado
};
void incIndexButton();
void doControllerButtonDown(const SDL_GamepadButtonEvent &event);
void bindButtons(Options::Gamepad *options_gamepad);
auto checkButtonNotInUse(SDL_GamepadButton button) -> bool;
void clearButtons();
void checkEnd();
void updateWindowMessage();
};