drain object queues after each object
This commit is contained in:
+19
-1
@@ -36,7 +36,7 @@ use crate::input::{
|
||||
use crate::log::{LogWidget, log_preview_line};
|
||||
use crate::menu::MenuWidget;
|
||||
use crate::mode::{Mode, PendingMode};
|
||||
use crate::scroll_overlay::ScrollOverlayWidget;
|
||||
use crate::scroll_overlay::{ScrollOpenAnimation, ScrollOverlayWidget};
|
||||
use crate::speech::SpeechBubblesWidget;
|
||||
use crate::status::StatusSidebarWidget;
|
||||
use crate::ui::Ui;
|
||||
@@ -142,6 +142,11 @@ fn run(terminal: &mut ratatui::DefaultTerminal, mode: &mut Mode, ui: &mut Ui) ->
|
||||
// only changed cells are actually written to the terminal.
|
||||
terminal.draw(|frame| draw(frame, mode, ui))?;
|
||||
|
||||
// Remember whether a scroll overlay was already open, so we can detect one
|
||||
// that opens this frame — from a player bump during input *or* from a tick —
|
||||
// and play its open animation exactly once (see after the tick below).
|
||||
let scroll_active_before = matches!(mode, Mode::Play(g) if g.active_scroll.is_some());
|
||||
|
||||
// Wait for input only up to the next frame deadline so the loop wakes to
|
||||
// tick even with no keypresses.
|
||||
let timeout = FRAME.saturating_sub(last_tick.elapsed());
|
||||
@@ -194,6 +199,19 @@ fn run(terminal: &mut ratatui::DefaultTerminal, mode: &mut Mode, ui: &mut Ui) ->
|
||||
ui.tick(dt, mode);
|
||||
}
|
||||
|
||||
// A scroll can be opened either by a script tick or by a player bump during
|
||||
// input handling (bump reactions now resolve within try_move). Start its open
|
||||
// animation once, whichever opened it — detected by the scroll appearing since
|
||||
// the top of this frame while no animation is running.
|
||||
if ui.active_animation.is_none()
|
||||
&& !scroll_active_before
|
||||
&& let Mode::Play(game) = &*mode
|
||||
&& let Some(scroll) = &game.active_scroll
|
||||
{
|
||||
let lines = scroll.lines.clone();
|
||||
ui.active_animation = Some(Box::new(ScrollOpenAnimation::new(lines)));
|
||||
}
|
||||
|
||||
// Apply any Play↔Edit switch a menu action requested this frame.
|
||||
apply_pending_mode(mode, ui);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user