From fd3da8cb99b275bf9e525f79abcd292b84713ca0 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 14 May 2026 09:02:03 +0200 Subject: [PATCH] =?UTF-8?q?feat(menu):=20F-keys=20passen=20a=20GlobalInput?= =?UTF-8?q?s=20amb=20men=C3=BA=20obert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/core/system/director.cpp | 8 +++++--- source/game/ui/service_menu.cpp | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index b89fe58..1ef6dc2 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -446,9 +446,11 @@ void Director::processGamepadEvents() { } void Director::processMenuInput() { - // Intercepta input abans que l'escena vegi els events. Si el menú està - // obert, consumeix TOTS els KEY_DOWN perquè ni GlobalInputs (F1–F8, - // F11, F12) ni el jugador els veuen. F9 obre el menú quan està tancat. + // Intercepta input abans que l'escena vegi els events. Amb el menú + // obert, `handleEvent` consumeix tot KEY_DOWN excepte les F-keys + // (F1–F12), que són hotkeys d'UI omnipresents i passen avall a + // GlobalInputs. Quan el menú està tancat, la branca de baix detecta + // `menu_toggle` (F12 per defecte) i obre el menú. // Erase invalida iteradors, per això actualitzem `it` a cada branca. for (auto it = EventBuffer::events.begin(); it != EventBuffer::events.end();) { if (ServiceMenu::get().isOpen() && ServiceMenu::get().handleEvent(*it)) { diff --git a/source/game/ui/service_menu.cpp b/source/game/ui/service_menu.cpp index 80d9376..dfcc4be 100644 --- a/source/game/ui/service_menu.cpp +++ b/source/game/ui/service_menu.cpp @@ -677,9 +677,14 @@ auto ServiceMenu::handleEvent(const SDL_Event& ev) -> bool { default: break; } - // Mentre el menú està obert consumim TOTS els KEY_DOWN perquè les - // hotkeys globals (F1–F8, F11, F12) no s'activen per sota. - return true; + // Context d'entrada exclusiu: amb el menú obert, el teclat va al menú + // i les escenes no veuen res. Les F-keys (F1–F12) són hotkeys d'UI + // omnipresents (zoom, shader, screenshot, render info, menu_toggle…) + // i passen avall a GlobalInputs. Tota la resta queda absorbida — + // inclús tecles que el menú no fa servir — perquè una J en LogoScene + // no salti la secció mentre l'usuari està al menú. + const bool IS_FUNCTION_KEY = SC >= SDL_SCANCODE_F1 && SC <= SDL_SCANCODE_F12; + return !IS_FUNCTION_KEY; } // --- Builders de pàgines ---