commit
Some checks are pending
Rust Checks / checks (push) Waiting to run

This commit is contained in:
raphael 2024-04-01 16:29:00 +02:00
parent 27fc86bfe4
commit c6e9206213
9 changed files with 46 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

View file

@ -13,7 +13,8 @@ pub struct MenuPlugin;
impl Plugin for MenuPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Update, menu_ui.run_if(in_state(CurrentScene::Menu)));
// app.add_systems(Update, menu_ui.run_if(in_state(CurrentScene::Menu)));
app.add_systems(OnEnter(CurrentScene::Menu), menu_ui2);
}
}
@ -75,3 +76,47 @@ fn menu_ui(
}
});
}
/// A Component to identify menus entities.
/// In order to be able to remove them later.
#[derive(Component)]
struct MenuEntity;
fn menu_ui2(mut commands: Commands, asset_server: Res<AssetServer>) {
commands
.spawn(ImageBundle {
style: Style {
margin: UiRect::all(Val::Auto),
width: Val::Px(1280.),
height: Val::Px(720.),
flex_direction: FlexDirection::Column,
..default()
},
image: asset_server.load("menu/bw_menu_bg.png").into(),
z_index: ZIndex::Local(0),
..default()
})
.insert(MenuEntity);
}
/// A function to create a side button.
fn create_side_button(
margin: UiRect,
target_scene: CurrentScene,
commands: &mut Commands,
textures: HoveredTexture,
) {
commands
.spawn(ButtonBundle {
style: Style {
width: Val::Px(53.),
aspect_ratio: Some(1.),
margin,
..default()
},
z_index: ZIndex::Global(14),
image: textures.texture.clone().into(),
..default()
})
.insert((target_scene, textures, MenuEntity));
}