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; break;
case SDLK_3: case SDLK_3:
defineButtons->swapControllers(); swapControllers();
screen->showNotification("Swap Controllers");
resetCounter();
break; break;
default: default:
@@ -291,9 +289,7 @@ void Title::checkInput()
break; break;
case SERVICE_SWAP_CONTROLLERS: case SERVICE_SWAP_CONTROLLERS:
defineButtons->swapControllers(); swapControllers();
screen->showNotification("Swap Controllers");
resetCounter();
break; break;
default: default:
@@ -342,4 +338,30 @@ void Title::reLoadTextures()
void Title::resetCounter() void Title::resetCounter()
{ {
counter = 0; 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();
} }

View File

@@ -97,6 +97,9 @@ private:
// Reinicia el contador interno // Reinicia el contador interno
void resetCounter(); void resetCounter();
// Intercambia la asignación de mandos a los jugadores
void swapControllers();
public: public:
// Constructor // Constructor
Title(Screen *screen, Asset *asset, Input *input, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music); Title(Screen *screen, Asset *asset, Input *input, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music);