Skip to content

Commit

Permalink
fix bug for repeat spawn dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
foxzool committed Dec 27, 2024
1 parent a29c1d5 commit 2216a7d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/game/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ fn fade_out_animation(
}
}

#[derive(Default)]
pub struct Opened(bool);

#[derive(Component)]
pub struct HintContainer;

Expand All @@ -435,15 +438,19 @@ fn on_hint(
font_assets: Res<FontAssets>,
texture_assets: Res<TextureAssets>,
q_hint: Query<Entity, With<HintContainer>>,
mut opened: Local<Opened>,
) {
let (entity, mut visibility) = q_dialog.into_inner();
if trigger.event().0 {
let show_hint = trigger.event().0;
if show_hint && !opened.0 {
opened.0 = true;
time.pause();
*visibility = Visibility::Visible;
commands.entity(entity).with_children(|builder| {
spawn_hint(&font_assets, &texture_assets, builder);
});
} else {
opened.0 = false;
time.unpause();
for hint in q_hint.iter() {
commands
Expand All @@ -468,15 +475,18 @@ fn on_show_settings(
texture_assets: Res<TextureAssets>,
q_setting: Query<Entity, With<SettingContainer>>,
setting: Res<Settings>,
mut opened: Local<Opened>
) {
let (entity, mut visibility) = q_dialog.into_inner();
if trigger.event().0 {
if trigger.event().0 && !opened.0 {
opened.0 = true;
time.pause();
*visibility = Visibility::Visible;
commands.entity(entity).with_children(|builder| {
spawn_settings(&font_assets, &texture_assets, builder, &setting);
});
} else {
opened.0 = false;
time.unpause();
for hint in q_setting.iter() {
commands
Expand Down

0 comments on commit 2216a7d

Please sign in to comment.