62 lines
1.9 KiB
Rust
62 lines
1.9 KiB
Rust
|
use bevy::prelude::*;
|
||
|
|
||
|
use crate::assets::AssetLoader;
|
||
|
|
||
|
#[derive(Component, Debug)]
|
||
|
pub struct MainMenu;
|
||
|
|
||
|
impl Plugin for MainMenu {
|
||
|
fn build(&self, app: &mut App) {
|
||
|
app.add_systems(PostStartup, setup_main_menu);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn setup_main_menu(mut commands: Commands, assets: Res<AssetLoader>) {
|
||
|
commands
|
||
|
.spawn(NodeBundle {
|
||
|
style: Style {
|
||
|
width: Val::Percent(100.0),
|
||
|
height: Val::Percent(100.0),
|
||
|
justify_content: JustifyContent::SpaceBetween,
|
||
|
..default()
|
||
|
},
|
||
|
..default()
|
||
|
})
|
||
|
.with_children(|parent| {
|
||
|
// text
|
||
|
parent.spawn((
|
||
|
TextBundle::from_section(
|
||
|
"Text Example",
|
||
|
TextStyle {
|
||
|
font: assets.fonts.iosevkalytemin.clone(),
|
||
|
font_size: 30.0,
|
||
|
..default()
|
||
|
},
|
||
|
)
|
||
|
.with_style(Style {
|
||
|
margin: UiRect::all(Val::Px(12.)),
|
||
|
..default()
|
||
|
}),
|
||
|
// Because this is a distinct label widget and
|
||
|
// not button/list item text, this is necessary
|
||
|
// for accessibility to treat the text accordingly.
|
||
|
Label,
|
||
|
));
|
||
|
|
||
|
parent.spawn(NodeBundle {
|
||
|
style: Style {
|
||
|
width: Val::Px(200.0),
|
||
|
height: Val::Px(200.0),
|
||
|
position_type: PositionType::Absolute,
|
||
|
left: Val::Px(210.),
|
||
|
bottom: Val::Px(10.),
|
||
|
border: UiRect::all(Val::Px(20.)),
|
||
|
..default()
|
||
|
},
|
||
|
border_color: Color::GREEN.into(),
|
||
|
background_color: Color::rgb(0.4, 0.4, 1.).into(),
|
||
|
..default()
|
||
|
});
|
||
|
});
|
||
|
}
|