~starkingdoms/starkingdoms

c1019affcb5d41babfb0b09e9be5316881a37530 — ghostly_zsh a day ago 3e58f95
feat: recipe list displaying
1 files changed, 20 insertions(+), 2 deletions(-)

M crates/unified/src/client/crafting/ui.rs
M crates/unified/src/client/crafting/ui.rs => crates/unified/src/client/crafting/ui.rs +20 -2
@@ 66,7 66,7 @@ fn setup_ui(
            position_type: PositionType::Absolute,
            left: Val::Px(parent_pos.x),
            top: Val::Px(parent_pos.y),
            width: Val::Px(100.0),
            width: Val::Px(200.0),
            height: Val::Px(100.0),
            display: Display::Flex,
            flex_direction: FlexDirection::Column,


@@ 143,6 143,8 @@ fn setup_ui(
        // assume CanCraft for now (THIS WILL CHANGE)
        parent.spawn((
            Node {
                display: Display::Flex,
                flex_direction: FlexDirection::Column,
                ..Default::default()
            },
            PendingRecipesHolder,


@@ 159,7 161,23 @@ fn initial_create_recipe_list(
    if let Some(strong_recipes_config) = recipes_config.get(&recipe_collection.handle.clone().unwrap()) {
        for recipe_holder in &added_recipes_holders {
            let mut recipe_holder = commands.get_entity(recipe_holder).unwrap();
            debug!("{:?}", strong_recipes_config);
            for (module_name, recipes) in &strong_recipes_config.recipes {
                for recipe in recipes {
                    let resource_list = recipe.iter()
                        .map(|(resource_name, quantity)| format!("{} {}", quantity, resource_name))
                        .collect::<Vec<_>>().join(", ");
                    recipe_holder.with_child((
                        Node {
                            ..Default::default()
                        },
                        TextFont {
                            font_size: 10.0,
                            ..Default::default()
                        },
                        Text::new(format!("{}: {}", module_name, resource_list)),
                    ));
                }
            }
            recipe_holder
                .insert(RecipesHolder)
                .remove::<PendingRecipesHolder>();