emscripten: fix reset quan fas exit. Eliminades les opcions d'eixida

This commit is contained in:
2026-04-13 17:57:54 +02:00
parent 9d70138855
commit a035fecb04
7 changed files with 30 additions and 12 deletions

View File

@@ -150,8 +150,8 @@ void Director::initInput() {
input->bindGameControllerButton(input_fire_right, SDL_GAMEPAD_BUTTON_EAST); input->bindGameControllerButton(input_fire_right, SDL_GAMEPAD_BUTTON_EAST);
// Mando - Otros // 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_accept, SDL_GAMEPAD_BUTTON_EAST);
input->bindGameControllerButton(input_cancel, SDL_GAMEPAD_BUTTON_SOUTH);
#ifdef GAME_CONSOLE #ifdef GAME_CONSOLE
input->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_BACK); input->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_BACK);
input->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_START); input->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_START);

View File

@@ -2825,7 +2825,7 @@ void Game::checkGameInput() {
} }
// Comprueba el input de pausa // 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; section->subsection = SUBSECTION_GAME_PAUSE;
} }

View File

@@ -157,12 +157,13 @@ bool Input::checkAnyInput(int device, int index) {
// Construye el nombre visible de un mando // Construye el nombre visible de un mando
std::string Input::buildControllerName(SDL_Gamepad *pad, int padIndex) { std::string Input::buildControllerName(SDL_Gamepad *pad, int padIndex) {
(void)padIndex;
const char *padName = SDL_GetGamepadName(pad); const char *padName = SDL_GetGamepadName(pad);
std::string name = padName ? padName : "Unknown"; std::string name = padName ? padName : "Unknown";
if (name.size() > 25) { if (name.size() > 25) {
name.resize(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 // Busca si hay un mando conectado. Cierra y limpia el estado previo para

View File

@@ -208,6 +208,7 @@ void Instructions::render() {
// Comprueba los eventos // Comprueba los eventos
void Instructions::checkEvents() { void Instructions::checkEvents() {
#ifndef __EMSCRIPTEN__
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) { while (SDL_PollEvent(eventHandler) != 0) {
// Evento de salida de la aplicación // Evento de salida de la aplicación
@@ -217,16 +218,18 @@ void Instructions::checkEvents() {
break; break;
} }
} }
#endif
} }
// Comprueba las entradas // Comprueba las entradas
void Instructions::checkInput() { void Instructions::checkInput() {
#ifndef __EMSCRIPTEN__
if (input->checkInput(input_exit, REPEAT_FALSE)) { if (input->checkInput(input_exit, REPEAT_FALSE)) {
quitRequested = true; quitRequested = true;
finished = true; finished = true;
} } else
#endif
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) {
screen->switchVideoMode(); screen->switchVideoMode();
} }

View File

@@ -185,6 +185,7 @@ bool Intro::loadMedia() {
// Comprueba los eventos // Comprueba los eventos
void Intro::checkEvents() { void Intro::checkEvents() {
#ifndef __EMSCRIPTEN__
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) { while (SDL_PollEvent(eventHandler) != 0) {
// Evento de salida de la aplicación // Evento de salida de la aplicación
@@ -193,15 +194,17 @@ void Intro::checkEvents() {
break; break;
} }
} }
#endif
} }
// Comprueba las entradas // Comprueba las entradas
void Intro::checkInput() { void Intro::checkInput() {
#ifndef __EMSCRIPTEN__
if (input->checkInput(input_exit, REPEAT_FALSE)) { if (input->checkInput(input_exit, REPEAT_FALSE)) {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} } else
#endif
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) {
screen->switchVideoMode(); screen->switchVideoMode();
} }

View File

@@ -61,6 +61,7 @@ void Logo::checkLogoEnd() {
// Comprueba los eventos // Comprueba los eventos
void Logo::checkEvents() { void Logo::checkEvents() {
#ifndef __EMSCRIPTEN__
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0) { while (SDL_PollEvent(eventHandler) != 0) {
// Evento de salida de la aplicación // Evento de salida de la aplicación
@@ -69,15 +70,17 @@ void Logo::checkEvents() {
break; break;
} }
} }
#endif
} }
// Comprueba las entradas // Comprueba las entradas
void Logo::checkInput() { void Logo::checkInput() {
#ifndef __EMSCRIPTEN__
if (input->checkInput(input_exit, REPEAT_FALSE)) { if (input->checkInput(input_exit, REPEAT_FALSE)) {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
} } else
#endif
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) { if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) {
screen->switchVideoMode(); screen->switchVideoMode();
} }

View File

@@ -59,6 +59,12 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
#endif #endif
menu.playerSelect = new Menu(renderer, asset, input, asset->get("player_select.men")); 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 // Sonidos
crashSound = JA_LoadSound(asset->get("title.wav").c_str()); crashSound = JA_LoadSound(asset->get("title.wav").c_str());
@@ -314,8 +320,10 @@ void Title::update() {
break; break;
case 2: // QUIT case 2: // QUIT
#ifndef __EMSCRIPTEN__
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
JA_StopMusic(); JA_StopMusic();
#endif
break; break;
case 3: // TIME OUT case 3: // TIME OUT