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);
// 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);

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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