oh look we can do events
parent
3c4aa78a6d
commit
9de30b29cb
@ -0,0 +1,12 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Event, Default)]
|
||||
pub(crate) struct Play;
|
||||
|
||||
pub(crate) struct Events {}
|
||||
|
||||
impl Plugin for Events {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_event::<Play>();
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
use crate::events;
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct Play {}
|
||||
|
||||
fn action_button() -> ButtonBundle {
|
||||
ButtonBundle {
|
||||
style: Style {
|
||||
align_items: AlignItems::Center,
|
||||
width: Val::Percent(100.0),
|
||||
height: Val::Percent(100.0),
|
||||
..default()
|
||||
},
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_play(mut events: EventReader<events::Play>, mut commands: Commands) {
|
||||
for _ in events.iter() {
|
||||
let mut bg = commands.spawn(NodeBundle {
|
||||
style: Style {
|
||||
display: Display::Flex,
|
||||
flex_direction: FlexDirection::Column,
|
||||
height: Val::Percent(100.0),
|
||||
width: Val::Percent(100.0),
|
||||
..default()
|
||||
},
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
});
|
||||
|
||||
bg.with_children(|bg| {
|
||||
// header
|
||||
bg.spawn(NodeBundle {
|
||||
style: Style {
|
||||
display: Display::Flex,
|
||||
height: Val::Percent(10.0),
|
||||
width: Val::Percent(100.0),
|
||||
border: UiRect {
|
||||
bottom: Val::Px(2.0),
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
border_color: Color::BLACK.into(),
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
});
|
||||
|
||||
// main play area
|
||||
bg.spawn(NodeBundle {
|
||||
style: Style {
|
||||
display: Display::Flex,
|
||||
height: Val::Percent(50.0),
|
||||
width: Val::Percent(100.0),
|
||||
border: UiRect {
|
||||
bottom: Val::Px(2.0),
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
background_color: Color::GRAY.into(),
|
||||
border_color: Color::BLACK.into(),
|
||||
..default()
|
||||
});
|
||||
|
||||
// Action controls
|
||||
let mut control_row = bg.spawn(NodeBundle {
|
||||
style: Style {
|
||||
flex_direction: FlexDirection::Row,
|
||||
display: Display::Flex,
|
||||
height: Val::Percent(40.0),
|
||||
width: Val::Percent(100.0),
|
||||
..default()
|
||||
},
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
});
|
||||
control_row.with_children(|controls| {
|
||||
controls.spawn(NodeBundle {
|
||||
style: Style {
|
||||
display: Display::Flex,
|
||||
height: Val::Percent(100.0),
|
||||
width: Val::Percent(100.0),
|
||||
border: UiRect::all(Val::Px(8.0)),
|
||||
..default()
|
||||
},
|
||||
border_color: Color::RED.into(),
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
});
|
||||
controls.spawn(NodeBundle {
|
||||
style: Style {
|
||||
display: Display::Flex,
|
||||
height: Val::Percent(100.0),
|
||||
width: Val::Percent(100.0),
|
||||
border: UiRect::all(Val::Px(8.0)),
|
||||
..default()
|
||||
},
|
||||
border_color: Color::RED.into(),
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
});
|
||||
controls.spawn(NodeBundle {
|
||||
style: Style {
|
||||
display: Display::Flex,
|
||||
height: Val::Percent(100.0),
|
||||
width: Val::Percent(100.0),
|
||||
border: UiRect::all(Val::Px(8.0)),
|
||||
..default()
|
||||
},
|
||||
border_color: Color::RED.into(),
|
||||
background_color: Color::GRAY.into(),
|
||||
..default()
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for Play {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Update, handle_play);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue