feat(notifier): doble pulsació d'ESC per confirmar sortida
La primera ESC ja no tanca el joc directament: dispara un toast "PREMEU ESC UN ALTRE COP PER EIXIR" en vermell. Mentre el toast està entrant o aguantant (Notifier::isActiveWindow()), una segona ESC confirma i tanca. Si l'usuari espera a que el toast comenci a sortir o desaparegui, ESC torna a obrir la finestra de confirmació sense tancar — només una doble pulsació consecutiva tanca. Si el Notifier no existeix (no hauria de passar dins runFrameLoop), ESC manté el comportament antic de tancar directament. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "core/input/input.hpp"
|
||||
#include "core/input/mouse.hpp"
|
||||
#include "core/rendering/sdl_manager.hpp"
|
||||
#include "core/system/notifier.hpp"
|
||||
#include "scene_context.hpp"
|
||||
|
||||
// Using declarations per simplificar el codi
|
||||
@@ -57,10 +58,24 @@ namespace GlobalEvents {
|
||||
sdl.toggleAntialias();
|
||||
return true;
|
||||
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
case SDL_SCANCODE_ESCAPE: {
|
||||
// Doble pulsació per confirmar sortida: la primera ESC
|
||||
// dispara un toast d'avís; mentre el toast està entrant
|
||||
// o aguantant (isActiveWindow), la segona ESC tanca el
|
||||
// joc. Si el toast ha començat a sortir o ja ha
|
||||
// desaparegut, ESC torna a obrir la finestra de
|
||||
// confirmació sense tancar.
|
||||
auto* notifier = System::Notifier::get();
|
||||
if (notifier != nullptr && !notifier->isActiveWindow()) {
|
||||
notifier->notifyExit("PREMEU ESC UN ALTRE COP PER EIXIR");
|
||||
return true;
|
||||
}
|
||||
// Notifier inexistent (degradació elegant) o segona ESC
|
||||
// dins la finestra activa: tanquem el joc.
|
||||
context.setNextScene(SceneType::EXIT);
|
||||
SceneManager::actual = SceneType::EXIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
// Tecla no global
|
||||
|
||||
Reference in New Issue
Block a user