Compare commits

...

9 Commits

@ -0,0 +1,10 @@
Voluptatem culpa quo quia alias minima amet. Consequatur fugit et vitae qui dolor. Aut ea dolorum dicta quas ex et recusandae et. Nostrum eos quia quis est consequuntur.
Ratione facilis aliquid et. Dolores expedita magni suscipit minima. Voluptatem in pariatur vitae laboriosam aliquam non ducimus. Laudantium illum provident et libero assumenda et sunt similique. Corporis tenetur repellat enim perferendis ut minus omnis.
Blanditiis vitae quae ut ipsum consequatur. Ratione dignissimos exercitationem autem accusamus. Qui molestiae ipsam pariatur quis amet quia voluptate sunt. In voluptate dolorum in quia. Sit ut non voluptatem qui placeat quis. Ducimus ipsa adipisci eligendi dolor id.
Ex totam nam laudantium quis. Omnis saepe mollitia eligendi unde rerum. Odit voluptatum repellat rem est iure neque saepe.
Nulla est consequatur sint amet nesciunt quam. Qui fuga excepturi veritatis quia. Saepe natus et enim eveniet voluptates velit quod sint. Dolores reprehenderit eligendi aut. Et voluptate ea aliquam.

@ -0,0 +1 @@
This is a placeholder monologue

File diff suppressed because it is too large Load Diff

@ -31,10 +31,10 @@ impl Plugin for GameUiPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_event::<Alert>() app.add_event::<Alert>()
.add_systems(Startup, init_alerts) .add_systems(Startup, init_alerts)
.add_systems(PreUpdate, create_titles)
.add_systems( .add_systems(
Update, Update,
( (
create_titles,
manage_titles, manage_titles,
manage_button_interaction, manage_button_interaction,
manage_select_active, manage_select_active,
@ -55,9 +55,39 @@ pub use title::*;
mod title { mod title {
use super::*; use super::*;
#[derive(Debug, Component)] #[derive(Debug, Component, Default)]
pub struct Title { pub struct Title {
pub text: String, pub text: String,
pub font: Option<Handle<Font>>,
}
#[derive(Debug)]
pub struct TitleBarBase {
bg_color: Color,
}
impl TitleBarBase {
pub fn new(bg_color: Color) -> Self {
Self { bg_color }
}
pub fn bundle(&self) -> NodeBundle {
NodeBundle {
style: Style {
padding: UiRect::all(Val::Px(1.0)),
margin: UiRect::all(Val::Px(1.0)),
border: UiRect::all(Val::Px(1.0)),
flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
align_content: AlignContent::Center,
justify_content: JustifyContent::SpaceBetween,
..default()
},
background_color: self.bg_color.into(),
border_color: Color::BLACK.into(),
..default()
}
}
} }
#[derive(Debug, Component)] #[derive(Debug, Component)]
@ -93,16 +123,24 @@ mod title {
) { ) {
events.for_each(|(entity, title, note, minimize, close)| { events.for_each(|(entity, title, note, minimize, close)| {
commands.entity(entity).with_children(|parent| { commands.entity(entity).with_children(|parent| {
let style = match &title.font {
Some(handle) => TextStyle {
color: Color::BLACK,
font: handle.clone(),
..default()
},
None => TextStyle {
color: Color::BLACK,
..default()
},
};
parent.spawn(( parent.spawn((
TextBundle { TextBundle {
text: Text { text: Text {
sections: vec![ sections: vec![
TextSection { TextSection {
value: title.text.clone(), value: title.text.clone(),
style: TextStyle { style,
color: Color::BLACK,
..default()
},
}, },
TextSection { TextSection {
value: note value: note
@ -291,19 +329,19 @@ mod collapse {
collapses: Query<&Collapse, With<Button>>, collapses: Query<&Collapse, With<Button>>,
mut styles: Query<&mut Style>, mut styles: Query<&mut Style>,
) { ) {
// Added collapse, display the target entity // Removed collapse, hide the target entity
added.iter().for_each(|e| { removed.iter().for_each(|e| {
if let Ok(Collapse { target }) = collapses.get(e) { if let Ok(Collapse { target }) = collapses.get(e) {
if let Ok(mut style) = styles.get_mut(*target) { if let Ok(mut style) = styles.get_mut(*target) {
style.display = Display::Flex; style.display = Display::None;
} }
} }
}); });
// Removed collapse, hide the target entity // Added collapse, display the target entity
removed.iter().for_each(|e| { added.iter().for_each(|e| {
if let Ok(Collapse { target }) = collapses.get(e) { if let Ok(Collapse { target }) = collapses.get(e) {
if let Ok(mut style) = styles.get_mut(*target) { if let Ok(mut style) = styles.get_mut(*target) {
style.display = Display::None; style.display = Display::Flex;
} }
} }
}); });
@ -352,14 +390,14 @@ mod buttons {
mut removed_active: RemovedComponents<Active>, mut removed_active: RemovedComponents<Active>,
mut bg_colors: Query<&mut BackgroundColor>, mut bg_colors: Query<&mut BackgroundColor>,
) { ) {
added_active.for_each(|e| { removed_active.iter().for_each(|e| {
if let Ok(mut bg_color) = bg_colors.get_mut(e) { if let Ok(mut bg_color) = bg_colors.get_mut(e) {
*bg_color = Color::ORANGE.into(); *bg_color = Color::WHITE.into();
} }
}); });
removed_active.iter().for_each(|e| { added_active.for_each(|e| {
if let Ok(mut bg_color) = bg_colors.get_mut(e) { if let Ok(mut bg_color) = bg_colors.get_mut(e) {
*bg_color = Color::WHITE.into(); *bg_color = Color::ORANGE.into();
} }
}); });
events.for_each(|(entity, interaction, active)| { events.for_each(|(entity, interaction, active)| {
@ -570,36 +608,43 @@ pub mod alert {
justify_self: JustifySelf::Center, justify_self: JustifySelf::Center,
..default() ..default()
}, },
background_color: Color::WHITE.into(),
border_color: color.into(), border_color: color.into(),
..default() ..default()
}) })
.with_children(|parent| { .with_children(|parent| {
parent.spawn(( parent.spawn((
NodeBundle { TitleBarBase::new(color).bundle(),
style: Style {
padding: UiRect::all(Val::Px(1.0)),
margin: UiRect::all(Val::Px(1.0)),
border: UiRect::all(Val::Px(1.0)),
flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
align_content: AlignContent::Center,
justify_content: JustifyContent::SpaceBetween,
..default()
},
background_color: color.into(),
..default()
},
Title { Title {
text: "Alert".into(), text: "Alert".into(),
..default()
}, },
Close { Close {
target: parent.parent_entity(), target: parent.parent_entity(),
}, },
Sorting(0), Sorting(0),
)); ));
parent.spawn(TextBundle::from_section(text, TextStyle { ..default() })); parent.spawn(TextBundle::from_section(
text,
TextStyle {
color: Color::BLACK.into(),
..default()
},
));
}); });
}); });
}); });
} }
} }
use dragndrop::*;
pub mod dragndrop {
use super::*;
#[derive(Debug, Component)]
struct DragNDrop;
pub fn dragndrop() {
todo!()
}
}

Loading…
Cancel
Save