Update callback builder
This commit is contained in:
parent
8b7f68232e
commit
0731089afe
1 changed files with 12 additions and 8 deletions
|
@ -1,7 +1,8 @@
|
|||
use std::any::Any;
|
||||
|
||||
use crate::gui_handler::gui_handler::GuiHandler;
|
||||
use anyhow::Result;
|
||||
use ecs::World;
|
||||
use ecs::Commands;
|
||||
|
||||
use super::ControllerButton;
|
||||
|
||||
|
@ -27,12 +28,12 @@ macro_rules! callbacks {
|
|||
};
|
||||
}
|
||||
|
||||
callbacks!(ClickCallbacks, Fn(&mut World) -> Result<()> + Send + Sync);
|
||||
callbacks!(SelectCallbacks, Fn(&mut World, bool) -> anyhow::Result<()> + Send + Sync);
|
||||
callbacks!(CustomCallbacks, Fn(&mut World, ControllerButton) -> anyhow::Result<bool> + Send + Sync);
|
||||
callbacks!(ClickCallbacks, Fn(&mut Commands, &mut GuiHandler) -> Result<()> + Send + Sync);
|
||||
callbacks!(SelectCallbacks, Fn(&mut Commands, &mut GuiHandler, bool) -> anyhow::Result<()> + Send + Sync);
|
||||
callbacks!(CustomCallbacks, Fn(&mut Commands, &mut GuiHandler, ControllerButton) -> anyhow::Result<bool> + Send + Sync);
|
||||
callbacks!(
|
||||
VecCallbacks,
|
||||
Fn(&mut World, &dyn Any) -> Result<()> + Send + Sync
|
||||
Fn(&mut Commands, &mut GuiHandler, &dyn Any) -> Result<()> + Send + Sync
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -40,8 +41,8 @@ mod test {
|
|||
use super::*;
|
||||
use anyhow::Result;
|
||||
|
||||
fn normal_fn() -> impl Fn(&mut World) -> Result<()> + Send + Sync {
|
||||
|_| Ok(())
|
||||
fn normal_fn() -> impl Fn(&mut Commands, &mut GuiHandler) -> Result<()> + Send + Sync {
|
||||
|_, _| Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -51,7 +52,10 @@ mod test {
|
|||
impl Test {
|
||||
fn set_click_callbacks(
|
||||
&self,
|
||||
_callbacks: Vec<(&str, Box<dyn Fn(&mut World) -> Result<()> + Send + Sync>)>,
|
||||
_callbacks: Vec<(
|
||||
&str,
|
||||
Box<dyn Fn(&mut Commands, &mut GuiHandler) -> Result<()> + Send + Sync>,
|
||||
)>,
|
||||
) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue