- unitat mouse per amagar el punter

- overlay captura el esc i confirma la eixida (falla en game)
This commit is contained in:
2026-04-04 22:32:53 +02:00
parent d4fc7c0ee8
commit a4ee304a79
7 changed files with 175 additions and 44 deletions

View File

@@ -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