diff --git a/life/src/main.rs b/life/src/main.rs index 4b8dcf4..a94579b 100644 --- a/life/src/main.rs +++ b/life/src/main.rs @@ -3,11 +3,9 @@ #![allow(dead_code)] use bevy::{ - feathers::{containers::*, theme::ThemeProps}, - ui::{Checked, InteractionDisabled}, - ui_widgets::{ + feathers::{containers::*, theme::ThemeProps}, ui::{Checked, InteractionDisabled}, ui_widgets::{ ActivateOnPress, Checkbox, SliderPrecision, SliderStep, ValueChange, checkbox_self_update, slider_self_update - }, + } }; use engine::*; @@ -181,6 +179,7 @@ fn the_ui() -> impl Scene { mut pitch_map: ResMut, ) { if change.is_final { + // TODO: if last selected note and de-selected, undo that move please let this_note = notes.get(change.source).unwrap(); pitch_map.set_note(this_note, change.value); info!("(note {:?}) Updated pitch map: {:#?}", this_note, pitch_map); @@ -289,40 +288,40 @@ fn the_ui() -> impl Scene { } Children [ ui_checkbox("A") - Note::A + template_value(Note::A) on(toggle_note), ui_checkbox("A#") - Note::ASharp + template_value(Note::ASharp) on(toggle_note), ui_checkbox("B") - Note::B + template_value(Note::B) on(toggle_note), ui_checkbox("C") - Note::C + template_value(Note::C) on(toggle_note), ui_checkbox("C#") - Note::CSharp + template_value(Note::CSharp) on(toggle_note), ui_checkbox("D") - Note::D + template_value(Note::D) on(toggle_note), ui_checkbox("D#") - Note::DSharp + template_value(Note::DSharp) on(toggle_note), ui_checkbox("E") - Note::E + template_value(Note::E) on(toggle_note), ui_checkbox("F") - Note::F + template_value(Note::F) on(toggle_note), ui_checkbox("F#") - Note::FSharp + template_value(Note::FSharp) on(toggle_note), ui_checkbox("G") - Note::G + template_value(Note::G) on(toggle_note), ui_checkbox("G#") - Note::GSharp + template_value(Note::GSharp) on(toggle_note), ] ], @@ -614,11 +613,15 @@ fn new_cell( let playback_settings = PlaybackSettings::ONCE.with_volume(volume); - debug!("using coordinates {:?}", c); + let cell_pitch = pitch_map.coordinates_cell_pitch(&c); + + #[derive(Clone, Default, Component)] + enum Foo { #[default]A } bsn! { Cell Coordinates { x, y } + template_value(cell_pitch) template_value(playback_settings) template_value(Transform::from_translation(c.as_translation() + Vec3::new(0.0, 0.0, 1.0))) template_value(Mesh2dTemplate(cell_assets.mesh.clone().into())) @@ -678,7 +681,7 @@ struct CellAssets { } // TODO: Impl Ord to sort Notes -#[derive(Hash, PartialEq, Eq, Debug, Clone, Component, Default, FromTemplate)] +#[derive(Component, Clone, Debug, Default, Reflect, PartialEq, Eq, Hash)] enum Note { #[default] A, @@ -732,7 +735,7 @@ impl Note { } } -#[derive(Hash, PartialEq, Eq, Debug, Component)] +#[derive(Component, Clone, Debug, Default, Reflect, PartialEq, Eq, Hash)] struct CellPitch { note: Note, octave: isize, @@ -996,11 +999,13 @@ impl PitchMap { /// When the pitch map changes, update all cells to use the correct pitch (note + octave) fn reassign_cell_pitch( - mut query: Query<(&mut CellPitch, &Coordinates), With>, + mut query: Query<(&mut CellPitch, &Coordinates)>, pitch_map: Res, ) { + info!("query size: {:?}", query.iter().len()); query.iter_mut().for_each(|(mut cell_pitch, c)| { *cell_pitch = pitch_map.coordinates_cell_pitch(c); + info!("Updating cell pitch for {:?}", c); }); }