|
|
|
|
@ -22,14 +22,19 @@ 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);
|
|
|
|
|
pub(crate) struct SetState<S: States + Clone + Debug>(pub S);
|
|
|
|
|
|
|
|
|
|
fn button_state_actions<S: States>(
|
|
|
|
|
q: Query<(&mut S, &SetState<S>, &Interaction), Changed<Interaction>>,
|
|
|
|
|
s: Res<State<S>>,
|
|
|
|
|
n: Res<NextState<S>>,
|
|
|
|
|
pub(crate) fn button_state_action<S: States + Clone + Debug>(
|
|
|
|
|
q: Query<(&SetState<S>, &Interaction), Changed<Interaction>>,
|
|
|
|
|
mut n: ResMut<NextState<S>>,
|
|
|
|
|
) {
|
|
|
|
|
todo!("Change state when button is clicked")
|
|
|
|
|
q.iter()
|
|
|
|
|
.for_each(|(SetState(s), interaction)| match interaction {
|
|
|
|
|
Interaction::Pressed => {
|
|
|
|
|
n.set(s.clone());
|
|
|
|
|
}
|
|
|
|
|
_ => (),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) mod button {
|
|
|
|
|
@ -113,8 +118,23 @@ pub(crate) mod container {
|
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
border_color: BorderColor(Color::BLACK),
|
|
|
|
|
..default()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) mod style {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
pub(crate) struct UiStyle(pub Style);
|
|
|
|
|
|
|
|
|
|
impl EntityCommand for UiStyle {
|
|
|
|
|
fn apply(self, id: Entity, world: &mut World) {
|
|
|
|
|
if let Some(mut s) = world.entity_mut(id).get_mut::<Style>() {
|
|
|
|
|
*s = self.0.clone();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|