This commit is contained in:
2024-09-16 22:21:57 +02:00
parent 80425a5ed0
commit 159a75a60e
12 changed files with 384 additions and 307 deletions

View File

@@ -1,5 +1,4 @@
#include "title.h"
#include "service.h"
// Constructor
Title::Title(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music)
@@ -122,6 +121,10 @@ void Title::update()
{
counter++;
}
else
{
counter = 0;
}
// Reproduce la música
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
@@ -246,11 +249,12 @@ void Title::checkInput()
// TECLADO //
//////////////////////////////////////////////////
// Comprueba el teclado para salir
// Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{
section->name = SECTION_PROG_QUIT;
section->options = SECTION_OPTIONS_QUIT_NORMAL;
return;
}
// Comprueba el teclado para empezar a jugar
@@ -264,50 +268,51 @@ void Title::checkInput()
}
//////////////////////////////////////////////////
// MANDO //
// MANDOS //
//////////////////////////////////////////////////
// Comprueba el botón de SERVICE
switch (checkServiceButton(input))
{
case SERVICE_RESET:
section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset");
break;
case SERVICE_MUTE:
options->audio.sound.enabled = options->audio.music.enabled = !options->audio.music.enabled;
JA_EnableMusic(options->audio.music.enabled);
JA_EnableSound(options->audio.sound.enabled);
screen->showNotification("Audio " + boolToOnOff(options->audio.music.enabled));
break;
case SERVICE_SWAP_CONTROLLERS:
swapControllers();
break;
default:
break;
}
// Comprueba si algun mando quiere ser configurado
for (int i = 0; i < input->getNumControllers(); ++i)
{
if (checkServiceButton(input, i) == SERVICE_CONFIG)
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset");
return;
}
// Comprueba si se va a activar o desactivar el audio
if (input->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
options->audio.sound.enabled = options->audio.music.enabled = !options->audio.music.enabled;
JA_EnableMusic(options->audio.music.enabled);
JA_EnableSound(options->audio.sound.enabled);
screen->showNotification("Audio " + boolToOnOff(options->audio.music.enabled));
return;
}
// Comprueba si se va a intercambiar la asignación de mandos a jugadores
if (input->checkModInput(input_service, input_swap_controllers, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
swapControllers();
return;
}
// Comprueba si algun mando quiere ser configurado
if (input->checkModInput(input_service, input_config, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
defineButtons->enable(i);
return;
}
}
// Comprueba el botón de START de los mandos
for (int i = 0; i < input->getNumControllers(); ++i)
{
// Comprueba el botón de START de los mandos
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{
fade->activate();
postFade = options->controller[i].playerId;
return;
}
}
}
@@ -358,20 +363,27 @@ void Title::swapControllers()
// Crea cadenas de texto vacias para un numero máximo de mandos
const int MAX_CONTROLLERS = 2;
std::string text[MAX_CONTROLLERS];
int playerControllerIndex[MAX_CONTROLLERS];
for (int i = 0; i < MAX_CONTROLLERS; ++i)
{
text[i] = "";
playerControllerIndex[i] = -1;
}
// Obtiene para cada jugador el índice del mando correspondiente
int playerControllerIndex[numControllers];
for (int i = 0; i < numControllers; ++i)
for (int i = 0; i < MAX_CONTROLLERS; ++i)
{
playerControllerIndex[options->controller[i].playerId - 1] = i;
}
// Genera el texto correspondiente
for (int i = 0; i < numControllers; ++i)
for (int i = 0; i < MAX_CONTROLLERS; ++i)
{
text[i] = "Jugador " + std::to_string(i + 1) + ": " + options->controller[playerControllerIndex[i]].name;
const int index = playerControllerIndex[i];
if (options->controller[index].name != "NO NAME")
{
text[i] = "Jugador " + std::to_string(i + 1) + ": " + options->controller[index].name;
}
}
screen->showNotification(text[0], text[1]);