diff --git a/Cargo.lock b/Cargo.lock index 8a690d1..4435e5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1866,9 +1866,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quick-xml" -version = "0.34.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f24d770aeca0eacb81ac29dfbc55ebcc09312fdd1f8bbecdc7e4a84e000e3b4" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" dependencies = [ "memchr", ] @@ -2591,9 +2591,9 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wayland-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90e11ce2ca99c97b940ee83edbae9da2d56a08f9ea8158550fd77fa31722993" +checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6" dependencies = [ "cc", "downcast-rs", @@ -2605,9 +2605,9 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.5" +version = "0.31.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e321577a0a165911bdcfb39cf029302479d7527b517ee58ab0f6ad09edf0943" +checksum = "e3f45d1222915ef1fd2057220c1d9d9624b7654443ea35c3877f7a52bd0a5a2d" dependencies = [ "bitflags 2.6.0", "rustix", @@ -2628,9 +2628,9 @@ dependencies = [ [[package]] name = "wayland-cursor" -version = "0.31.5" +version = "0.31.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef9489a8df197ebf3a8ce8a7a7f0a2320035c3743f3c1bd0bdbccf07ce64f95" +checksum = "3a94697e66e76c85923b0d28a0c251e8f0666f58fc47d316c0f4da6da75d37cb" dependencies = [ "rustix", "wayland-client", @@ -2639,9 +2639,9 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.32.3" +version = "0.32.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62989625a776e827cc0f15d41444a3cea5205b963c3a25be48ae1b52d6b4daaa" +checksum = "2b5755d77ae9040bb872a25026555ce4cb0ae75fd923e90d25fba07d81057de0" dependencies = [ "bitflags 2.6.0", "wayland-backend", @@ -2651,9 +2651,9 @@ dependencies = [ [[package]] name = "wayland-protocols-plasma" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79f2d57c7fcc6ab4d602adba364bf59a5c24de57bd194486bf9b8360e06bfc4" +checksum = "8a0a41a6875e585172495f7a96dfa42ca7e0213868f4f15c313f7c33221a7eff" dependencies = [ "bitflags 2.6.0", "wayland-backend", @@ -2664,9 +2664,9 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd993de54a40a40fbe5601d9f1fbcaef0aebcc5fda447d7dc8f6dcbaae4f8953" +checksum = "dad87b5fd1b1d3ca2f792df8f686a2a11e3fe1077b71096f7a175ab699f89109" dependencies = [ "bitflags 2.6.0", "wayland-backend", @@ -2677,9 +2677,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.4" +version = "0.31.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7b56f89937f1cf2ee1f1259cf2936a17a1f45d8f0aa1019fae6d470d304cfa6" +checksum = "597f2001b2e5fc1121e3d5b9791d3e78f05ba6bfa4641053846248e3a13661c3" dependencies = [ "proc-macro2", "quick-xml", @@ -2688,9 +2688,9 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.31.4" +version = "0.31.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43676fe2daf68754ecf1d72026e4e6c15483198b5d24e888b74d3f22f887a148" +checksum = "efa8ac0d8e8ed3e3b5c9fc92c7881406a268e11555abe36493efabe649a29e09" dependencies = [ "dlib", "log", diff --git a/Cargo.toml b/Cargo.toml index 54ad692..25fdede 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ android_game_activity = ["winit/android-game-activity"] [dependencies] image = { version = "0.25.2" } pollster = "0.3" -winit = { version = "0.30", features = ["rwh_06"] } +winit = { version = "0.30.5", features = ["rwh_06"] } wgpu = { version = "22.1.0" } bytemuck = { version = "1.16", features = ["derive"] } eyre = "0.6" diff --git a/src/header.rs b/src/header.rs index 46effc9..fc7e4f5 100644 --- a/src/header.rs +++ b/src/header.rs @@ -561,7 +561,18 @@ pub struct Instance { /// Allows all events to be fetched directly, making it easier to add custom additions to the engine. pub trait Signal: Any { - /// This is ran before any of the render events, it's generally used to capture raw input. + /// This is ran as soon as the engine is properly initialized and all components are ready + #[allow(clippy::too_many_arguments)] + fn init( + &mut self, + _renderer: &mut crate::Renderer, + _window: &crate::Window, + _objects: &mut ObjectStorage, + _camera: &mut crate::CameraContainer, + ) { + } + + /// This is ran at the device events when available #[allow(clippy::too_many_arguments)] fn device_events( &mut self, @@ -574,6 +585,19 @@ pub trait Signal: Any { ) { } + /// This is ran at the window events when available + #[allow(clippy::too_many_arguments)] + fn window_events( + &mut self, + _renderer: &mut crate::Renderer, + _window: &crate::Window, + _objects: &mut ObjectStorage, + _events: &crate::WindowEvent, + _input: &crate::InputHelper, + _camera: &mut crate::CameraContainer, + ) { + } + /// ran before the frame is rendered #[allow(clippy::too_many_arguments)] fn frame( diff --git a/src/window.rs b/src/window.rs index 654f2f3..7c899bd 100644 --- a/src/window.rs +++ b/src/window.rs @@ -152,6 +152,8 @@ impl ApplicationHandler for Engine { ref mut window, ref mut renderer, ref mut objects, + ref mut signals, + ref mut camera, .. } = self; @@ -216,6 +218,10 @@ impl ApplicationHandler for Engine { window.set_cursor(self.window.default_attributes.cursor.clone()); window.set_fullscreen(self.window.default_attributes.fullscreen.clone()); } + + signals.events.iter_mut().for_each(|i| { + i.1.init(renderer, &self.window, objects, camera); + }); } } @@ -258,6 +264,10 @@ impl ApplicationHandler for Engine { .. } = self; + signals.events.iter_mut().for_each(|i| { + i.1.window_events(renderer, window, objects, &event, input_events, camera); + }); + let mut _device_event: winit::event::DeviceEvent = DeviceEvent::MouseMotion { delta: (0.0, 0.0) };