|
|
|
@ -1,12 +1,12 @@
|
|
|
|
// TODO:
|
|
|
|
// TODO:
|
|
|
|
// * Debug Panel
|
|
|
|
// * Debug Panel
|
|
|
|
// * Describe cell I am hovering over (Note, Octave, etc)
|
|
|
|
// * Describe cell I am hovering over (Note, Octave, etc)
|
|
|
|
// * Count # of cells on the board
|
|
|
|
|
|
|
|
// * Fix tiling repeating
|
|
|
|
// * Fix tiling repeating
|
|
|
|
// * Negative coordinates should not mirror
|
|
|
|
// * Negative coordinates should not mirror
|
|
|
|
// * Fix randomly audio not working
|
|
|
|
// * Fix randomly audio not working
|
|
|
|
// * space -> play/pause sim
|
|
|
|
// * On reset: pause
|
|
|
|
// * m -> un/mute audio
|
|
|
|
// * Show shadow of piece (same tile, just with alpha transparency)
|
|
|
|
|
|
|
|
// * UI: Swap buttons mutually exclusive instead of disabling
|
|
|
|
#![allow(clippy::complexity)]
|
|
|
|
#![allow(clippy::complexity)]
|
|
|
|
// Only because of FromTemplat macros unfortunately...
|
|
|
|
// Only because of FromTemplat macros unfortunately...
|
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
@ -89,9 +89,9 @@ fn main() {
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
// TODO: Visualize audio play/mute buttons enable/disable
|
|
|
|
toggle_state_visible::<SimulationPlayback>.run_if(state_changed::<SimulationPlayback>),
|
|
|
|
manage_interactive::<SimulationPlayback>,
|
|
|
|
manage_interactive::<SimulationPlayback>,
|
|
|
|
// TODO Visualize simulation run/pause buttons enable/disable
|
|
|
|
toggle_state_visible::<AudioPlayback>.run_if(state_changed::<AudioPlayback>),
|
|
|
|
manage_interactive::<AudioPlayback>,
|
|
|
|
manage_interactive::<AudioPlayback>,
|
|
|
|
update_note_interactivity,
|
|
|
|
update_note_interactivity,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -196,6 +196,43 @@ 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 {
|
|
|
|
fn the_camera() -> impl Scene {
|
|
|
|
bsn! {
|
|
|
|
bsn! {
|
|
|
|
Camera2d
|
|
|
|
Camera2d
|
|
|
|
@ -362,11 +399,7 @@ fn primary_ui() -> impl Scene {
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
ui_button(UiButton::Power)
|
|
|
|
ui_button(UiButton::Power)
|
|
|
|
ActionSource<Action>(Action::Quit),
|
|
|
|
ActionSource<Action>(Action::Quit),
|
|
|
|
ui_button(UiButton::Pause)
|
|
|
|
ui_toggle_button((UiButton::Pause, bsn! { SimulationPlayback::Pause }), (UiButton::Play, bsn! { SimulationPlayback::Run }))
|
|
|
|
SimulationPlayback::Pause
|
|
|
|
|
|
|
|
ActionSource<SimAction>(SimAction::Toggle),
|
|
|
|
|
|
|
|
ui_button(UiButton::Play)
|
|
|
|
|
|
|
|
SimulationPlayback::Run
|
|
|
|
|
|
|
|
ActionSource<SimAction>(SimAction::Toggle),
|
|
|
|
ActionSource<SimAction>(SimAction::Toggle),
|
|
|
|
ui_button(UiButton::Step)
|
|
|
|
ui_button(UiButton::Step)
|
|
|
|
ActionSource<SimAction>(SimAction::Step),
|
|
|
|
ActionSource<SimAction>(SimAction::Step),
|
|
|
|
@ -378,11 +411,7 @@ fn primary_ui() -> impl Scene {
|
|
|
|
ActionSource<ZoomAction>(ZoomAction::ZoomOut),
|
|
|
|
ActionSource<ZoomAction>(ZoomAction::ZoomOut),
|
|
|
|
ui_button(UiButton::ZoomIn)
|
|
|
|
ui_button(UiButton::ZoomIn)
|
|
|
|
ActionSource<ZoomAction>(ZoomAction::ZoomIn),
|
|
|
|
ActionSource<ZoomAction>(ZoomAction::ZoomIn),
|
|
|
|
ui_button(UiButton::MuteAudio)
|
|
|
|
ui_toggle_button((UiButton::MuteAudio, bsn! { AudioPlayback::Mute }), (UiButton::PlayAudio, bsn! { AudioPlayback::Play }))
|
|
|
|
AudioPlayback::Mute
|
|
|
|
|
|
|
|
ActionSource<AudioAction>(AudioAction::Toggle),
|
|
|
|
|
|
|
|
ui_button(UiButton::PlayAudio)
|
|
|
|
|
|
|
|
AudioPlayback::Play
|
|
|
|
|
|
|
|
ActionSource<AudioAction>(AudioAction::Toggle),
|
|
|
|
ActionSource<AudioAction>(AudioAction::Toggle),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -1190,3 +1219,19 @@ fn update_note_interactivity(
|
|
|
|
fn pause_simulation(mut next: ResMut<NextState<SimulationPlayback>>) {
|
|
|
|
fn pause_simulation(mut next: ResMut<NextState<SimulationPlayback>>) {
|
|
|
|
next.set(SimulationPlayback::Pause)
|
|
|
|
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
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|