Skip to content

Commit

Permalink
dev: started using bevy_ui_dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
roboteng committed Oct 12, 2023
1 parent d98fcea commit 54250b7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions game/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2021"

[dependencies]
bevy = "0.11.3"
bevy-ui-dsl = "0.6.1"
42 changes: 12 additions & 30 deletions game/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy::prelude::*;
use bevy_ui_dsl::*;

pub struct BasePlugin;

Expand All @@ -9,38 +10,19 @@ impl Plugin for BasePlugin {
}
}

fn draw_main_menu(mut commands: Commands) {
fn c_background(node: &mut NodeBundle) {
node.background_color = Color::DARK_GREEN.into();
let style = &mut node.style;
style.flex_direction = FlexDirection::Column;
style.width = Val::Vw(100.0);
}

fn draw_main_menu(mut commands: Commands, assets: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());

commands
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Column,
width: Val::Vw(100.0),
..Default::default()
},
background_color: Color::DARK_GREEN.into(),
..Default::default()
})
.with_children(|builder| {
builder.spawn(TextBundle::from_section(
"Hello, World!",
TextStyle::default(),
));
builder
.spawn(ButtonBundle {
..Default::default()
})
.with_children(|builder| {
builder.spawn(TextBundle::from_section(
"Hello, Button!",
TextStyle {
color: Color::BLACK,
..Default::default()
},
));
});
});
root(c_background, &assets, &mut commands, |p| {
text("Hello, DSL", (), (), p);
});
}

#[derive(Debug, Default, Hash, PartialEq, Eq, Clone, States)]
Expand Down

0 comments on commit 54250b7

Please sign in to comment.