mod event; mod system; mod window; mod windows; pub use event::*; pub use system::*; pub use window::*; pub use windows::*; pub mod prelude { #[doc(hidden)] pub use crate::{ CursorEntered, CursorLeft, CursorMoved, FileDragAndDrop, ReceivedCharacter, Window, WindowDescriptor, WindowMoved, Windows, }; } use bevy_app::{prelude::*, Events}; pub struct WindowPlugin { pub add_primary_window: bool, pub exit_on_close: bool, } impl Default for WindowPlugin { fn default() -> Self { WindowPlugin { add_primary_window: true, exit_on_close: true, } } } impl Plugin for WindowPlugin { fn build(&self, app: &mut App) { app.add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .add_event::() .init_resource::(); if self.add_primary_window { let window_descriptor = app .world .get_resource::() .map(|descriptor| (*descriptor).clone()) .unwrap_or_else(WindowDescriptor::default); let mut create_window_event = app .world .get_resource_mut::>() .unwrap(); create_window_event.send(CreateWindow { id: WindowId::primary(), descriptor: window_descriptor, }); } if self.exit_on_close { app.add_system(exit_on_window_close_system); } } }