fixing minor bug
This commit is contained in:
parent
619de45221
commit
dcdeae75bc
@ -1119,49 +1119,38 @@ namespace ZL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuManager::updateToasts(float deltaMs) {
|
void MenuManager::updateToasts(float deltaMs) {
|
||||||
if (activeToasts_.empty() && toastQueue_.empty()) return;
|
// Advance timers and state transitions
|
||||||
|
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
for (auto& e : activeToasts_) {
|
for (auto& e : activeToasts_) {
|
||||||
e.timer += deltaMs;
|
e.timer += deltaMs;
|
||||||
// Advance state machine
|
|
||||||
if (e.state == ToastEntry::State::FadeIn && e.timer >= TOAST_FADE_MS) {
|
if (e.state == ToastEntry::State::FadeIn && e.timer >= TOAST_FADE_MS) {
|
||||||
e.state = ToastEntry::State::Visible;
|
e.state = ToastEntry::State::Visible;
|
||||||
e.timer = 0.0f;
|
e.timer = 0.0f;
|
||||||
changed = true;
|
|
||||||
} else if (e.state == ToastEntry::State::Visible && e.timer >= TOAST_VISIBLE_MS) {
|
} else if (e.state == ToastEntry::State::Visible && e.timer >= TOAST_VISIBLE_MS) {
|
||||||
e.state = ToastEntry::State::FadeOut;
|
e.state = ToastEntry::State::FadeOut;
|
||||||
e.timer = 0.0f;
|
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)
|
// Remove completed fade-outs
|
||||||
auto removed = std::remove_if(activeToasts_.begin(), activeToasts_.end(),
|
activeToasts_.erase(
|
||||||
[](const ToastEntry& e) {
|
std::remove_if(activeToasts_.begin(), activeToasts_.end(),
|
||||||
return e.state == ToastEntry::State::FadeOut && e.timer >= TOAST_FADE_MS;
|
[](const ToastEntry& e) {
|
||||||
});
|
return e.state == ToastEntry::State::FadeOut && e.timer >= TOAST_FADE_MS;
|
||||||
if (removed != activeToasts_.end()) {
|
}),
|
||||||
activeToasts_.erase(removed, activeToasts_.end());
|
activeToasts_.end());
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pull queued messages into now-free slots (with FadeIn)
|
// Promote queued messages into free slots
|
||||||
while (!toastQueue_.empty() && activeToasts_.size() < 3) {
|
while (!toastQueue_.empty() && activeToasts_.size() < 3) {
|
||||||
ToastEntry e;
|
ToastEntry e;
|
||||||
e.iconPath = toastQueue_.front().iconPath;
|
e.iconPath = toastQueue_.front().iconPath;
|
||||||
e.text = toastQueue_.front().text;
|
e.text = toastQueue_.front().text;
|
||||||
toastQueue_.pop_front();
|
toastQueue_.pop_front();
|
||||||
activeToasts_.push_back(std::move(e));
|
activeToasts_.push_back(std::move(e));
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) applyToastsToUi();
|
// Always sync UI — even with no active toasts, this hides stale widgets
|
||||||
// Also refresh alpha smoothly every frame while any slot is fading
|
// that couldn't be hidden while a pushed menu (inventory/journal/phone) was active.
|
||||||
else if (!activeToasts_.empty()) applyToastsToUi();
|
applyToastsToUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuManager::applyToastsToUi() {
|
void MenuManager::applyToastsToUi() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user