why you no iter_many_mut().for_each()???

main
Elijah C. Voigt 2 years ago
parent c04f72dccd
commit d3c2289d41

@ -83,19 +83,16 @@ fn init_credits_ui(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "B a c k".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 12.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -103,8 +100,7 @@ fn init_credits_ui(
..default()
},
..default()
}
);
});
});
});
}

@ -680,19 +680,16 @@ fn set_endgame(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "N e w G a m e".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 16.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -700,8 +697,7 @@ fn set_endgame(
..default()
},
..default()
}
);
});
});
// Quit button
@ -723,19 +719,16 @@ fn set_endgame(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "Q u i t".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 16.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -743,8 +736,7 @@ fn set_endgame(
..default()
},
..default()
}
);
});
});
});
});

@ -100,19 +100,16 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "C o n t i n u e".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 16.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -120,8 +117,7 @@ fn init_play_menu(
..default()
},
..default()
}
);
});
});
// Tutorial button
@ -143,19 +139,16 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "T u t o r i a l".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 16.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -163,8 +156,7 @@ fn init_play_menu(
..default()
},
..default()
}
);
});
});
// Credits button
@ -186,19 +178,16 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "C r e d i t s".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 16.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -206,8 +195,7 @@ fn init_play_menu(
..default()
},
..default()
}
);
});
});
// Quit button
@ -229,19 +217,16 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "Q u i t".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 16.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -249,8 +234,7 @@ fn init_play_menu(
..default()
},
..default()
}
);
});
});
});
}

@ -245,19 +245,16 @@ fn initialize_tutorial(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "R e s t a r t".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 8.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -265,8 +262,7 @@ fn initialize_tutorial(
..default()
},
..default()
}
);
});
});
parent
@ -288,19 +284,16 @@ fn initialize_tutorial(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
parent.spawn(TextBundle {
text: Text {
sections: vec![
TextSection {
sections: vec![TextSection {
value: "C o n t i n u e".into(),
style: TextStyle {
color: Color::WHITE,
font_size: 12.0,
font: font_handle.clone(),
},
}
],
}],
..default()
},
style: Style {
@ -308,8 +301,7 @@ fn initialize_tutorial(
..default()
},
..default()
}
);
});
});
});
}

@ -69,8 +69,10 @@ fn manage_cursor(
}
fn interactive_button(
mut events: Query<(&mut UiImage, &Interaction), (With<Button>, Changed<Interaction>)>,
mut events: Query<(Entity, &mut UiImage, &Interaction), (With<Button>, Changed<Interaction>)>,
mut writer: EventWriter<audio::AudioEvent>,
mut children: Query<&Children>,
mut texts: Query<(&mut Text, &mut Style)>,
tweaks_file: Res<tweak::GameTweaks>,
tweaks: Res<Assets<tweak::Tweaks>>,
) {
@ -82,23 +84,38 @@ fn interactive_button(
events
.iter_mut()
.for_each(|(mut ui_image, interaction)| match interaction {
.for_each(|(entity, mut ui_image, interaction)| match interaction {
Interaction::None => {
ui_image.texture = resting_handle.clone();
texts
.iter_many_mut(children.iter_descendants(entity))
.for_each(|(mut t, mut s)| {
s.right = Val::Auto;
info!("TODO: Change text color");
info!("TODO: Change position");
});
}
Interaction::Hovered => {
ui_image.texture = depressed_handle.clone();
writer.send(audio::AudioEvent::MenuHover);
texts
.iter_many_mut(children.iter_descendants(entity))
.for_each(|(mut t, mut s)| {
s.right = Val::Px(0.0);
info!("TODO: Change text color");
info!("TODO: Change position");
});
}
Interaction::Pressed => {
ui_image.texture = depressed_handle.clone();
writer.send(audio::AudioEvent::MenuSelect);
texts
.iter_many_mut(children.iter_descendants(entity))
.for_each(|(mut t, mut s)| {
s.right = Val::Px(0.0);
info!("TODO: Change text color");
info!("TODO: Change position");
});
}
});
}

Loading…
Cancel
Save