|
|
|
@ -1,13 +1,14 @@
|
|
|
|
// TODO:
|
|
|
|
// TODO:
|
|
|
|
// * Fix randomly audio not working
|
|
|
|
// * Fix randomly audio not working
|
|
|
|
// * Lock down system scheduling/run_if conditions
|
|
|
|
// * Lock down system scheduling/run_if conditions
|
|
|
|
// * Fix tiling repeating
|
|
|
|
|
|
|
|
// * Negative coordinates should not mirror
|
|
|
|
|
|
|
|
// * UI widget explaining rules/hotkeys
|
|
|
|
// * UI widget explaining rules/hotkeys
|
|
|
|
// * Show shadow of piece (same tile, just with alpha transparency)
|
|
|
|
// * Show shadow of piece (same tile, just with alpha transparency)
|
|
|
|
// * Start with an interesting pattern
|
|
|
|
// * Start with an interesting pattern
|
|
|
|
// * UI minimize widgets
|
|
|
|
// * UI minimize widgets
|
|
|
|
|
|
|
|
// * Add "follow action" that adjusts camera to zoom in/out/move to see everything
|
|
|
|
// * Make click and drag feel better
|
|
|
|
// * Make click and drag feel better
|
|
|
|
|
|
|
|
// * Add arrow keys to move around
|
|
|
|
|
|
|
|
// * web/wasm build
|
|
|
|
#![allow(clippy::complexity)]
|
|
|
|
#![allow(clippy::complexity)]
|
|
|
|
// Only because of FromTemplat macros unfortunately...
|
|
|
|
// Only because of FromTemplat macros unfortunately...
|
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
@ -37,6 +38,8 @@ fn main() {
|
|
|
|
.insert_resource(UiTheme(create_light_theme()))
|
|
|
|
.insert_resource(UiTheme(create_light_theme()))
|
|
|
|
.init_state::<SimulationPlayback>()
|
|
|
|
.init_state::<SimulationPlayback>()
|
|
|
|
.init_state::<AudioPlayback>()
|
|
|
|
.init_state::<AudioPlayback>()
|
|
|
|
|
|
|
|
.init_state::<DebugUi>()
|
|
|
|
|
|
|
|
.init_state::<MainUi>()
|
|
|
|
.add_message::<Lifecycle>()
|
|
|
|
.add_message::<Lifecycle>()
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Startup,
|
|
|
|
Startup,
|
|
|
|
@ -92,9 +95,12 @@ fn main() {
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
Update,
|
|
|
|
Update,
|
|
|
|
(
|
|
|
|
(
|
|
|
|
toggle_state_visible::<SimulationPlayback>.run_if(state_changed::<SimulationPlayback>),
|
|
|
|
toggle_state_visible::<SimulationPlayback>
|
|
|
|
|
|
|
|
.run_if(state_changed::<SimulationPlayback>),
|
|
|
|
manage_interactive::<SimulationPlayback>,
|
|
|
|
manage_interactive::<SimulationPlayback>,
|
|
|
|
toggle_state_visible::<AudioPlayback>.run_if(state_changed::<AudioPlayback>),
|
|
|
|
toggle_state_visible::<AudioPlayback>.run_if(state_changed::<AudioPlayback>),
|
|
|
|
|
|
|
|
toggle_state_visible::<DebugUi>.run_if(state_changed::<DebugUi>),
|
|
|
|
|
|
|
|
toggle_state_visible::<MainUi>.run_if(state_changed::<MainUi>),
|
|
|
|
manage_interactive::<AudioPlayback>,
|
|
|
|
manage_interactive::<AudioPlayback>,
|
|
|
|
update_note_interactivity,
|
|
|
|
update_note_interactivity,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -118,6 +124,20 @@ enum DebugInfo {
|
|
|
|
Empty,
|
|
|
|
Empty,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(States, Debug, Default, Hash, PartialEq, Eq, Clone, Component, FromTemplate)]
|
|
|
|
|
|
|
|
enum DebugUi {
|
|
|
|
|
|
|
|
#[default]
|
|
|
|
|
|
|
|
Visible,
|
|
|
|
|
|
|
|
Hidden,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(States, Debug, Default, Hash, PartialEq, Eq, Clone, Component, FromTemplate)]
|
|
|
|
|
|
|
|
enum MainUi {
|
|
|
|
|
|
|
|
#[default]
|
|
|
|
|
|
|
|
Visible,
|
|
|
|
|
|
|
|
Hidden,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(States, Debug, Default, Hash, PartialEq, Eq, Clone, Component, FromTemplate)]
|
|
|
|
#[derive(States, Debug, Default, Hash, PartialEq, Eq, Clone, Component, FromTemplate)]
|
|
|
|
enum AudioPlayback {
|
|
|
|
enum AudioPlayback {
|
|
|
|
#[default]
|
|
|
|
#[default]
|
|
|
|
@ -200,7 +220,10 @@ 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 {
|
|
|
|
fn ui_toggle_button<A: Scene, B: Scene>(
|
|
|
|
|
|
|
|
(button_a, state_a): (UiButton, A),
|
|
|
|
|
|
|
|
(button_b, state_b): (UiButton, B),
|
|
|
|
|
|
|
|
) -> impl Scene {
|
|
|
|
bsn! {
|
|
|
|
bsn! {
|
|
|
|
@FeathersButton
|
|
|
|
@FeathersButton
|
|
|
|
Hovered
|
|
|
|
Hovered
|
|
|
|
@ -289,21 +312,33 @@ fn the_ui() -> impl Scene {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn debug_ui() -> impl Scene {
|
|
|
|
fn debug_ui() -> impl Scene {
|
|
|
|
|
|
|
|
fn toggle_debug_ui(
|
|
|
|
|
|
|
|
_: On<Pointer<Click>>,
|
|
|
|
|
|
|
|
mut next: ResMut<NextState<DebugUi>>,
|
|
|
|
|
|
|
|
curr: Res<State<DebugUi>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
next.set(match curr.get() {
|
|
|
|
|
|
|
|
DebugUi::Hidden => DebugUi::Visible,
|
|
|
|
|
|
|
|
DebugUi::Visible => DebugUi::Hidden,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
bsn! {
|
|
|
|
bsn! {
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
display: Display::Flex,
|
|
|
|
display: Display::Flex,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: Toggle visibility when debugging disabled
|
|
|
|
|
|
|
|
pane()
|
|
|
|
pane()
|
|
|
|
Transform
|
|
|
|
Transform
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
pane_header()
|
|
|
|
pane_header()
|
|
|
|
|
|
|
|
on(toggle_debug_ui)
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
Text("Debug Info") ThemedText,
|
|
|
|
Text("Debug Info") ThemedText,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
pane_body()
|
|
|
|
pane_body()
|
|
|
|
|
|
|
|
DebugUi::Visible
|
|
|
|
|
|
|
|
ToggleStateVisible
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
subpane()
|
|
|
|
subpane()
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
@ -387,6 +422,17 @@ fn primary_ui() -> impl Scene {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn toggle_main_ui(
|
|
|
|
|
|
|
|
_: On<Pointer<Click>>,
|
|
|
|
|
|
|
|
mut next: ResMut<NextState<MainUi>>,
|
|
|
|
|
|
|
|
curr: Res<State<MainUi>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
next.set(match curr.get() {
|
|
|
|
|
|
|
|
MainUi::Hidden => MainUi::Visible,
|
|
|
|
|
|
|
|
MainUi::Visible => MainUi::Hidden,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bsn! {
|
|
|
|
bsn! {
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
display: Display::Flex,
|
|
|
|
display: Display::Flex,
|
|
|
|
@ -397,10 +443,14 @@ fn primary_ui() -> impl Scene {
|
|
|
|
pane()
|
|
|
|
pane()
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
pane_header()
|
|
|
|
pane_header()
|
|
|
|
|
|
|
|
on(toggle_main_ui)
|
|
|
|
|
|
|
|
// todo: toggle main ui
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
Text("Conways Game of Life With Sound") ThemedText,
|
|
|
|
Text("Conways Game of Life With Sound") ThemedText,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
pane_body()
|
|
|
|
pane_body()
|
|
|
|
|
|
|
|
MainUi::Visible
|
|
|
|
|
|
|
|
ToggleStateVisible
|
|
|
|
Children [
|
|
|
|
Children [
|
|
|
|
subpane()
|
|
|
|
subpane()
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
@ -1269,7 +1319,7 @@ struct ToggleStateVisible;
|
|
|
|
|
|
|
|
|
|
|
|
fn toggle_state_visible<S: States + Component>(
|
|
|
|
fn toggle_state_visible<S: States + Component>(
|
|
|
|
mut q: Query<(&S, &mut Node), With<ToggleStateVisible>>,
|
|
|
|
mut q: Query<(&S, &mut Node), With<ToggleStateVisible>>,
|
|
|
|
c: Res<State<S>>
|
|
|
|
c: Res<State<S>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
q.iter_mut().for_each(|(s, mut node)| {
|
|
|
|
q.iter_mut().for_each(|(s, mut node)| {
|
|
|
|
node.display = if s == c.get() {
|
|
|
|
node.display = if s == c.get() {
|
|
|
|
|