empezando a trabajar en la clase DefineButtons

This commit is contained in:
2024-07-06 13:25:15 +02:00
parent 78a689760d
commit c8cd375d81
4 changed files with 309 additions and 35 deletions

64
source/define_buttons.h Normal file
View File

@@ -0,0 +1,64 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/input.h"
#include "common/text.h"
#ifndef DEFINE_BUTTONS_H
#define DEFINE_BUTTONS_H
struct db_button_t
{
std::string label; // Texto en pantalla para el botón
inputs_e input; // Input asociado
SDL_GameControllerButton button; // Botón del mando correspondiente
};
// Clase Bullet
class DefineButtons
{
private:
// Objetos
SDL_Renderer *renderer; // El renderizador de la ventana
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para escribir texto
// Variables
options_t *options; // Variable con todas las variables de las opciones del programa
param_t *param; // Puntero con todos los parametros del programa
bool enabled; // Indica si el objeto está habilitado
int x; // Posición donde dibujar el texto
int y; // Posición donde dibujar el texto
std::vector<db_button_t> buttons; // Vector con las nuevas definiciones de botones/acciones
int indexController; // Indice del controlador a reasignar
int indexButton; // Indice para saber qué bot´çon se está definiendo
// Incrementa el indice de los botones
void incIndexButton();
void doJoystickButtonDown(SDL_JoyButtonEvent *event);
public:
// Constructor
DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options);
// Destructor
~DefineButtons();
// Actualiza las variables del objeto
void update();
// Dibuja el objeto en pantalla
void render();
// Comprueba las entradas
void checkInput();
// Habilita el objeto
void enable(int index);
// Comprueba si está habilitado
bool isEnabled();
};
#endif