|
|
|
@ -41,8 +41,8 @@ fn button_builder(node: Node) -> (Button, BackgroundColor, Node, BorderColor) {
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
BackgroundColor(BLACK.with_alpha(0.9).into()),
|
|
|
|
BackgroundColor(BLACK.with_alpha(0.9).into()),
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
padding: UiRect::all(Val::Px(10.)),
|
|
|
|
padding: UiRect::all(Val::Px(5.)),
|
|
|
|
margin: UiRect::top(Val::Px(25.)),
|
|
|
|
margin: UiRect::top(Val::Px(5.)),
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
..node
|
|
|
|
..node
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -64,12 +64,43 @@ fn setup(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
parent
|
|
|
|
|
|
|
|
.spawn((
|
|
|
|
|
|
|
|
Button,
|
|
|
|
|
|
|
|
BackgroundColor(BLACK.with_alpha(0.9).into()),
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
|
|
|
margin: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
|
|
|
|
height: Val::Px(40.0),
|
|
|
|
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
|
|
|
|
top: Val::Px(0.0),
|
|
|
|
|
|
|
|
left: Val::Px(0.0),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
BorderColor(WHITE.into()),
|
|
|
|
|
|
|
|
GlobalZIndex(1),
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
parent.spawn((
|
|
|
|
|
|
|
|
ImageNode {
|
|
|
|
|
|
|
|
image: server.load("kenney_game-icons/PNG/White/1x/musicOn.png"),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
audio::MusicIcon,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.observe(button_hover_on)
|
|
|
|
|
|
|
|
.observe(button_hover_off)
|
|
|
|
|
|
|
|
.observe(audio::toggle_music);
|
|
|
|
|
|
|
|
|
|
|
|
parent
|
|
|
|
parent
|
|
|
|
.spawn(Node {
|
|
|
|
.spawn(Node {
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
|
|
|
|
height: Val::Percent(100.0),
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
justify_content: JustifyContent::Center,
|
|
|
|
justify_content: JustifyContent::SpaceAround,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
@ -79,11 +110,20 @@ fn setup(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
height: Val::Px(300.0),
|
|
|
|
height: Val::Percent(40.0),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parent
|
|
|
|
|
|
|
|
.spawn(Node {
|
|
|
|
|
|
|
|
height: Val::Percent(40.0),
|
|
|
|
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
|
|
|
|
justify_content: JustifyContent::FlexEnd,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.with_children(|parent| {
|
|
|
|
parent
|
|
|
|
parent
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
button_builder(Node::default()),
|
|
|
|
button_builder(Node::default()),
|
|
|
|
@ -132,6 +172,7 @@ fn setup(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
.observe(quit_button);
|
|
|
|
.observe(quit_button);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
#[derive(Component)]
|
|
|
|
@ -289,7 +330,7 @@ fn setup_about(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
ViewState::About,
|
|
|
|
ViewState::About,
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
justify_content: JustifyContent::SpaceBetween,
|
|
|
|
justify_content: JustifyContent::FlexStart,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
))
|
|
|
|
))
|
|
|
|
@ -319,6 +360,32 @@ fn setup_about(mut commands: Commands, server: Res<AssetServer>) {
|
|
|
|
.observe(button_hover_off)
|
|
|
|
.observe(button_hover_off)
|
|
|
|
.observe(button_set_state(ViewState::Menu));
|
|
|
|
.observe(button_set_state(ViewState::Menu));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
parent
|
|
|
|
|
|
|
|
.spawn((
|
|
|
|
|
|
|
|
Button,
|
|
|
|
|
|
|
|
BackgroundColor(BLACK.with_alpha(0.9).into()),
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
|
|
|
margin: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
|
|
|
|
height: Val::Px(40.0),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
BorderColor(WHITE.into()),
|
|
|
|
|
|
|
|
GlobalZIndex(1),
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
parent.spawn((
|
|
|
|
|
|
|
|
ImageNode {
|
|
|
|
|
|
|
|
image: server.load("kenney_game-icons/PNG/White/1x/musicOn.png"),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
audio::MusicIcon,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.observe(button_hover_on)
|
|
|
|
|
|
|
|
.observe(button_hover_off)
|
|
|
|
|
|
|
|
.observe(audio::toggle_music);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
@ -377,7 +444,7 @@ fn setup_how_to_play(mut commands: Commands, deck: Res<Deck>, server: Res<AssetS
|
|
|
|
ViewState::HowToPlay,
|
|
|
|
ViewState::HowToPlay,
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
justify_content: JustifyContent::SpaceBetween,
|
|
|
|
justify_content: JustifyContent::FlexStart,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
))
|
|
|
|
))
|
|
|
|
@ -407,6 +474,32 @@ fn setup_how_to_play(mut commands: Commands, deck: Res<Deck>, server: Res<AssetS
|
|
|
|
.observe(button_hover_off)
|
|
|
|
.observe(button_hover_off)
|
|
|
|
.observe(button_set_state(ViewState::Menu));
|
|
|
|
.observe(button_set_state(ViewState::Menu));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
parent
|
|
|
|
|
|
|
|
.spawn((
|
|
|
|
|
|
|
|
Button,
|
|
|
|
|
|
|
|
BackgroundColor(BLACK.with_alpha(0.9).into()),
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
|
|
|
margin: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
|
|
|
padding: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
|
|
|
border: UiRect::all(Val::Px(1.0)),
|
|
|
|
|
|
|
|
height: Val::Px(40.0),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
BorderColor(WHITE.into()),
|
|
|
|
|
|
|
|
GlobalZIndex(1),
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
parent.spawn((
|
|
|
|
|
|
|
|
ImageNode {
|
|
|
|
|
|
|
|
image: server.load("kenney_game-icons/PNG/White/1x/musicOn.png"),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
audio::MusicIcon,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.observe(button_hover_on)
|
|
|
|
|
|
|
|
.observe(button_hover_off)
|
|
|
|
|
|
|
|
.observe(audio::toggle_music);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
@ -517,6 +610,7 @@ fn setup_how_to_play(mut commands: Commands, deck: Res<Deck>, server: Res<AssetS
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Text(t.to_string()),
|
|
|
|
Text(t.to_string()),
|
|
|
|
|
|
|
|
TextFont::default().with_font_size(16.0),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
parent.spawn(Node {
|
|
|
|
parent.spawn(Node {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
|