74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include "common/input.h"
|
|
#include "common/text.h"
|
|
#include "const.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
|
|
section_t *section; // Indicador para el bucle del titulo
|
|
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
|
|
std::vector<std::string> controllerNames; // Nombres de los mandos
|
|
|
|
// Incrementa el indice de los botones
|
|
void incIndexButton();
|
|
|
|
// Comprueba el botón que se ha pulsado
|
|
void doControllerButtonDown(SDL_ControllerButtonEvent *event);
|
|
|
|
// Asigna los botones definidos al input
|
|
void bindButtons();
|
|
|
|
// Guarda los cambios en las opciones
|
|
void saveBindingsToOptions();
|
|
|
|
public:
|
|
// Constructor
|
|
DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options, section_t *section);
|
|
|
|
// 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 |