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

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

@ -83,28 +83,24 @@ fn init_credits_ui(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
});
}

@ -680,28 +680,24 @@ fn set_endgame(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
// Quit button
@ -723,28 +719,24 @@ fn set_endgame(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
});
});

@ -100,28 +100,24 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
// Tutorial button
@ -143,28 +139,24 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
// Credits button
@ -186,28 +178,24 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
// Quit button
@ -229,28 +217,24 @@ fn init_play_menu(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
});
}

@ -245,28 +245,24 @@ fn initialize_tutorial(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
});
});
parent
@ -288,28 +284,24 @@ fn initialize_tutorial(
},
))
.with_children(|parent| {
parent.spawn(
TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..default()
},
parent.spawn(TextBundle {
text: Text {
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 {
margin: UiRect::all(Val::Px(20.0)),
..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();
info!("TODO: Change text color");
info!("TODO: Change position");
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);
info!("TODO: Change text color");
info!("TODO: Change position");
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);
info!("TODO: Change text color");
info!("TODO: Change position");
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