Afegida confirmació per eixir del joc

This commit is contained in:
2024-09-25 09:19:12 +02:00
parent 2f152915ed
commit 6ad1bca29f
14 changed files with 156 additions and 16 deletions

View File

@@ -504,4 +504,10 @@ void Screen::displayInfo()
// Resolution
dbg_print(0, 0, infoResolution.c_str(), 255, 255, 0);
}
}
// Indica si hay alguna notificación activa en pantalla
bool Screen::notificationsAreActive()
{
return notify->active();
}

View File

@@ -134,6 +134,9 @@ public:
// Muestra una notificación de texto por pantalla;
void showNotification(std::string text1 = "", std::string text2 = "", int icon = -1);
// Indica si hay alguna notificación activa en pantalla
bool notificationsAreActive();
// Obtiene el puntero al renderizador
SDL_Renderer *getRenderer();
};

View File

@@ -2040,13 +2040,19 @@ void Game::checkInput()
// 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;
quit(SECTION_OPTIONS_QUIT_NORMAL);
return;
}
for (int i = 0; i < input->getNumControllers(); ++i)
{
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
return;
}
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
@@ -2809,4 +2815,18 @@ int Game::getController(int playerId)
}
return -1;
}
// Termina
void Game::quit(int code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
}
else
{
screen->showNotification("Torna a polsar per eixir");
}
}

View File

@@ -446,6 +446,9 @@ private:
// Obtiene un controlador a partir del "id" del jugador
int getController(int playerId);
// Termina
void quit(int code);
public:
// Constructor
Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music);

View File

@@ -197,8 +197,7 @@ void HiScoreTable::checkInput()
// 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;
quit(SECTION_OPTIONS_QUIT_NORMAL);
return;
}
@@ -213,6 +212,13 @@ void HiScoreTable::checkInput()
for (int i = 0; i < input->getNumControllers(); ++i)
{
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
return;
}
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
@@ -329,4 +335,18 @@ std::string HiScoreTable::format(int number)
}
return result;
}
// Termina
void HiScoreTable::quit(int code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
}
else
{
screen->showNotification("Torna a polsar per eixir");
}
}

View File

@@ -78,6 +78,9 @@ private:
// Gestiona el fade
void updateFade();
// Termina
void quit(int code);
public:
// Constructor
HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music);

View File

@@ -327,8 +327,7 @@ void Instructions::checkInput()
// 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;
quit(SECTION_OPTIONS_QUIT_NORMAL);
return;
}
@@ -343,6 +342,13 @@ void Instructions::checkInput()
for (int i = 0; i < input->getNumControllers(); ++i)
{
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
return;
}
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
@@ -377,3 +383,17 @@ void Instructions::run()
render();
}
}
// Termina
void Instructions::quit(int code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
}
else
{
screen->showNotification("Torna a polsar per eixir");
}
}

View File

@@ -85,6 +85,9 @@ private:
// Recarga todas las texturas
void reloadTextures();
// Termina
void quit(int code);
public:
// Constructor
Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music);

View File

@@ -196,8 +196,7 @@ void Intro::checkInput()
// 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;
quit(SECTION_OPTIONS_QUIT_NORMAL);
return;
}
@@ -209,9 +208,16 @@ void Intro::checkInput()
section->options = SECTION_OPTIONS_TITLE_1;
return;
}
for (int i = 0; i < input->getNumControllers(); ++i)
{
{
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
return;
}
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
@@ -455,3 +461,17 @@ void Intro::run()
render();
}
}
// Termina
void Intro::quit(int code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
}
else
{
screen->showNotification("Torna a polsar per eixir");
}
}

View File

@@ -59,6 +59,9 @@ private:
// Recarga todas las texturas
void reloadTextures();
// Termina
void quit(int code);
public:
// Constructor
Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music);

View File

@@ -107,8 +107,7 @@ void Logo::checkInput()
// 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;
quit(SECTION_OPTIONS_QUIT_NORMAL);
return;
}
@@ -126,8 +125,7 @@ void Logo::checkInput()
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
section->name = SECTION_PROG_QUIT;
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN;
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
return;
}
@@ -335,4 +333,18 @@ void Logo::run()
checkEvents(); // Tiene que ir antes del render
render();
}
}
// Termina
void Logo::quit(int code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
}
else
{
screen->showNotification("Torna a polsar per eixir");
}
}

View File

@@ -68,6 +68,9 @@ private:
// Recarga todas las texturas
void reloadTextures();
// Termina
void quit(int code);
public:
// Constructor
Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section);

View File

@@ -252,8 +252,7 @@ void Title::checkInput()
// 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;
quit(SECTION_OPTIONS_QUIT_NORMAL);
return;
}
@@ -273,6 +272,14 @@ void Title::checkInput()
for (int i = 0; i < input->getNumControllers(); ++i)
{
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
return;
}
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
@@ -389,4 +396,18 @@ void Title::swapControllers()
screen->showNotification(text[0], text[1]);
resetCounter();
}
// Termina
void Title::quit(int code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
}
else
{
screen->showNotification("Torna a polsar per eixir");
}
}

View File

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