- unitat mouse per amagar el punter
- overlay captura el esc i confirma la eixida (falla en game)
This commit is contained in:
@@ -50,6 +50,9 @@ namespace Overlay {
|
||||
// --- Render info ---
|
||||
static std::string render_info_text_;
|
||||
|
||||
// --- Doble ESC per a eixir ---
|
||||
static bool esc_waiting_ = false;
|
||||
|
||||
void init() {
|
||||
font_ = std::make_unique<Text>("fonts/8bithud.fnt", "fonts/8bithud.gif");
|
||||
last_ticks_ = SDL_GetTicks();
|
||||
@@ -141,6 +144,11 @@ namespace Overlay {
|
||||
notifications_.erase(
|
||||
std::remove_if(notifications_.begin(), notifications_.end(), [](const Notification& n) { return n.status == Status::FINISHED; }),
|
||||
notifications_.end());
|
||||
|
||||
// Si la notificació d'ESC ha desaparegut, reseteja l'estat
|
||||
if (esc_waiting_ && notifications_.empty()) {
|
||||
esc_waiting_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void showNotification(const char* text, float duration_seconds) {
|
||||
@@ -175,4 +183,16 @@ namespace Overlay {
|
||||
render_info_text_ = text;
|
||||
}
|
||||
|
||||
auto handleEscape() -> bool {
|
||||
if (!esc_waiting_) {
|
||||
// Primera pulsació: mostra avís i consumeix
|
||||
esc_waiting_ = true;
|
||||
showNotification("TORNA A PULSAR ESC PER EIXIR", 2.0F);
|
||||
return true; // Consumit
|
||||
}
|
||||
// Segona pulsació: deixa passar
|
||||
esc_waiting_ = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Overlay
|
||||
|
||||
@@ -15,4 +15,8 @@ namespace Overlay {
|
||||
// Activa/desactiva la info de renderitzat (FPS, driver, shader, preset)
|
||||
void toggleRenderInfo();
|
||||
void setRenderInfoText(const char* text);
|
||||
|
||||
// Gestió d'eixida amb doble ESC
|
||||
// Retorna true si l'ESC ha sigut consumit (no s'ha de passar al joc)
|
||||
auto handleEscape() -> bool;
|
||||
} // namespace Overlay
|
||||
|
||||
Reference in New Issue
Block a user