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<ModalScrim>, Without<StatsScreen>)> 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>
This commit is contained in:
@@ -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<ReplayHistoryResource>,
|
||||
selected_index: Res<SelectedReplayIndex>,
|
||||
screens: Query<Entity, With<StatsScreen>>,
|
||||
other_modal_scrims: Query<(), (With<ModalScrim>, Without<StatsScreen>)>,
|
||||
) {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user