Al intercambiar los mandos de los jugadores se muestra el mando que corresponde a cada jugador

This commit is contained in:
2024-09-15 14:30:58 +02:00
parent 7ef75184a5
commit 41e57064cb
2 changed files with 31 additions and 6 deletions

View File

@@ -225,9 +225,7 @@ void Title::checkEvents()
break;
case SDLK_3:
defineButtons->swapControllers();
screen->showNotification("Swap Controllers");
resetCounter();
swapControllers();
break;
default:
@@ -291,9 +289,7 @@ void Title::checkInput()
break;
case SERVICE_SWAP_CONTROLLERS:
defineButtons->swapControllers();
screen->showNotification("Swap Controllers");
resetCounter();
swapControllers();
break;
default:
@@ -342,4 +338,30 @@ void Title::reLoadTextures()
void Title::resetCounter()
{
counter = 0;
}
// Intercambia la asignación de mandos a los jugadores
void Title::swapControllers()
{
const int numControllers = input->getNumControllers();
if (numControllers == 0)
{
return;
}
defineButtons->swapControllers();
const std::string text0 = "Jugador " + std::to_string(options->controller[0].playerId) + " -> " + options->controller[0].name;
const std::string text1 = "Jugador " + std::to_string(options->controller[1].playerId) + " -> " + options->controller[1].name;
if (numControllers == 1)
{
screen->showNotification(text0);
}
else
{
screen->showNotification(text0, text1);
}
resetCounter();
}