Skip to content

Commit

Permalink
tox in info panel
Browse files Browse the repository at this point in the history
  • Loading branch information
andricDu committed Apr 9, 2023
1 parent 23074b5 commit ca9633e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/game/information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub fn build_ingredient_information(
style: Style {
flex_direction: FlexDirection::Row,
justify_content: JustifyContent::SpaceEvenly,
flex_wrap: FlexWrap::Wrap,
..default()
},
..default()
Expand All @@ -152,7 +153,7 @@ pub fn build_ingredient_information(
NodeBundle {
style: Style {
flex_direction: FlexDirection::Column,
size: Size::new(Val::Px(140.), Val::Px(200.0)),
size: Size::new(Val::Px(140.), Val::Px(150.0)),
..default()
},
..default()
Expand Down Expand Up @@ -186,7 +187,7 @@ pub fn build_ingredient_information(
NodeBundle {
style: Style {
flex_direction: FlexDirection::Column,
size: Size::new(Val::Px(140.), Val::Px(200.0)),
size: Size::new(Val::Px(140.), Val::Px(150.0)),
..default()
},
..default()
Expand All @@ -212,6 +213,13 @@ pub fn build_ingredient_information(
parent.spawn((TextBundle::from_sections(text_sections),));
});
});
commands.spawn(TextBundle {
text: Text {
sections: vec![TextSection::new(format!("Toxicity: {}\n", get_tox_or_unknown(ingredient)), get_info_text_style(font, 18.))],
..default()
},
..default()
});
}

pub fn build_default_information_text(commands: &mut ChildBuilder, font: &Handle<Font>) {
Expand All @@ -236,6 +244,14 @@ fn get_text_or_unknown(side_effect: &SideEffectClass, used: bool, starter: bool)
}
}

fn get_tox_or_unknown(ingredient: &Ingredient) -> String {
if ingredient.used || ingredient.starter {
ingredient.toxicity.to_string()
} else {
"?".into()
}
}

// ------ STYLES ------

const INFO_TEXT_BUNDLE_STYLE: Style = Style {
Expand Down

0 comments on commit ca9633e

Please sign in to comment.