Añadido botón de servicio al titulo

This commit is contained in:
2024-09-09 13:31:37 +02:00
parent 7e1085ea42
commit 1b2d1c5786
6 changed files with 65 additions and 34 deletions

View File

@@ -328,8 +328,6 @@ void Screen::checkInput()
else if (input->checkInput(input_video_shaders, DO_NOT_ALLOW_REPEAT))
{
switchShaders();
const std::string value = options->video.shaders ? "on" : "off";
showNotification("Shaders " + value);
}
#endif
@@ -419,6 +417,8 @@ void Screen::switchShaders()
{
options->video.shaders = !options->video.shaders;
setVideoMode(options->video.mode);
const std::string value = options->video.shaders ? "on" : "off";
showNotification("Shaders " + value);
}
// Atenua la pantalla

View File

@@ -20,17 +20,17 @@ DefineButtons::DefineButtons(Input *input, Text *text, param_t *param, options_t
buttons.clear();
db_button_t button;
button.label = "DISPARO IZQUIERDA";
button.label = "DISPARAR CAP A L'ESQUERRA";
button.input = input_fire_left;
button.button = SDL_CONTROLLER_BUTTON_X;
buttons.push_back(button);
button.label = "DISPARO CENTRO";
button.label = "DISPARAR CAP AMUNT";
button.input = input_fire_center;
button.button = SDL_CONTROLLER_BUTTON_Y;
buttons.push_back(button);
button.label = "DISPARO DERECHA";
button.label = "DISPARAR CAP A LA DRETA";
button.input = input_fire_right;
button.button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
buttons.push_back(button);
@@ -40,7 +40,7 @@ DefineButtons::DefineButtons(Input *input, Text *text, param_t *param, options_t
button.button = SDL_CONTROLLER_BUTTON_START;
buttons.push_back(button);
button.label = "SALIR DEL JUEGO";
button.label = "SERVEI";
button.input = input_exit;
button.button = SDL_CONTROLLER_BUTTON_BACK;
buttons.push_back(button);
@@ -69,7 +69,7 @@ void DefineButtons::render()
{
if (enabled)
{
text->writeCentered(x, y - 10, "PLAYER " + std::to_string(indexController + 1));
text->writeCentered(x, y - 10, "JUGADOR " + std::to_string(indexController + 1));
text->writeCentered(x, y, controllerNames[indexController]);
text->writeCentered(x, y + 10, buttons[indexButton].label);
}

View File

@@ -1,25 +1,26 @@
#include "service.h"
int checkServiceButton(Input *input)
// Comprueba el botón de servicio del controlador "index"
int checkServiceButton(Input *input, int index)
{
if (input->checkInput(input_service))
if (input->checkInput(input_service, true, INPUT_USE_GAMECONTROLLER, index))
{
if (input->checkInput(input_start))
if (input->checkInput(input_start, false, INPUT_USE_GAMECONTROLLER, index))
{
return SERVICE_EXIT;
}
else if (input->checkInput(input_fire_left))
else if (input->checkInput(input_fire_left, false, INPUT_USE_GAMECONTROLLER, index))
{
return SERVICE_CONFIG;
}
else if (input->checkInput(input_fire_center))
else if (input->checkInput(input_fire_center, false, INPUT_USE_GAMECONTROLLER, index))
{
return SERVICE_SHADERS;
}
else if (input->checkInput(input_fire_right))
else if (input->checkInput(input_fire_right, false, INPUT_USE_GAMECONTROLLER, index))
{
return SERVICE_PAUSE;
}

View File

@@ -11,5 +11,5 @@
#define SERVICE_SHADERS 3
#define SERVICE_PAUSE 4
// Comprueba el botón de servicio
int checkServiceButton(Input *input);
// Comprueba el botón de servicio del controlador "index"
int checkServiceButton(Input *input, int index);

View File

@@ -221,15 +221,15 @@ void Title::checkEvents()
}
// Comprueba en el primer mando el botón de salir del programa
else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN)
{
if ((SDL_GameControllerButton)eventHandler->cbutton.which == 0)
if ((SDL_GameControllerButton)eventHandler->cbutton.button == input->getControllerBinding(0, input_exit))
{
section->name = SECTION_PROG_QUIT;
break;
}
}
// else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN)
//{
// if ((SDL_GameControllerButton)eventHandler->cbutton.which == 0)
// if ((SDL_GameControllerButton)eventHandler->cbutton.button == input->getControllerBinding(0, input_exit))
// {
// section->name = SECTION_PROG_QUIT;
// break;
// }
//}
}
}
}
@@ -240,16 +240,9 @@ void Title::checkInput()
// Comprueba los controladores solo si no se estan definiendo los botones
if (!defineButtons->isEnabled())
{
// Comprueba si se ha pulsado algún botón para empezar a jugar
const int index = input->checkAnyButtonPressed();
if (index)
{
if (section->subsection == SUBSECTION_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{ // No se puede empezar a jugar durante la animación del titulo a menos que se permita
fade->activate();
postFade = index;
}
}
//////////////////////////////////////////////////
// TECLADO //
//////////////////////////////////////////////////
// Comprueba el teclado para salir
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
@@ -269,6 +262,42 @@ void Title::checkInput()
{
defineButtons->enable(1);
}
//////////////////////////////////////////////////
// MANDO //
//////////////////////////////////////////////////
// Comprueba el botón de SERVICE
switch (checkServiceButton(input, 0))
{
case SERVICE_EXIT:
section->name = SECTION_PROG_QUIT;
break;
case SERVICE_SHADERS:
screen->switchShaders();
break;
case SERVICE_CONFIG:
defineButtons->enable(0);
break;
default:
break;
}
// Comprueba el botón de START
for (int i = 0; i < input->getNumControllers(); ++i)
{
if (input->checkInput(input_start, false, INPUT_USE_GAMECONTROLLER, i))
{
if (section->subsection == SUBSECTION_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{
fade->activate();
postFade = i + 1;
}
}
}
}
// Comprueba el input para el resto de objetos

View File

@@ -20,6 +20,7 @@
#include "tiledbg.h"
#include "game_logo.h"
#include "define_buttons.h"
#include "service.h"
// Textos
#define TEXT_COPYRIGHT "@2020,2024 JailDesigner"