|
|
|
|
@ -20,6 +20,18 @@ fn button_interaction(mut query: Query<(&mut BackgroundColor, &Interaction)>) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Component for marking a button as a "Set State" action
|
|
|
|
|
#[derive(Component)]
|
|
|
|
|
pub(crate) struct SetState<S: States>(S);
|
|
|
|
|
|
|
|
|
|
fn button_state_actions<S: States>(
|
|
|
|
|
q: Query<(&mut S, &SetState<S>, &Interaction), Changed<Interaction>>,
|
|
|
|
|
s: Res<State<S>>,
|
|
|
|
|
n: Res<NextState<S>>,
|
|
|
|
|
) {
|
|
|
|
|
todo!("Change state when button is clicked")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) mod button {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
@ -55,3 +67,54 @@ pub(crate) mod button {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) mod title {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
pub(crate) struct UiTitle {
|
|
|
|
|
pub text: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl EntityCommand for UiTitle {
|
|
|
|
|
fn apply(self, id: Entity, world: &mut World) {
|
|
|
|
|
let title_text_style = TextStyle {
|
|
|
|
|
color: Color::BLACK,
|
|
|
|
|
font_size: 24.0,
|
|
|
|
|
..default()
|
|
|
|
|
};
|
|
|
|
|
world.entity_mut(id).insert(TextBundle {
|
|
|
|
|
text: Text::from_section(self.text, title_text_style),
|
|
|
|
|
style: Style {
|
|
|
|
|
margin: UiRect::all(Val::Px(5.0)),
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
..default()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) mod container {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
pub(crate) struct UiContainer;
|
|
|
|
|
|
|
|
|
|
impl EntityCommand for UiContainer {
|
|
|
|
|
fn apply(self, id: Entity, world: &mut World) {
|
|
|
|
|
world.entity_mut(id).insert(NodeBundle {
|
|
|
|
|
style: Style {
|
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
|
height: Val::Percent(100.0),
|
|
|
|
|
align_items: AlignItems::Center,
|
|
|
|
|
align_content: AlignContent::Center,
|
|
|
|
|
justify_items: JustifyItems::Center,
|
|
|
|
|
justify_content: JustifyContent::Center,
|
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
..default()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|