diff --git a/data/locale/ca.yaml b/data/locale/ca.yaml index 0d410f4..21e1767 100644 --- a/data/locale/ca.yaml +++ b/data/locale/ca.yaml @@ -103,11 +103,10 @@ define: press_button: "PREMEU UN BOTO" complete: "CONFIGURACIO COMPLETA" no_gamepad: "CAP MANDO ASSIGNAT AL JUGADOR" - cancel_hint: "ESC PER CANCEL-LAR" action: left: "ESQUERRA" right: "DRETA" - fire: "DISPAR" + fire: "DISPARAR" accelerate: "ACCELERAR" start: "START" menu: "MENU" diff --git a/data/locale/en.yaml b/data/locale/en.yaml index e35509a..111c936 100644 --- a/data/locale/en.yaml +++ b/data/locale/en.yaml @@ -102,7 +102,6 @@ define: press_button: "PRESS A BUTTON" complete: "CONFIGURATION COMPLETE" no_gamepad: "NO GAMEPAD ASSIGNED TO PLAYER" - cancel_hint: "ESC TO CANCEL" action: left: "LEFT" right: "RIGHT" diff --git a/source/core/input/define_inputs.cpp b/source/core/input/define_inputs.cpp index 8f46847..27e8b9e 100644 --- a/source/core/input/define_inputs.cpp +++ b/source/core/input/define_inputs.cpp @@ -252,22 +252,20 @@ namespace System { return true; // Empassem la resta sense fer res } const SDL_Scancode SC = event.key.scancode; - if (SC == SDL_SCANCODE_ESCAPE) { - cancel(); - return true; - } if (isReservedScancode(SC)) { - return true; // Ignorada + // ESC, F1-F12, RETURN, BACKSPACE, TAB es deixen passar al pipeline + // global (ESC obre el prompt d'eixida; F1-F12 hotkeys, etc.). + return false; } captureAndAdvance(scancodeToInt(SC)); return true; } auto DefineInputs::handleGamepadEvent(const SDL_Event& event) -> bool { - // ESC al teclat tambe cancel·la durant rebind del mando. - if (event.type == SDL_EVENT_KEY_DOWN && event.key.scancode == SDL_SCANCODE_ESCAPE) { - cancel(); - return true; + // KEY_DOWN no es per al rebind de mando: deixem que el global el + // gestioni (ex. ESC → prompt d'eixida, F12 → tanca menu, etc.). + if (event.type == SDL_EVENT_KEY_DOWN) { + return false; } // Filtrar events al pad del jugador actiu. @@ -312,8 +310,15 @@ namespace System { if (phase_ == Phase::INACTIVE) { return false; } + // SDL_EVENT_QUIT i WINDOW_CLOSE_REQUESTED han de poder tancar la + // finestra encara que el modal estiga obert; els passem al pipeline. + if (event.type == SDL_EVENT_QUIT || + event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) { + return false; + } if (phase_ == Phase::COMPLETE) { - // Mentre mostrem el missatge OK, empassem els events sense capturar. + // Mentre mostrem el missatge OK, empassem la resta d'events sense + // capturar perque l'usuari no puga avançar accions sense voler. return true; } if (mode_ == Mode::KEYBOARD) { @@ -390,12 +395,6 @@ namespace System { const float PROG_X = BOX_X + ((BOX_W - PROG_W) * 0.5F); const float PROG_Y = BOX_Y + 200.0F; text_.render(PROGRESS, Vec2{.x = PROG_X, .y = PROG_Y}, PROG_SCALE, TEXT_SPACING, 1.0F, LABEL_COLOR); - - const std::string CANCEL_HINT = Locale::get().text("define.cancel_hint"); - const float CH_W = Graphics::VectorText::getTextWidth(CANCEL_HINT, PROG_SCALE, TEXT_SPACING); - const float CH_X = BOX_X + ((BOX_W - CH_W) * 0.5F); - const float CH_Y = BOX_Y + BOX_H - 30.0F; - text_.render(CANCEL_HINT, Vec2{.x = CH_X, .y = CH_Y}, PROG_SCALE, TEXT_SPACING, 1.0F, SEPARATOR_COLOR); } } // namespace System diff --git a/source/core/system/global_events.cpp b/source/core/system/global_events.cpp index ad4e2df..9fa22bf 100644 --- a/source/core/system/global_events.cpp +++ b/source/core/system/global_events.cpp @@ -51,14 +51,16 @@ namespace GlobalEvents { return false; } - // Si l'overlay de redefinicio esta actiu, engoleix tots els events. + // Engoleix els events que DefineInputs vol consumir mentre l'overlay + // es actiu. Els events que el modul torna a passar (QUIT, ESC) cauen + // cap al pipeline normal i poden tancar la finestra o obrir el prompt + // d'eixida sense haver de completar la sequencia. auto consumeIfDefineActive(const SDL_Event& event) -> bool { auto* di = System::DefineInputs::get(); if (di == nullptr || !di->isActive()) { return false; } - di->handleEvent(event); - return true; + return di->handleEvent(event); } // Botó MENU al mando d'algun jugador → alterna el menú de servei