Compare commits

..

No commits in common. 'fbc9389f57cdcb91e50a6c524f80f567df1b7692' and 'f3afb2616c3575c2f0b40f2ee0b45ddcf7e44b82' have entirely different histories.

@ -69,7 +69,6 @@ impl SimAction {
mut lifecycle: MessageWriter<Lifecycle>,
cells: Query<Entity, With<Cell>>,
mut commands: Commands,
mut playback: ResMut<NextState<SimulationPlayback>>,
) {
// TODO: reconcile board instead of despawn/spawning the world
cells.iter().for_each(|e| {
@ -78,7 +77,6 @@ impl SimAction {
last_board_state.coordinates.iter().for_each(|c| {
lifecycle.write(Lifecycle::Alive(c.clone()));
});
playback.set(SimulationPlayback::Pause);
}
// Wipe all cells from the board

@ -1,13 +1,12 @@
// TODO:
// * Debug Panel
// * Describe cell I am hovering over (Note, Octave, etc)
// * Count # of cells on the board
// * Fix tiling repeating
// * Negative coordinates should not mirror
// * Fix randomly audio not working
// * Make click and drag feel better
// * Show shadow of piece (same tile, just with alpha transparency)
// * UI widget explaining rules/hotkeys
// * UI minimize widgets
// * Start with an interesting pattern
// * Lock down system scheduling/run_if conditions
// * space -> play/pause sim
// * m -> un/mute audio
#![allow(clippy::complexity)]
// Only because of FromTemplat macros unfortunately...
#![allow(dead_code)]
@ -84,16 +83,15 @@ fn main() {
grid_gizmo,
update_debug_info_cell_count,
update_debug_info_coordinates,
update_debug_info_active,
),
)
// Ui Controllers
.add_systems(
Update,
(
toggle_state_visible::<SimulationPlayback>.run_if(state_changed::<SimulationPlayback>),
// TODO: Visualize audio play/mute buttons enable/disable
manage_interactive::<SimulationPlayback>,
toggle_state_visible::<AudioPlayback>.run_if(state_changed::<AudioPlayback>),
// TODO Visualize simulation run/pause buttons enable/disable
manage_interactive::<AudioPlayback>,
update_note_interactivity,
),
@ -112,7 +110,6 @@ const SCALE: f32 = 100.0;
enum DebugInfo {
CellCount,
Coordinates,
Active,
#[default]
Empty,
}
@ -199,43 +196,6 @@ fn ui_button(button: UiButton) -> impl Scene {
}
}
fn ui_toggle_button<A: Scene, B: Scene>((button_a, state_a): (UiButton, A), (button_b, state_b): (UiButton, B)) -> impl Scene {
bsn! {
@FeathersButton
Hovered
Node {
top: Val::Px(2.5),
left: Val::Px(2.5),
margin: UiRect::all(Val::Px(2.5)),
align_items: AlignItems::Center,
}
Children [
Node {
align_self: AlignSelf::Center,
justify_self: JustifySelf::Center,
width: Val::Percent(100.0),
height: Val::Percent(100.0),
}
ImageNode {
image: HandleTemplate::Path(AssetPath::parse(button_a.icon())),
}
state_a
ToggleStateVisible,
Node {
align_self: AlignSelf::Center,
justify_self: JustifySelf::Center,
width: Val::Percent(100.0),
height: Val::Percent(100.0),
}
ImageNode {
image: HandleTemplate::Path(AssetPath::parse(button_b.icon())),
}
state_b
ToggleStateVisible,
]
}
}
fn the_camera() -> impl Scene {
bsn! {
Camera2d
@ -345,27 +305,6 @@ fn debug_ui() -> impl Scene {
Children [
Text("##,##") ThemedText template_value(DebugInfo::Coordinates)
]
],
subpane()
Node {
display: Display::Flex,
flex_direction: FlexDirection::Row,
}
Children [
subpane_header() Children [
Text("Active Cell") ThemedText
]
subpane_body()
Node {
display: Display::Flex,
flex_direction: FlexDirection::Row,
align_items: AlignItems::Stretch,
justify_content: JustifyContent::Start,
}
text_setup()
Children [
Text("Foo/Bar") ThemedText template_value(DebugInfo::Active)
]
]
]
]
@ -423,7 +362,11 @@ fn primary_ui() -> impl Scene {
Children [
ui_button(UiButton::Power)
ActionSource<Action>(Action::Quit),
ui_toggle_button((UiButton::Pause, bsn! { SimulationPlayback::Pause }), (UiButton::Play, bsn! { SimulationPlayback::Run }))
ui_button(UiButton::Pause)
SimulationPlayback::Pause
ActionSource<SimAction>(SimAction::Toggle),
ui_button(UiButton::Play)
SimulationPlayback::Run
ActionSource<SimAction>(SimAction::Toggle),
ui_button(UiButton::Step)
ActionSource<SimAction>(SimAction::Step),
@ -435,7 +378,11 @@ fn primary_ui() -> impl Scene {
ActionSource<ZoomAction>(ZoomAction::ZoomOut),
ui_button(UiButton::ZoomIn)
ActionSource<ZoomAction>(ZoomAction::ZoomIn),
ui_toggle_button((UiButton::MuteAudio, bsn! { AudioPlayback::Mute }), (UiButton::PlayAudio, bsn! { AudioPlayback::Play }))
ui_button(UiButton::MuteAudio)
AudioPlayback::Mute
ActionSource<AudioAction>(AudioAction::Toggle),
ui_button(UiButton::PlayAudio)
AudioPlayback::Play
ActionSource<AudioAction>(AudioAction::Toggle),
]
],
@ -608,7 +555,7 @@ impl Coordinates {
}
}
/// When the cursor moves, update the Coordinates
/// When the cursor moves, update the Coordiantes
fn update_grid_position(
mut coordinates: ResMut<NextCoordinates>,
q_window: Single<&Window>,
@ -1224,22 +1171,6 @@ fn update_debug_info_coordinates(
});
}
fn update_debug_info_active(
next_coordinates: Res<NextCoordinates>,
cells: Query<(&CellPitch, &Coordinates)>,
mut text: Query<(&DebugInfo, &mut Text)>,
) {
text.iter_mut()
.filter(|(di, _)| **di == DebugInfo::Active)
.for_each(|(_, mut t)| {
if let Some((cp, _c)) = cells.iter().find(|(_cp, c)| **c == next_coordinates.0) {
*t = Text::new(format!("Note: {:?} | Octave: {}", cp.note, cp.octave));
} else {
*t = Text::new(String::from("N/A"));
}
});
}
fn update_note_interactivity(
checked: Query<Entity, (With<Note>, With<Checkbox>, With<Checked>)>,
mut commands: Commands,
@ -1259,19 +1190,3 @@ fn update_note_interactivity(
fn pause_simulation(mut next: ResMut<NextState<SimulationPlayback>>) {
next.set(SimulationPlayback::Pause)
}
#[derive(Component, Debug, FromTemplate)]
struct ToggleStateVisible;
fn toggle_state_visible<S: States + Component>(
mut q: Query<(&S, &mut Node), With<ToggleStateVisible>>,
c: Res<State<S>>
) {
q.iter_mut().for_each(|(s, mut node)| {
node.display = if s == c.get() {
Display::None
} else {
Display::Flex
};
})
}

Loading…
Cancel
Save