|
|
|
|
@ -1,3 +1,13 @@
|
|
|
|
|
// TODO:
|
|
|
|
|
// * Debug Panel
|
|
|
|
|
// * Describe cell I am hovering over (Note, Octave, etc)
|
|
|
|
|
// * Count # of cells on the board
|
|
|
|
|
// * Save board state when playing
|
|
|
|
|
// * Restore board state from before playing
|
|
|
|
|
// * Wipe board
|
|
|
|
|
// * Fix tiling repeating
|
|
|
|
|
// * Negative coordinates should not mirror
|
|
|
|
|
//
|
|
|
|
|
#![allow(clippy::complexity)]
|
|
|
|
|
// Only because of FromTemplat macros unfortunately...
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
@ -625,7 +635,8 @@ fn new_cell(
|
|
|
|
|
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()))
|
|
|
|
|
template_value(AudioPlayerTemplate(cell_assets.pitches.get(&pitch_map.coordinates_cell_pitch(&c)).unwrap().clone().into()))
|
|
|
|
|
// AudioPlayer added by update_audio
|
|
|
|
|
// MeshMaterial2d added by update_material
|
|
|
|
|
template_value(MeshMaterial2dTemplate(cell_assets.materials.get(&pitch_map.coordinates_cell_pitch(&c)).unwrap().clone().into()))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -680,8 +691,7 @@ struct CellAssets {
|
|
|
|
|
mesh: Handle<Mesh>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Impl Ord to sort Notes
|
|
|
|
|
#[derive(Component, Clone, Debug, Default, Reflect, PartialEq, Eq, Hash)]
|
|
|
|
|
#[derive(Component, Clone, Debug, Default, Reflect, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
|
|
|
|
enum Note {
|
|
|
|
|
#[default]
|
|
|
|
|
A,
|
|
|
|
|
@ -975,6 +985,8 @@ impl PitchMap {
|
|
|
|
|
} else if value {
|
|
|
|
|
self.notes.push(n.clone());
|
|
|
|
|
}
|
|
|
|
|
// always ensure the notes list is sorted
|
|
|
|
|
self.notes.sort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Given the currently selected notes and octave range selected in the PitchMap convert the given coordinates to a CellPitch
|
|
|
|
|
@ -1011,14 +1023,13 @@ fn reassign_cell_pitch(
|
|
|
|
|
|
|
|
|
|
// When CellPitch is added/updated on a cell, update the material
|
|
|
|
|
fn update_material(
|
|
|
|
|
mut query: Query<
|
|
|
|
|
(&CellPitch, &mut MeshMaterial2d<ColorMaterial>),
|
|
|
|
|
Or<(Added<CellPitch>, Changed<CellPitch>)>,
|
|
|
|
|
>,
|
|
|
|
|
mut query: Query<(&CellPitch, Entity), Or<(Added<CellPitch>, Changed<CellPitch>)>>,
|
|
|
|
|
cell_assets: ResMut<CellAssets>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
query.iter_mut().for_each(|(cell_pitch, mut material)| {
|
|
|
|
|
material.0 = cell_assets.materials.get(cell_pitch).unwrap().clone();
|
|
|
|
|
query.iter_mut().for_each(|(cell_pitch, e)| {
|
|
|
|
|
let h = cell_assets.materials.get(cell_pitch).unwrap().clone();
|
|
|
|
|
commands.entity(e).insert(MeshMaterial2d(h));
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|