From 75f9d3f5cbff9825e2b3822177d6375a4ff17cbb Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 15 Sep 2024 18:14:51 +0200 Subject: [PATCH] Cambios en swapControllers --- source/title.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/source/title.cpp b/source/title.cpp index fb838ad..3928e9e 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -365,17 +365,27 @@ void Title::swapControllers() } 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) + // Crea cadenas de texto vacias para un numero máximo de mandos + const int MAX_CONTROLLERS = 2; + std::string text[MAX_CONTROLLERS]; + for (int i = 0; i < MAX_CONTROLLERS; ++i) + text[i] = ""; + + // Obtiene para cada jugador el índice del mando correspondiente + int playerControllerIndex[numControllers]; + for (int i = 0; i < numControllers; ++i) { - screen->showNotification(text0); + playerControllerIndex[options->controller[i].playerId - 1] = i; } - else + + // Genera el texto correspondiente + for (int i = 0; i < numControllers; ++i) { - screen->showNotification(text0, text1); + text[i] = "Jugador " + std::to_string(i + 1) + ": " + options->controller[playerControllerIndex[i]].name; } + screen->showNotification(text[0], text[1]); + resetCounter(); } \ No newline at end of file