diff --git a/life/Cargo.lock b/life/Cargo.lock index a23cc6e..0cd2a6a 100644 --- a/life/Cargo.lock +++ b/life/Cargo.lock @@ -3324,6 +3324,14 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "life" +version = "0.1.0" +dependencies = [ + "bevy", + "engine", +] + [[package]] name = "linebender_resource_handle" version = "0.1.1" @@ -4212,14 +4220,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" -[[package]] -name = "prototypes" -version = "0.1.0" -dependencies = [ - "bevy", - "engine", -] - [[package]] name = "pxfm" version = "0.1.29" diff --git a/life/Cargo.toml b/life/Cargo.toml index 44b5959..623d054 100644 --- a/life/Cargo.toml +++ b/life/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "prototypes" +name = "life" version = "0.1.0" edition = "2024" diff --git a/life/src/actions.rs b/life/src/actions.rs index 31e4a49..6a57e83 100644 --- a/life/src/actions.rs +++ b/life/src/actions.rs @@ -15,8 +15,7 @@ impl Plugin for GameActionsPlugin { .bind(ZoomAction::Zoom, [Binding::Scroll]) .bind(ZoomAction::ZoomIn, [Binding::Key(KeyCode::Equal)]) .bind(ZoomAction::ZoomOut, [Binding::Key(KeyCode::Minus)]), - ActionsPlugin::::new() - .bind(Action::Quit, [Binding::Key(KeyCode::Escape)]), + ActionsPlugin::::new().bind(Action::Quit, [Binding::Key(KeyCode::Escape)]), )); } } @@ -99,7 +98,7 @@ pub(crate) enum ZoomAction { #[action_handler(ZoomAction::zoom_out)] ZoomOut, #[default] - None + None, } #[derive(Copy, Clone, Eq, PartialEq, Hash, GameAction, Default)] diff --git a/life/src/main.rs b/life/src/main.rs index 1222f5d..7c92ab1 100644 --- a/life/src/main.rs +++ b/life/src/main.rs @@ -1,13 +1,14 @@ // TODO: // * Fix randomly audio not working // * Lock down system scheduling/run_if conditions -// * Fix tiling repeating -// * Negative coordinates should not mirror // * UI widget explaining rules/hotkeys // * Show shadow of piece (same tile, just with alpha transparency) // * Start with an interesting pattern // * UI minimize widgets +// * Add "follow action" that adjusts camera to zoom in/out/move to see everything // * Make click and drag feel better +// * Add arrow keys to move around +// * web/wasm build #![allow(clippy::complexity)] // Only because of FromTemplat macros unfortunately... #![allow(dead_code)] @@ -37,6 +38,8 @@ fn main() { .insert_resource(UiTheme(create_light_theme())) .init_state::() .init_state::() + .init_state::() + .init_state::() .add_message::() .add_systems( Startup, @@ -92,9 +95,12 @@ fn main() { .add_systems( Update, ( - toggle_state_visible::.run_if(state_changed::), + toggle_state_visible:: + .run_if(state_changed::), manage_interactive::, toggle_state_visible::.run_if(state_changed::), + toggle_state_visible::.run_if(state_changed::), + toggle_state_visible::.run_if(state_changed::), manage_interactive::, update_note_interactivity, ), @@ -118,6 +124,20 @@ enum DebugInfo { 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)] enum AudioPlayback { #[default] @@ -200,7 +220,10 @@ fn ui_button(button: UiButton) -> impl Scene { } } -fn ui_toggle_button((button_a, state_a): (UiButton, A), (button_b, state_b): (UiButton, B)) -> impl Scene { +fn ui_toggle_button( + (button_a, state_a): (UiButton, A), + (button_b, state_b): (UiButton, B), +) -> impl Scene { bsn! { @FeathersButton Hovered @@ -289,21 +312,33 @@ fn the_ui() -> impl Scene { } fn debug_ui() -> impl Scene { + fn toggle_debug_ui( + _: On>, + mut next: ResMut>, + curr: Res>, + ) { + next.set(match curr.get() { + DebugUi::Hidden => DebugUi::Visible, + DebugUi::Visible => DebugUi::Hidden, + }); + } bsn! { Node { justify_self: JustifySelf::End, display: Display::Flex, flex_direction: FlexDirection::Column, } - // TODO: Toggle visibility when debugging disabled pane() Transform Children [ pane_header() + on(toggle_debug_ui) Children [ Text("Debug Info") ThemedText, ], pane_body() + DebugUi::Visible + ToggleStateVisible Children [ subpane() Node { @@ -387,6 +422,17 @@ fn primary_ui() -> impl Scene { } } + fn toggle_main_ui( + _: On>, + mut next: ResMut>, + curr: Res>, + ) { + next.set(match curr.get() { + MainUi::Hidden => MainUi::Visible, + MainUi::Visible => MainUi::Hidden, + }); + } + bsn! { Node { display: Display::Flex, @@ -397,10 +443,14 @@ fn primary_ui() -> impl Scene { pane() Children [ pane_header() + on(toggle_main_ui) + // todo: toggle main ui Children [ Text("Conways Game of Life With Sound") ThemedText, ], pane_body() + MainUi::Visible + ToggleStateVisible Children [ subpane() Node { @@ -1269,7 +1319,7 @@ struct ToggleStateVisible; fn toggle_state_visible( mut q: Query<(&S, &mut Node), With>, - c: Res> + c: Res>, ) { q.iter_mut().for_each(|(s, mut node)| { node.display = if s == c.get() {