diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index ef77c84..8356931 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -1119,49 +1119,38 @@ namespace ZL { } void MenuManager::updateToasts(float deltaMs) { - if (activeToasts_.empty() && toastQueue_.empty()) return; - - bool changed = false; - + // Advance timers and state transitions for (auto& e : activeToasts_) { e.timer += deltaMs; - // Advance state machine if (e.state == ToastEntry::State::FadeIn && e.timer >= TOAST_FADE_MS) { e.state = ToastEntry::State::Visible; e.timer = 0.0f; - changed = true; } else if (e.state == ToastEntry::State::Visible && e.timer >= TOAST_VISIBLE_MS) { e.state = ToastEntry::State::FadeOut; e.timer = 0.0f; - changed = true; - } else if (e.state == ToastEntry::State::FadeOut && e.timer >= TOAST_FADE_MS) { - changed = true; } } - // Remove finished entries (FadeOut complete) - auto removed = std::remove_if(activeToasts_.begin(), activeToasts_.end(), - [](const ToastEntry& e) { - return e.state == ToastEntry::State::FadeOut && e.timer >= TOAST_FADE_MS; - }); - if (removed != activeToasts_.end()) { - activeToasts_.erase(removed, activeToasts_.end()); - changed = true; - } + // Remove completed fade-outs + activeToasts_.erase( + std::remove_if(activeToasts_.begin(), activeToasts_.end(), + [](const ToastEntry& e) { + return e.state == ToastEntry::State::FadeOut && e.timer >= TOAST_FADE_MS; + }), + activeToasts_.end()); - // Pull queued messages into now-free slots (with FadeIn) + // Promote queued messages into free slots while (!toastQueue_.empty() && activeToasts_.size() < 3) { ToastEntry e; e.iconPath = toastQueue_.front().iconPath; e.text = toastQueue_.front().text; toastQueue_.pop_front(); activeToasts_.push_back(std::move(e)); - changed = true; } - if (changed) applyToastsToUi(); - // Also refresh alpha smoothly every frame while any slot is fading - else if (!activeToasts_.empty()) applyToastsToUi(); + // Always sync UI — even with no active toasts, this hides stale widgets + // that couldn't be hidden while a pushed menu (inventory/journal/phone) was active. + applyToastsToUi(); } void MenuManager::applyToastsToUi() {