tutorial quality of life improverments

main
Elijah C. Voigt 1 year ago
parent 29144126e9
commit 18b2341b6a

@ -1471,4 +1471,4 @@ fn fade_title(
let new_a = (bgc.0.a() + step).min(1.0).max(0.0); let new_a = (bgc.0.a() + step).min(1.0).max(0.0);
bgc.0.set_a(new_a); bgc.0.set_a(new_a);
}) })
} }

@ -40,6 +40,14 @@ impl Plugin for TutorialPlugin {
) )
.run_if(not(in_state(GameState::Loading))) .run_if(not(in_state(GameState::Loading)))
.run_if(state_changed::<TutorialState>), .run_if(state_changed::<TutorialState>),
)
.add_systems(
Update,
start_tutorial_on_play
.run_if(in_state(GameState::Play))
.run_if(not(resource_exists::<TutorialStarted>))
.run_if(any_component_removed::<display3d::Dissolving>())
.run_if(state_changed::<TutorialState>),
); );
} }
} }
@ -174,6 +182,50 @@ fn initialize_tutorial(
}, },
)) ))
.with_children(|parent| { .with_children(|parent| {
// Skip button
parent
.spawn((
menu::ButtonAction(tutorial::TutorialState::None),
menu::ButtonAction(GameState::Play),
menu::ButtonAction(menu::MenuState::Off),
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 Tutorial".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(20.0)),
..default()
},
..default()
});
});
// Content
parent parent
.spawn(( .spawn((
step.clone(), step.clone(),
@ -199,7 +251,7 @@ fn initialize_tutorial(
.map(|line| TextSection { .map(|line| TextSection {
value: line.clone(), value: line.clone(),
style: TextStyle { style: TextStyle {
font_size: 12.0, font_size: 14.0,
color: Color::hex(&text_visible_hex).unwrap(), color: Color::hex(&text_visible_hex).unwrap(),
font: ui_font.handle.clone(), font: ui_font.handle.clone(),
}, },
@ -211,11 +263,16 @@ fn initialize_tutorial(
..default() ..default()
}, },
)); ));
if *step == TutorialState::Outro { if *step == TutorialState::Outro {
parent parent
.spawn(NodeBundle { .spawn(NodeBundle {
style: Style { style: Style {
flex_direction: FlexDirection::Row, flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
justify_items: JustifyItems::Center,
align_content: AlignContent::Center,
justify_content: JustifyContent::Center,
..default() ..default()
}, },
..default() ..default()
@ -228,8 +285,9 @@ fn initialize_tutorial(
menu::ButtonAction(menu::MenuState::Off), menu::ButtonAction(menu::MenuState::Off),
ButtonBundle { ButtonBundle {
style: Style { style: Style {
padding: UiRect::all(Val::Px(5.0)),
margin: UiRect::all(Val::Px(5.0)), margin: UiRect::all(Val::Px(5.0)),
align_content: AlignContent::Center,
justify_content: JustifyContent::Center,
..default() ..default()
}, },
image: UiImage { image: UiImage {
@ -243,7 +301,7 @@ fn initialize_tutorial(
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: 10.0, font_size: 10.0,
@ -264,11 +322,12 @@ fn initialize_tutorial(
.spawn(( .spawn((
menu::ButtonAction(tutorial::TutorialState::None), menu::ButtonAction(tutorial::TutorialState::None),
menu::ButtonAction(GameState::Play), menu::ButtonAction(GameState::Play),
menu::ButtonAction(menu::MenuState::Off), menu::ButtonAction(menu::MenuState::On),
ButtonBundle { ButtonBundle {
style: Style { style: Style {
padding: UiRect::all(Val::Px(5.0)),
margin: UiRect::all(Val::Px(5.0)), margin: UiRect::all(Val::Px(5.0)),
align_content: AlignContent::Center,
justify_content: JustifyContent::Center,
..default() ..default()
}, },
image: UiImage { image: UiImage {
@ -282,10 +341,10 @@ fn initialize_tutorial(
parent.spawn(TextBundle { parent.spawn(TextBundle {
text: Text { text: Text {
sections: vec![TextSection { sections: vec![TextSection {
value: "C o n t i n u e".into(), value: "Main Menu".into(),
style: TextStyle { style: TextStyle {
color: Color::WHITE, color: Color::WHITE,
font_size: 8.0, font_size: 10.0,
font: font_handle.clone(), font: font_handle.clone(),
}, },
}], }],
@ -423,4 +482,20 @@ fn activate_tutorial_step(
*v = Visibility::Hidden; *v = Visibility::Hidden;
} }
}); });
}
#[derive(Debug, Resource)]
struct TutorialStarted;
fn start_tutorial_on_play(
query: Query<Entity, (With<BoardComponent>, With<display3d::Dissolving>)>,
state: Res<State<TutorialState>>,
mut next_state: ResMut<NextState<TutorialState>>,
mut commands: Commands,
) {
if query.iter().len() == 0 || *state.get() != TutorialState::None {
info!("Intro dissolve is done!");
next_state.set(TutorialState::Intro);
commands.insert_resource(TutorialStarted);
}
} }
Loading…
Cancel
Save