.
This commit is contained in:
@@ -10,49 +10,22 @@
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
DefineButtons::DefineButtons(std::unique_ptr<Text> text_)
|
DefineButtons::DefineButtons(std::unique_ptr<Text> text_)
|
||||||
: text_(std::move(text_))
|
: input_(Input::get()),
|
||||||
|
text_(std::move(text_))
|
||||||
{
|
{
|
||||||
// Copia punteros a los objetos
|
|
||||||
input_ = Input::get();
|
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
enabled_ = false;
|
|
||||||
x_ = param.game.width / 2;
|
x_ = param.game.width / 2;
|
||||||
y_ = param.title.press_start_position;
|
y_ = param.title.press_start_position;
|
||||||
index_controller_ = 0;
|
|
||||||
index_button_ = 0;
|
|
||||||
|
|
||||||
buttons_.clear();
|
buttons_.emplace_back(lang::getText(95), InputType::FIRE_LEFT, SDL_CONTROLLER_BUTTON_X);
|
||||||
DefineButtonsButton button;
|
buttons_.emplace_back(lang::getText(96), InputType::FIRE_CENTER, SDL_CONTROLLER_BUTTON_Y);
|
||||||
|
buttons_.emplace_back(lang::getText(97), InputType::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
button.label = lang::getText(95);
|
buttons_.emplace_back(lang::getText(98), InputType::START, SDL_CONTROLLER_BUTTON_START);
|
||||||
button.input = InputType::FIRE_LEFT;
|
buttons_.emplace_back(lang::getText(99), InputType::EXIT, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
button.button = SDL_CONTROLLER_BUTTON_X;
|
|
||||||
buttons_.push_back(button);
|
|
||||||
|
|
||||||
button.label = lang::getText(96);
|
|
||||||
button.input = InputType::FIRE_CENTER;
|
|
||||||
button.button = SDL_CONTROLLER_BUTTON_Y;
|
|
||||||
buttons_.push_back(button);
|
|
||||||
|
|
||||||
button.label = lang::getText(97);
|
|
||||||
button.input = InputType::FIRE_RIGHT;
|
|
||||||
button.button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
|
|
||||||
buttons_.push_back(button);
|
|
||||||
|
|
||||||
button.label = lang::getText(98);
|
|
||||||
button.input = InputType::START;
|
|
||||||
button.button = SDL_CONTROLLER_BUTTON_START;
|
|
||||||
buttons_.push_back(button);
|
|
||||||
|
|
||||||
button.label = lang::getText(99);
|
|
||||||
button.input = InputType::EXIT;
|
|
||||||
button.button = SDL_CONTROLLER_BUTTON_BACK;
|
|
||||||
buttons_.push_back(button);
|
|
||||||
|
|
||||||
for (int i = 0; i < input_->getNumControllers(); ++i)
|
for (int i = 0; i < input_->getNumControllers(); ++i)
|
||||||
{
|
{
|
||||||
controller_names_.push_back(input_->getControllerName(i));
|
controller_names_.emplace_back(input_->getControllerName(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ struct DefineButtonsButton
|
|||||||
std::string label; // Texto en pantalla para el botón
|
std::string label; // Texto en pantalla para el botón
|
||||||
InputType input; // Input asociado
|
InputType input; // Input asociado
|
||||||
SDL_GameControllerButton button; // Botón del mando correspondiente
|
SDL_GameControllerButton button; // Botón del mando correspondiente
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
DefineButtonsButton(const std::string &lbl, InputType inp, SDL_GameControllerButton btn)
|
||||||
|
: label(lbl), input(inp), button(btn) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clase Bullet
|
// Clase Bullet
|
||||||
@@ -25,12 +29,12 @@ private:
|
|||||||
std::shared_ptr<Text> text_; // Objeto para escribir texto
|
std::shared_ptr<Text> text_; // Objeto para escribir texto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
bool enabled_; // Indica si el objeto está habilitado
|
bool enabled_ = false; // Indica si el objeto está habilitado
|
||||||
int x_; // Posición donde dibujar el texto
|
int x_; // Posición donde dibujar el texto
|
||||||
int y_; // Posición donde dibujar el texto
|
int y_; // Posición donde dibujar el texto
|
||||||
std::vector<DefineButtonsButton> buttons_; // Vector con las nuevas definiciones de botones/acciones
|
std::vector<DefineButtonsButton> buttons_; // Vector con las nuevas definiciones de botones/acciones
|
||||||
int index_controller_; // Indice del controlador a reasignar
|
int index_controller_ = 0; // Indice del controlador a reasignar
|
||||||
int index_button_; // Indice para saber qué bot´çon se está definiendo
|
int index_button_ = 0; // Indice para saber qué bot´çon se está definiendo
|
||||||
std::vector<std::string> controller_names_; // Nombres de los mandos
|
std::vector<std::string> controller_names_; // Nombres de los mandos
|
||||||
|
|
||||||
// Incrementa el indice de los botones
|
// Incrementa el indice de los botones
|
||||||
|
|||||||
Reference in New Issue
Block a user