use bevy::ecs::system::EntityCommands; use bevy::prelude::*; use bevy_ui_navigation::prelude::{ DefaultNavigationPlugins, FocusState, Focusable, NavRequestSystem, NavigationDsl, }; use bevy_ui_navigation::systems::InputMapping; use cuicui_chirp::{parse_dsl_impl, ChirpBundle}; use cuicui_layout::{DslBundle, LayoutRootCamera}; use cuicui_layout_bevy_ui::UiDsl; #[derive(Default, Deref, DerefMut)] struct UltimateMenuDsl { #[deref] inner: NavigationDsl, } #[parse_dsl_impl(delegate = inner)] impl UltimateMenuDsl {} impl DslBundle for UltimateMenuDsl { fn insert(&mut self, cmds: &mut EntityCommands) { self.inner.insert(cmds); } } /// THE ULTIMATE MENU DEMONSTRATION /// /// This is an unrealistic menu demonstrating tabbed navigation, focus memory /// and navigation hierarchy traversal. It is similar to your classical RPG /// menu, with the significant difference that **all tabs are shown at the same /// time on screen** rather than hidden and shown as the tabs are selected. /// /// We use `cuicui_chirp` for this demo, because using bevy_ui's default spawning /// mechanism is unrealistic for a complex UI. see the file `assets/ultimate_menu.chirp` /// /// Use `Q` and `E` to navigate tabs, use `WASD` for moving within containers, /// `ENTER` and `BACKSPACE` for going down/up the hierarchy. /// /// Navigation also works with controller fn main() { let primary_window = Some(Window { resolution: (1280., 720.).into(), ..default() }); App::new() .add_plugins(( DefaultPlugins.set(WindowPlugin { primary_window, ..default() }), DefaultNavigationPlugins, cuicui_chirp::loader::Plugin::new::(), cuicui_layout_bevy_ui::Plugin, )) .add_systems(Startup, setup) // IMPORTANT: setting the button appearance update system after the // NavRequestSystem makes everything much snappier, highly recommended. .add_systems( Update, ( block_some_focusables.before(NavRequestSystem), button_system.after(NavRequestSystem), ), ) .run(); } fn block_some_focusables( mut focusables: Query<&mut Focusable>, mut blocked_index: Local, time: Res