ESC global amb doble pulsació: F12=pausa, BACKSPACE=cancel, text pausa més clar
This commit is contained in:
@@ -17,13 +17,24 @@ namespace GlobalInputs {
|
||||
constexpr int LANG_WINDOW = 98;
|
||||
constexpr int LANG_SHADER = 99;
|
||||
constexpr int LANG_PRESET = 100;
|
||||
constexpr int LANG_EXIT_CONFIRM = 101;
|
||||
|
||||
constexpr Uint32 NOTIFY_MS = 1500;
|
||||
constexpr Uint32 EXIT_CONFIRM_MS = 2000;
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Color CYAN = {0x00, 0xFF, 0xFF};
|
||||
const Color YELLOW = {0xFF, 0xE0, 0x40};
|
||||
const Color MAGENTA = {0xFF, 0x00, 0xFF};
|
||||
const Color GREEN = {0x00, 0xFF, 0x80};
|
||||
const Color RED = {0xFF, 0x40, 0x40};
|
||||
|
||||
// Patró de doble pulsació: la primera pulsació d'EXIT mostra una
|
||||
// notificació en vermell i obre una finestra de confirmació; una
|
||||
// segona pulsació dins la finestra activa `quit_requested`. La
|
||||
// finestra coincideix amb la durada del missatge perquè usuari i
|
||||
// sistema sempre estiguin sincronitzats.
|
||||
Uint32 exit_window_until_ticks = 0;
|
||||
bool quit_requested = false;
|
||||
|
||||
void notifyZoom() {
|
||||
const std::string MSG = Lang::get()->getText(LANG_ZOOM) + " " + std::to_string(Options::window.zoom) + "x";
|
||||
@@ -51,11 +62,25 @@ namespace GlobalInputs {
|
||||
const std::string MSG = Lang::get()->getText(LANG_PRESET) + " " + Screen::get()->getCurrentPresetName();
|
||||
Screen::get()->notify(MSG, GREEN, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void onExit() {
|
||||
const Uint32 NOW = SDL_GetTicks();
|
||||
if (NOW < exit_window_until_ticks) {
|
||||
quit_requested = true;
|
||||
return;
|
||||
}
|
||||
exit_window_until_ticks = NOW + EXIT_CONFIRM_MS;
|
||||
Screen::get()->notify(Lang::get()->getText(LANG_EXIT_CONFIRM), RED, BLACK, EXIT_CONFIRM_MS);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
auto handle() -> bool {
|
||||
if (Screen::get() == nullptr || Input::get() == nullptr) { return false; }
|
||||
|
||||
if (Input::get()->checkInput(Input::Action::EXIT, Input::Repeat::OFF)) {
|
||||
onExit();
|
||||
return true;
|
||||
}
|
||||
if (Input::get()->checkInput(Input::Action::WINDOW_FULLSCREEN, Input::Repeat::OFF)) {
|
||||
Screen::get()->toggleVideoMode();
|
||||
notifyFullscreen();
|
||||
@@ -95,4 +120,8 @@ namespace GlobalInputs {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto wantsQuit() -> bool {
|
||||
return quit_requested;
|
||||
}
|
||||
|
||||
} // namespace GlobalInputs
|
||||
|
||||
Reference in New Issue
Block a user