From f1d96012f171471ab87f43100e651057a3035991 Mon Sep 17 00:00:00 2001 From: funman300 Date: Thu, 28 May 2026 15:19:24 -0700 Subject: [PATCH] fix(engine): add modal scrim guard to toggle_stats_screen (#75) Pressing S (or the Stats HUD button) while another modal was open (Settings, Profile, Leaderboard, etc.) would spawn a second ModalScrim on top of the existing one, violating the one-scrim-at-a-time invariant. Add other_modal_scrims: Query<(), (With, Without)> matching the guard pattern used by every other modal-spawning system. Also import ModalScrim which was previously not imported in this file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- solitaire_engine/src/stats_plugin.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/solitaire_engine/src/stats_plugin.rs b/solitaire_engine/src/stats_plugin.rs index 45ecf0f..60607fd 100644 --- a/solitaire_engine/src/stats_plugin.rs +++ b/solitaire_engine/src/stats_plugin.rs @@ -29,7 +29,7 @@ use crate::progress_plugin::ProgressResource; use crate::resources::GameStateResource; use crate::time_attack_plugin::TimeAttackResource; use crate::ui_modal::{ - ButtonVariant, ModalButton, ScrimDismissible, spawn_modal, spawn_modal_actions, + ButtonVariant, ModalButton, ModalScrim, ScrimDismissible, spawn_modal, spawn_modal_actions, spawn_modal_button, spawn_modal_header, }; use crate::ui_theme::{ @@ -649,6 +649,7 @@ fn toggle_stats_screen( latest_replay: Res, selected_index: Res, screens: Query>, + other_modal_scrims: Query<(), (With, Without)>, ) { let button_clicked = requests.read().count() > 0; if !keys.just_pressed(KeyCode::KeyS) && !button_clicked { @@ -657,6 +658,9 @@ fn toggle_stats_screen( if let Ok(entity) = screens.single() { commands.entity(entity).despawn(); } else { + if !other_modal_scrims.is_empty() { + return; + } spawn_stats_screen( &mut commands, &stats.0,