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

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

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

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

@ -69,8 +69,10 @@ fn manage_cursor(
} }
fn interactive_button( 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 writer: EventWriter<audio::AudioEvent>,
mut children: Query<&Children>,
mut texts: Query<(&mut Text, &mut Style)>,
tweaks_file: Res<tweak::GameTweaks>, tweaks_file: Res<tweak::GameTweaks>,
tweaks: Res<Assets<tweak::Tweaks>>, tweaks: Res<Assets<tweak::Tweaks>>,
) { ) {
@ -82,23 +84,38 @@ fn interactive_button(
events events
.iter_mut() .iter_mut()
.for_each(|(mut ui_image, interaction)| match interaction { .for_each(|(entity, mut ui_image, interaction)| match interaction {
Interaction::None => { Interaction::None => {
ui_image.texture = resting_handle.clone(); 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 text color");
info!("TODO: Change position"); info!("TODO: Change position");
});
} }
Interaction::Hovered => { Interaction::Hovered => {
ui_image.texture = depressed_handle.clone(); ui_image.texture = depressed_handle.clone();
writer.send(audio::AudioEvent::MenuHover); 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 text color");
info!("TODO: Change position"); info!("TODO: Change position");
});
} }
Interaction::Pressed => { Interaction::Pressed => {
ui_image.texture = depressed_handle.clone(); ui_image.texture = depressed_handle.clone();
writer.send(audio::AudioEvent::MenuSelect); 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 text color");
info!("TODO: Change position"); info!("TODO: Change position");
});
} }
}); });
} }

Loading…
Cancel
Save