use bevy::{ input::{keyboard::KeyboardInput, ButtonState}, prelude::*, window::PrimaryWindow, }; use monologue_trees::{debug::*, ui::*}; fn main() { App::new() .add_plugins(( DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "UI WTF".into(), resolution: (640., 480.).into(), ..default() }), ..default() }), GameUiPlugin, )) .init_resource::() .add_systems(Startup, init_ui) .add_systems(Update, (cursors, container)) .run(); } const CURSORS: [CursorIcon; 35] = [ CursorIcon::Default, CursorIcon::Crosshair, CursorIcon::Hand, CursorIcon::Arrow, CursorIcon::Move, CursorIcon::Text, CursorIcon::Wait, CursorIcon::Help, CursorIcon::Progress, CursorIcon::NotAllowed, CursorIcon::ContextMenu, CursorIcon::Cell, CursorIcon::VerticalText, CursorIcon::Alias, CursorIcon::Copy, CursorIcon::NoDrop, CursorIcon::Grab, CursorIcon::Grabbing, CursorIcon::AllScroll, CursorIcon::ZoomIn, CursorIcon::ZoomOut, CursorIcon::EResize, CursorIcon::NResize, CursorIcon::NeResize, CursorIcon::NwResize, CursorIcon::SResize, CursorIcon::SeResize, CursorIcon::SwResize, CursorIcon::WResize, CursorIcon::EwResize, CursorIcon::NsResize, CursorIcon::NeswResize, CursorIcon::NwseResize, CursorIcon::ColResize, CursorIcon::RowResize, ]; #[derive(Debug, Component, Resource, Default)] struct Icon(CursorIcon); fn init_ui(mut commands: Commands) { commands.spawn(( Camera2dBundle { ..default() }, UiCameraConfig { show_ui: true }, )); commands .spawn((GameUiNav, NodeBundle { ..default() })) .with_children(|parent| { parent .spawn(( GameUiTab, Name::new("Grow/Shrink Container"), NodeBundle { ..default() }, )) .with_children(|parent| { parent.spawn((Container, GameUiSet, NodeBundle { ..default() })); }); parent .spawn(( GameUiTab, Name::new("Cursor Icons"), NodeBundle { background_color: BackgroundColor(Color::BLACK), ..default() }, )) .with_children(|parent| { parent .spawn(( GameUiTab, NodeBundle { background_color: BackgroundColor(Color::BLACK), ..default() }, )) .with_children(|parent| { CURSORS.iter().for_each(|&icon| { parent.spawn(( GameUiButton, Name::new(format!("{:?}", icon)), NodeBundle { ..default() }, Icon(icon), )); }); }); }); }); } fn cursors( events: Query<(&Interaction, &Icon), (Changed, With