fix(engine): snap cards directly on window resize
on_window_resized was firing StateChangedEvent on every WindowResized event. That ran sync_cards_on_change → update_card_entity, which inserts a CardAnim slide tween for every card whose target moves >1 unit. During a corner drag the resize fires every frame, retargeting the slide each time from the cards' current mid-tween positions, so cards never reach steady state — the visible "snap back and forth" jitter reported during the 2026-04-29 smoke test. Replace the StateChangedEvent emit with a direct snap path: - Add LayoutSystem::UpdateOnResize SystemSet in layout.rs so cross- plugin ordering is explicit (Bevy's automatic conflict-based order only forces non-parallel execution, not a particular order). - table_plugin::on_window_resized: drop the StateChangedEvent emit; mark the system in_set(LayoutSystem::UpdateOnResize). It already snaps backgrounds and pile markers directly, so this aligns cards with the same instant-snap policy. - card_plugin: new snap_cards_on_window_resize system listens for WindowResized, runs .after(LayoutSystem::UpdateOnResize), writes fresh transforms via the existing card_positions() helper, and removes any in-flight CardAnim. It also reapplies the stock-empty indicator so the "↺" label's font_size (derived from layout.card_size.x) still rescales on resize. Other StateChangedEvent listeners — start_settle_anim, detect_auto_complete, clear_selection_on_state_change, check_no_moves, reset_hint_cycle_on_state_change, clear_right_click_highlights — no longer fire spuriously on resize. They should not fire on a layout change anyway; that was a pre-existing minor bug masked by the jitter. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,10 +6,22 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use bevy::math::Vec2;
|
||||
use bevy::prelude::Resource;
|
||||
use bevy::prelude::{Resource, SystemSet};
|
||||
use solitaire_core::card::Suit;
|
||||
use solitaire_core::pile::PileType;
|
||||
|
||||
/// Schedule labels for layout-related systems so cross-plugin ordering is
|
||||
/// explicit instead of relying on Bevy's automatic resource-conflict ordering
|
||||
/// (which only forces non-parallel execution, not a particular order).
|
||||
#[derive(SystemSet, Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum LayoutSystem {
|
||||
/// The system that updates [`LayoutResource`], the table background, and
|
||||
/// pile markers in response to a `WindowResized` event. Card-snap systems
|
||||
/// (in `card_plugin`) run `.after(LayoutSystem::UpdateOnResize)` so they
|
||||
/// see the fresh layout.
|
||||
UpdateOnResize,
|
||||
}
|
||||
|
||||
/// Minimum supported window dimensions. Layout is still computed below this
|
||||
/// size but cards will be small.
|
||||
pub const MIN_WINDOW: Vec2 = Vec2::new(800.0, 600.0);
|
||||
|
||||
Reference in New Issue
Block a user