From a035fecb041e6b45945b644cade04f5b51c91df4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 13 Apr 2026 17:57:54 +0200 Subject: [PATCH] emscripten: fix reset quan fas exit. Eliminades les opcions d'eixida --- source/director.cpp | 2 +- source/game.cpp | 2 +- source/input.cpp | 3 ++- source/instructions.cpp | 9 ++++++--- source/intro.cpp | 9 ++++++--- source/logo.cpp | 9 ++++++--- source/title.cpp | 8 ++++++++ 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 7f54ac5..ad752a2 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -150,8 +150,8 @@ void Director::initInput() { input->bindGameControllerButton(input_fire_right, SDL_GAMEPAD_BUTTON_EAST); // Mando - Otros + // SOUTH queda sin asignar para evitar salidas accidentales: pausa/cancel se hace con START/BACK. input->bindGameControllerButton(input_accept, SDL_GAMEPAD_BUTTON_EAST); - input->bindGameControllerButton(input_cancel, SDL_GAMEPAD_BUTTON_SOUTH); #ifdef GAME_CONSOLE input->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_BACK); input->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_START); diff --git a/source/game.cpp b/source/game.cpp index 66041c8..c11dc6d 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -2825,7 +2825,7 @@ void Game::checkGameInput() { } // Comprueba el input de pausa - if (input->checkInput(input_cancel, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id)) { + if (input->checkInput(input_pause, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id)) { section->subsection = SUBSECTION_GAME_PAUSE; } diff --git a/source/input.cpp b/source/input.cpp index 8fc84c3..327cf46 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -157,12 +157,13 @@ bool Input::checkAnyInput(int device, int index) { // Construye el nombre visible de un mando std::string Input::buildControllerName(SDL_Gamepad *pad, int padIndex) { + (void)padIndex; const char *padName = SDL_GetGamepadName(pad); std::string name = padName ? padName : "Unknown"; if (name.size() > 25) { name.resize(25); } - return name + " #" + std::to_string(padIndex); + return name; } // Busca si hay un mando conectado. Cierra y limpia el estado previo para diff --git a/source/instructions.cpp b/source/instructions.cpp index f2a2a01..89da39e 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -208,6 +208,7 @@ void Instructions::render() { // Comprueba los eventos void Instructions::checkEvents() { +#ifndef __EMSCRIPTEN__ // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) { // Evento de salida de la aplicación @@ -217,16 +218,18 @@ void Instructions::checkEvents() { break; } } +#endif } // Comprueba las entradas void Instructions::checkInput() { +#ifndef __EMSCRIPTEN__ if (input->checkInput(input_exit, REPEAT_FALSE)) { quitRequested = true; finished = true; - } - - else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { + } else +#endif + if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } diff --git a/source/intro.cpp b/source/intro.cpp index a432b4b..8c7d15a 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -185,6 +185,7 @@ bool Intro::loadMedia() { // Comprueba los eventos void Intro::checkEvents() { +#ifndef __EMSCRIPTEN__ // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) { // Evento de salida de la aplicación @@ -193,15 +194,17 @@ void Intro::checkEvents() { break; } } +#endif } // Comprueba las entradas void Intro::checkInput() { +#ifndef __EMSCRIPTEN__ if (input->checkInput(input_exit, REPEAT_FALSE)) { section->name = SECTION_PROG_QUIT; - } - - else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { + } else +#endif + if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } diff --git a/source/logo.cpp b/source/logo.cpp index f31124b..c49ce32 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -61,6 +61,7 @@ void Logo::checkLogoEnd() { // Comprueba los eventos void Logo::checkEvents() { +#ifndef __EMSCRIPTEN__ // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) { // Evento de salida de la aplicación @@ -69,15 +70,17 @@ void Logo::checkEvents() { break; } } +#endif } // Comprueba las entradas void Logo::checkInput() { +#ifndef __EMSCRIPTEN__ if (input->checkInput(input_exit, REPEAT_FALSE)) { section->name = SECTION_PROG_QUIT; - } - - else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { + } else +#endif + if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { screen->switchVideoMode(); } diff --git a/source/title.cpp b/source/title.cpp index 827b5e2..55ff816 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -59,6 +59,12 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, #endif menu.playerSelect = new Menu(renderer, asset, input, asset->get("player_select.men")); +#ifdef __EMSCRIPTEN__ + // En la versión web no se puede cerrar el programa: ocultamos la opción QUIT del menú de título + menu.title->setVisible(3, false); + menu.title->setSelectable(3, false); +#endif + // Sonidos crashSound = JA_LoadSound(asset->get("title.wav").c_str()); @@ -314,8 +320,10 @@ void Title::update() { break; case 2: // QUIT +#ifndef __EMSCRIPTEN__ section->name = SECTION_PROG_QUIT; JA_StopMusic(); +#endif break; case 3: // TIME OUT