pub fn dashboard_variables_setup(
    mut commands: Commands,
    all_vars_res: ResMut<AllDashRes>,
    all_vars_comp: ResMut<AllDashComp>,

    mut comp_query_set: QuerySet<(QueryState<(Entity, &MyComponent), With<DashComponent>>,)>,
    globals: Res<Globals>,
    other_globals: Res<OtherGlobals>,
    mut materials: ResMut<Assets<ColorMaterial>>,
    mut spawn_res_fields_event: EventWriter<SpawnLabels>,
    // mut spawn_comp_fields_event: EventWriter<SpawnComponentLabels>,
    // ui_res_query: Query<Entity, With<UiBoardResources>>,
    // ui_comp_query: Query<Entity, With<UiBoardComponents>>,
) {
    let ui_board = commands
        .spawn_bundle(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(31.0), Val::Percent(95.0)),
                // border: Rect::all(Val::Px(5.0)),
                position: Rect {
                    // top: Val::Px(15.0),
                    left: Val::Percent(2.0),
                    bottom: Val::Percent(2.5),
                    ..Default::default()
                },
                align_self: bevy::ui::AlignSelf::FlexStart,
                ..Default::default()
            },
            material: materials.add(Color::rgba(0.65, 0.25, 0.65, 0.45).into()),
            ..Default::default()
        })
        .id();

    let ui_res_entity = commands
        .spawn_bundle(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(95.0), Val::Percent(45.0)),
                // border: Rect::all(Val::Px(5.0)),
                position: Rect {
                    // top: Val::Px(30.0),
                    left: Val::Percent(2.5),
                    bottom: Val::Percent(2.5),
                    // bottom: Val::Px(30.0),
                    ..Default::default()
                },
                align_self: bevy::ui::AlignSelf::FlexStart,
                position_type: PositionType::Absolute,
                ..Default::default()
            },
            material: materials.add(Color::rgba(0.65, 0.1, 0.65, 0.5).into()),
            ..Default::default()
        })
        .insert(UiBoardResources)
        .id();

    commands.entity(ui_board).push_children(&[ui_res_entity]);

    let ui_comp_entity = commands
        .spawn_bundle(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(95.0), Val::Percent(45.0)),
                // border: Rect::all(Val::Px(5.0)),
                position: Rect {
                    // top: Val::Px(15.0),
                    // right: Val::Px(15.0),
                    left: Val::Percent(2.5),
                    top: Val::Px(15.0),
                    ..Default::default()
                },
                align_self: bevy::ui::AlignSelf::FlexEnd,
                position_type: PositionType::Absolute,
                ..Default::default()
            },
            material: materials.add(Color::rgba(0.65, 0.8, 0.75, 0.5).into()),
            ..Default::default()
        })
        .insert(UiBoardComponents)
        .id();

    commands.entity(ui_board).push_children(&[ui_comp_entity]);
    // commands
    //     .entity(ui_board)
    //     .push_children(&[ui_res_entity, ui_comp_entity]);

    //////////////////////////////// resources /////////////////////////
    let all_vars_resources = all_vars_res
        .as_ref()
        .set_values_from_resources(globals.clone(), other_globals.clone());

    let mut struct_field_vec: Vec<(String, FieldString)> = Vec::new();
    //
    for (i, value) in all_vars_resources.iter_fields().enumerate() {
        //
        let mut struct_name = all_vars_resources.name_at(i).unwrap().to_string();
        //
        // procedural macro to generate the list of Dashboard implemented types
        let mut v: Vec<(FieldName, FieldString)> =
            downcast_struct![value, GlobalsNbr, OtherGlobalsNbr];
        v = v
            .iter_mut()
            .map(|(field_name, val_string)| {
                //
                let mut struct_name_temp = struct_name.clone();
                //
                struct_name_temp.push('.');
                struct_name_temp.push_str(field_name);
                //
                (struct_name_temp.to_owned(), val_string.clone())
            })
            .collect::<Vec<(FieldName, FieldString)>>();
        // format!("{:.5}", value.to_string());
        struct_field_vec.append(&mut v);
    }
    spawn_res_fields_event.send(SpawnLabels(struct_field_vec.clone(), ui_res_entity));
    //////////////////////////////// resources /////////////////////////

    //////////////////////////////// components ////////////////////////
    let comp_query = comp_query_set.q0();
    let mut comp_iter = comp_query.iter();
    let (_comp_entity, my_component1) = comp_iter.next().unwrap();
    let (_comp_entity, my_component2) = comp_iter.next().unwrap();
    // let my_component_vec = comp_query_set.q0().iter().map(|(_, comp)| comp).collect::<Vec<_>>();
    let all_vars_components = all_vars_comp
        .as_ref()
        .set_values_from_components(my_component1.clone(), my_component2.clone());

    let mut struct_field_vec: Vec<(String, FieldString)> = Vec::new();
    //
    for (i, value) in all_vars_components.iter_fields().enumerate() {
        //
        let mut struct_name = all_vars_components.name_at(i).unwrap().to_string();
        //
        // procedural macro to generate the list of Dashboard implemented types
        let mut v: Vec<(FieldName, FieldString)> = downcast_struct![value, MyComponentNbr];
        v = v
            .iter_mut()
            .map(|(field_name, val_f64)| {
                //
                let mut struct_name_temp = struct_name.clone();
                //
                struct_name_temp.push('.');
                struct_name_temp.push_str(field_name);
                //
                (struct_name_temp.to_owned(), val_f64.clone())
            })
            .collect::<Vec<(FieldName, FieldString)>>();
        struct_field_vec.append(&mut v);
    }
    spawn_res_fields_event.send(SpawnLabels(struct_field_vec, ui_comp_entity));
    //////////////////////////////// components /////////////////////////
}
// procedural macro here for resources (globals and other_globals)
procedural macro here for resources (globals and other_globals)
procedural macro here for resources ( globals and other_globals )
pub fn dashboard_variables_setup(
    mut commands: Commands,
    all_vars_res: ResMut<AllDashRes>,
    all_vars_comp: ResMut<AllDashComp>,
    mut comp_query_set: QuerySet<(QueryState<(Entity, &MyComponent), With<DashComponent>>,)>,
    globals: Res<Globals>,
    other_globals: Res<OtherGlobals>,
    mut materials: ResMut<Assets<ColorMaterial>>,
    mut spawn_res_fields_event: EventWriter<SpawnLabels>,
    // mut spawn_comp_fields_event: EventWriter<SpawnComponentLabels>,
    // ui_res_query: Query<Entity, With<UiBoardResources>>,
    // ui_comp_query: Query<Entity, With<UiBoardComponents>>,
) {
    let ui_board = commands
        .spawn_bundle(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(31.0), Val::Percent(95.0)),
                // border: Rect::all(Val::Px(5.0)),
                position: Rect {
                    // top: Val::Px(15.0),
                    left: Val::Percent(2.0),
                    bottom: Val::Percent(2.5),
                    ..Default::default()
                },
                align_self: bevy::ui::AlignSelf::FlexStart,
                ..Default::default()
            },
            material: materials.add(Color::rgba(0.65, 0.25, 0.65, 0.45).into()),
            ..Default::default()
        })
        .id();
    let ui_res_entity = commands
        .spawn_bundle(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(95.0), Val::Percent(45.0)),
                // border: Rect::all(Val::Px(5.0)),
                position: Rect {
                    // top: Val::Px(30.0),
                    left: Val::Percent(2.5),
                    bottom: Val::Percent(2.5),
                    // bottom: Val::Px(30.0),
                    ..Default::default()
                },
                align_self: bevy::ui::AlignSelf::FlexStart,
                position_type: PositionType::Absolute,
                ..Default::default()
            },
            material: materials.add(Color::rgba(0.65, 0.1, 0.65, 0.5).into()),
            ..Default::default()
        })
        .insert(UiBoardResources)
        .id();
    commands.entity(ui_board).push_children(&[ui_res_entity]);
    let ui_comp_entity = commands
        .spawn_bundle(NodeBundle {
            style: Style {
                size: Size::new(Val::Percent(95.0), Val::Percent(45.0)),
                // border: Rect::all(Val::Px(5.0)),
                position: Rect {
                    // top: Val::Px(15.0),
                    // right: Val::Px(15.0),
                    left: Val::Percent(2.5),
                    top: Val::Px(15.0),
                    ..Default::default()
                },
                align_self: bevy::ui::AlignSelf::FlexEnd,
                position_type: PositionType::Absolute,
                ..Default::default()
            },
            material: materials.add(Color::rgba(0.65, 0.8, 0.75, 0.5).into()),
            ..Default::default()
        })
        .insert(UiBoardComponents)
        .id();
    commands.entity(ui_board).push_children(&[ui_comp_entity]);
    // commands
    //     .entity(ui_board)
    //     .push_children(&[ui_res_entity, ui_comp_entity]);
    //////////////////////////////// resources /////////////////////////
    let all_vars_resources = all_vars_res
        .as_ref()
        .set_values_from_resources(globals.clone(), other_globals.clone());
    let mut struct_field_vec: Vec<(String, FieldString)> = Vec::new();
    //
    for (i, value) in all_vars_resources.iter_fields().enumerate() {
        //
        let mut struct_name = all_vars_resources.name_at(i).unwrap().to_string();
        //
        // procedural macro to generate the list of Dashboard implemented types
        let mut v: Vec<(FieldName, FieldString)> =
            downcast_struct![value, GlobalsNbr, OtherGlobalsNbr];
        v = v
            .iter_mut()
            .map(|(field_name, val_string)| {
                //
                let mut struct_name_temp = struct_name.clone();
                //
                struct_name_temp.push('.');
                struct_name_temp.push_str(field_name);
                //
                (struct_name_temp.to_owned(), val_string.clone())
            })
            .collect::<Vec<(FieldName, FieldString)>>();
        // format!("{:.5}", value.to_string());
        struct_field_vec.append(&mut v);
    }
    spawn_res_fields_event.send(SpawnLabels(struct_field_vec.clone(), ui_res_entity));
    //////////////////////////////// resources /////////////////////////
    //////////////////////////////// components ////////////////////////
    let comp_query = comp_query_set.q0();
    let mut comp_iter = comp_query.iter();
    let (_comp_entity, my_component1) = comp_iter.next().unwrap();
    let (_comp_entity, my_component2) = comp_iter.next().unwrap();
    // let my_component_vec = comp_query_set.q0().iter().map(|(_, comp)| comp).collect::<Vec<_>>();
    let all_vars_components = all_vars_comp
        .as_ref()
        .set_values_from_components(my_component1.clone(), my_component2.clone());
    let mut struct_field_vec: Vec<(String, FieldString)> = Vec::new();
    //
    for (i, value) in all_vars_components.iter_fields().enumerate() {
        //
        let mut struct_name = all_vars_components.name_at(i).unwrap().to_string();
        //
        // procedural macro to generate the list of Dashboard implemented types
        let mut v: Vec<(FieldName, FieldString)> = downcast_struct![value, MyComponentNbr];
        v = v
            .iter_mut()
            .map(|(field_name, val_f64)| {
                //
                let mut struct_name_temp = struct_name.clone();
                //
                struct_name_temp.push('.');
                struct_name_temp.push_str(field_name);
                //
                (struct_name_temp.to_owned(), val_f64.clone())
            })
            .collect::<Vec<(FieldName, FieldString)>>();
        struct_field_vec.append(&mut v);
    }
    spawn_res_fields_event.send(SpawnLabels(struct_field_vec, ui_comp_entity));
    //////////////////////////////// components /////////////////////////
}
pub fn dashboard_variables_setup ( mut commands : Commands , all_vars_res : ResMut < AllDashRes > , all_vars_comp : ResMut < AllDashComp > , mut comp_query_set : QuerySet < ( QueryState < ( Entity , & MyComponent ) , With < DashComponent > > , ) > , globals : Res < Globals > , other_globals : Res < OtherGlobals > , mut materials : ResMut < Assets < ColorMaterial > > , mut spawn_res_fields_event : EventWriter < SpawnLabels > , // mut spawn_comp_fields_event: EventWriter<SpawnComponentLabels>, // ui_res_query: Query<Entity, With<UiBoardResources>>, // ui_comp_query: Query<Entity, With<UiBoardComponents>>, ) { let ui_board = commands . spawn_bundle ( NodeBundle { style : Style { size : Size :: new ( Val :: Percent ( 31.0 ) , Val :: Percent ( 95.0 ) ) , // border: Rect::all(Val::Px(5.0)), position : Rect { // top: Val::Px(15.0), left : Val :: Percent ( 2.0 ) , bottom : Val :: Percent ( 2.5 ) , .. Default :: default ( ) } , align_self : bevy :: ui :: AlignSelf :: FlexStart , .. Default :: default ( ) } , material : materials . add ( Color :: rgba ( 0.65 , 0.25 , 0.65 , 0.45 ) . into ( ) ) , .. Default :: default ( ) } ) . id ( ) ; let ui_res_entity = commands . spawn_bundle ( NodeBundle { style : Style { size : Size :: new ( Val :: Percent ( 95.0 ) , Val :: Percent ( 45.0 ) ) , // border: Rect::all(Val::Px(5.0)), position : Rect { // top: Val::Px(30.0), left : Val :: Percent ( 2.5 ) , bottom : Val :: Percent ( 2.5 ) , // bottom: Val::Px(30.0), .. Default :: default ( ) } , align_self : bevy :: ui :: AlignSelf :: FlexStart , position_type : PositionType :: Absolute , .. Default :: default ( ) } , material : materials . add ( Color :: rgba ( 0.65 , 0.1 , 0.65 , 0.5 ) . into ( ) ) , .. Default :: default ( ) } ) . insert ( UiBoardResources ) . id ( ) ; commands . entity ( ui_board ) . push_children ( & [ ui_res_entity ] ) ; let ui_comp_entity = commands . spawn_bundle ( NodeBundle { style : Style { size : Size :: new ( Val :: Percent ( 95.0 ) , Val :: Percent ( 45.0 ) ) , // border: Rect::all(Val::Px(5.0)), position : Rect { // top: Val::Px(15.0), // right: Val::Px(15.0), left : Val :: Percent ( 2.5 ) , top : Val :: Px ( 15.0 ) , .. Default :: default ( ) } , align_self : bevy :: ui :: AlignSelf :: FlexEnd , position_type : PositionType :: Absolute , .. Default :: default ( ) } , material : materials . add ( Color :: rgba ( 0.65 , 0.8 , 0.75 , 0.5 ) . into ( ) ) , .. Default :: default ( ) } ) . insert ( UiBoardComponents ) . id ( ) ; commands . entity ( ui_board ) . push_children ( & [ ui_comp_entity ] ) ; // commands //     .entity(ui_board) //     .push_children(&[ui_res_entity, ui_comp_entity]); //////////////////////////////// resources ///////////////////////// let all_vars_resources = all_vars_res . as_ref ( ) . set_values_from_resources ( globals . clone ( ) , other_globals . clone ( ) ) ; let mut struct_field_vec : Vec < ( String , FieldString ) > = Vec :: new ( ) ; // for ( i , value ) in all_vars_resources . iter_fields ( ) . enumerate ( ) { // let mut struct_name = all_vars_resources . name_at ( i ) . unwrap ( ) . to_string ( ) ; // // procedural macro to generate the list of Dashboard implemented types let mut v : Vec < ( FieldName , FieldString ) > = downcast_struct ! [ value GlobalsNbr OtherGlobalsNbr ] ; v = v . iter_mut ( ) . map ( | ( field_name , val_string ) | { // let mut struct_name_temp = struct_name . clone ( ) ; // struct_name_temp . push ( '.' ) ; struct_name_temp . push_str ( field_name ) ; // ( struct_name_temp . to_owned ( ) , val_string . clone ( ) ) } ) . collect :: < Vec < ( FieldName , FieldString ) > > ( ) ; // format!("{:.5}", value.to_string()); struct_field_vec . append ( & mut v ) ; } spawn_res_fields_event . send ( SpawnLabels ( struct_field_vec . clone ( ) , ui_res_entity ) ) ; //////////////////////////////// resources ///////////////////////// //////////////////////////////// components //////////////////////// let comp_query = comp_query_set . q0 ( ) ; let mut comp_iter = comp_query . iter ( ) ; let ( _comp_entity , my_component1 ) = comp_iter . next ( ) . unwrap ( ) ; let ( _comp_entity , my_component2 ) = comp_iter . next ( ) . unwrap ( ) ; // let my_component_vec = comp_query_set.q0().iter().map(|(_, comp)| comp).collect::<Vec<_>>(); let all_vars_components = all_vars_comp . as_ref ( ) . set_values_from_components ( my_component1 . clone ( ) , my_component2 . clone ( ) ) ; let mut struct_field_vec : Vec < ( String , FieldString ) > = Vec :: new ( ) ; // for ( i , value ) in all_vars_components . iter_fields ( ) . enumerate ( ) { // let mut struct_name = all_vars_components . name_at ( i ) . unwrap ( ) . to_string ( ) ; // // procedural macro to generate the list of Dashboard implemented types let mut v : Vec < ( FieldName , FieldString ) > = downcast_struct ! [ value MyComponentNbr ] ; v = v . iter_mut ( ) . map ( | ( field_name , val_f64 ) | { // let mut struct_name_temp = struct_name . clone ( ) ; // struct_name_temp . push ( '.' ) ; struct_name_temp . push_str ( field_name ) ; // ( struct_name_temp . to_owned ( ) , val_f64 . clone ( ) ) } ) . collect :: < Vec < ( FieldName , FieldString ) > > ( ) ; struct_field_vec . append ( & mut v ) ; } spawn_res_fields_event . send ( SpawnLabels ( struct_field_vec , ui_comp_entity ) ) ; //////////////////////////////// components ///////////////////////// }
procedural macro here for resources (globals and other_globals)
procedural macro here for resources ( globals and other_globals )
commands
Commands
all_vars_res
ResMut<AllDashRes>
all_vars_comp
ResMut<AllDashComp>
comp_query_set
QuerySet<(QueryState<(Entity, &MyComponent), With<DashComponent>>,)>
globals
Res<Globals>
other_globals
Res<OtherGlobals>
materials
ResMut<Assets<ColorMaterial>>
spawn_res_fields_event
EventWriter<SpawnLabels>
commands
Commands
all_vars_res
ResMut<AllDashRes>
all_vars_comp
ResMut<AllDashComp>
comp_query_set
QuerySet<(QueryState<(Entity, &MyComponent), With<DashComponent>>,)>
globals
Res<Globals>
other_globals
Res<OtherGlobals>
materials
ResMut<Assets<ColorMaterial>>
spawn_res_fields_event
EventWriter<SpawnLabels>