Add "Skip" button to intro and title

This is not the same as a save file that skips automatically, but I
think a fair compromise.
main
Elijah C. Voigt 2 years ago
parent 99edfd596b
commit 665691d000

@ -145,7 +145,7 @@ fn init_play_menu(
parent.spawn(TextBundle { parent.spawn(TextBundle {
text: Text { text: Text {
sections: vec![TextSection { sections: vec![TextSection {
value: "R e s t a r t".into(), value: "New Game".into(),
style: TextStyle { style: TextStyle {
color: Color::WHITE, color: Color::WHITE,
font_size: 12.0, font_size: 12.0,

@ -221,7 +221,7 @@ fn initialize_tutorial(
..default() ..default()
}, },
style: Style { style: Style {
margin: UiRect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(10.0)),
..default() ..default()
}, },
..default() ..default()
@ -304,7 +304,7 @@ fn initialize_tutorial(
parent.spawn(TextBundle { parent.spawn(TextBundle {
text: Text { text: Text {
sections: vec![TextSection { sections: vec![TextSection {
value: "Reset".into(), value: "New Game".into(),
style: TextStyle { style: TextStyle {
color: Color::WHITE, color: Color::WHITE,
font_size: 10.0, font_size: 10.0,
@ -314,7 +314,7 @@ fn initialize_tutorial(
..default() ..default()
}, },
style: Style { style: Style {
margin: UiRect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(10.0)),
..default() ..default()
}, },
..default() ..default()
@ -354,7 +354,7 @@ fn initialize_tutorial(
..default() ..default()
}, },
style: Style { style: Style {
margin: UiRect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(10.0)),
..default() ..default()
}, },
..default() ..default()

@ -8,7 +8,7 @@ impl Plugin for UiPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(Startup, load_assets) app.add_systems(Startup, load_assets)
.init_state::<Prompt>() .init_state::<Prompt>()
.add_systems(Startup, init_prompts) .add_systems(OnExit(GameState::Loading), init_prompts)
.add_systems( .add_systems(
Update, Update,
( (
@ -151,7 +151,15 @@ fn scale_ui(
}); });
} }
fn init_prompts(mut commands: Commands) { fn init_prompts(
tweaks_file: Res<tweak::GameTweaks>,
tweaks: Res<Assets<tweak::Tweaks>>,
mut commands: Commands,
) {
let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks");
let button_handle = tweak.get_handle::<Image>("buttons_image_resting").unwrap();
let font_handle = tweak.get_handle::<Font>("buttons_font").unwrap();
// ClickToContinue // ClickToContinue
commands commands
.spawn(( .spawn((
@ -178,6 +186,90 @@ fn init_prompts(mut commands: Commands) {
visibility: Visibility::Inherited, visibility: Visibility::Inherited,
..default() ..default()
}); });
// Skip Intro button
parent
.spawn((
GameState::Intro,
menu::ButtonAction(GameState::Title),
ButtonBundle {
style: Style {
margin: UiRect::all(Val::Px(5.0)),
position_type: PositionType::Absolute,
bottom: Val::Px(0.0),
right: Val::Px(0.0),
..default()
},
background_color: Color::WHITE.with_a(0.3).into(),
image: UiImage {
texture: button_handle.clone(),
..default()
},
..default()
},
))
.with_children(|parent| {
parent.spawn(TextBundle {
text: Text {
sections: vec![TextSection {
value: "Skip".into(),
style: TextStyle {
color: Color::WHITE.with_a(0.3),
font_size: 8.0,
font: font_handle.clone(),
},
}],
..default()
},
style: Style {
margin: UiRect::all(Val::Px(10.0)),
..default()
},
..default()
});
});
// Skip Title button
parent
.spawn((
GameState::Title,
menu::ButtonAction(GameState::Play),
ButtonBundle {
style: Style {
margin: UiRect::all(Val::Px(5.0)),
position_type: PositionType::Absolute,
bottom: Val::Px(0.0),
right: Val::Px(0.0),
..default()
},
background_color: Color::WHITE.with_a(0.3).into(),
image: UiImage {
texture: button_handle.clone(),
..default()
},
..default()
},
))
.with_children(|parent| {
parent.spawn(TextBundle {
text: Text {
sections: vec![TextSection {
value: "Skip".into(),
style: TextStyle {
color: Color::WHITE.with_a(0.3),
font_size: 8.0,
font: font_handle.clone(),
},
}],
..default()
},
style: Style {
margin: UiRect::all(Val::Px(10.0)),
..default()
},
..default()
});
});
}); });
} }

Loading…
Cancel
Save