Skip to content

Commit

Permalink
feat!: use a single BarSettings component (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
sparten11740 committed Nov 13, 2023
1 parent 1a9d207 commit 41b77d6
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 200 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() {
}
```

Spawn a mesh, the component to be tracked, and a `BarBundle` to configure the look & feel of your bar.
Spawn a mesh, the component to be tracked, and a `BarSettings` component to configure the look & feel of your bar.

```rust
fn setup(
Expand All @@ -69,9 +69,9 @@ fn setup(
max: 10.,
current: 2.,
},
BarBundle::<Health> {
width: BarWidth::new(mesh_width),
offset: BarOffset::new(mesh_height),
BarSettings::<Health> {
width: 5.,
offset: 2.,
orientation: BarOrientation::Vertical, // default is horizontal
..default()
},
Expand Down
10 changes: 4 additions & 6 deletions examples/border.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::prelude::{
BarBorder, BarBundle, BarHeight, BarOffset, BarWidth, HealthBarPlugin, Percentage,
};
use bevy_health_bar3d::prelude::{BarBorder, BarHeight, BarSettings, HealthBarPlugin, Percentage};

#[derive(Component, Reflect)]
struct Health {
Expand Down Expand Up @@ -76,9 +74,9 @@ fn setup(
max: 10.,
current: value,
},
BarBundle::<Health> {
offset: BarOffset::new(offset),
width: BarWidth::new(bar_width),
BarSettings::<Health> {
offset,
width: bar_width,
height: BarHeight::Static(bar_height),
// here is where the border is defined
border: BarBorder::new(bar_height / 4.).color(Color::PURPLE),
Expand Down
10 changes: 4 additions & 6 deletions examples/custom_background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::prelude::{
BarBundle, BarOffset, BarWidth, ColorScheme, HealthBarPlugin, Percentage,
};
use bevy_health_bar3d::prelude::{BarSettings, ColorScheme, HealthBarPlugin, Percentage};

#[derive(Component, Reflect)]
struct Health {
Expand Down Expand Up @@ -69,9 +67,9 @@ fn setup(
max: 10.,
current: 8.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand Down
12 changes: 6 additions & 6 deletions examples/custom_foreground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ fn setup(
max: 10.,
current: value,
},
BarBundle::<Mana> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Mana> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand All @@ -107,9 +107,9 @@ fn setup(
max: 10.,
current: value,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand Down
15 changes: 8 additions & 7 deletions examples/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use bevy::pbr::*;
use bevy::prelude::*;
use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_health_bar3d::prelude::{BarBundle, BarOffset, BarWidth, HealthBarPlugin, Percentage};
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::prelude::{BarSettings, HealthBarPlugin, Percentage};

#[derive(Component, Reflect)]
struct Health {
max: f32,
Expand Down Expand Up @@ -66,9 +67,9 @@ fn setup(
max: 10.,
current: 8.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand All @@ -90,9 +91,9 @@ fn setup(
max: 10.,
current: 2.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand Down
21 changes: 10 additions & 11 deletions examples/dinosaurs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use bevy_tweening::lens::{TransformPositionLens, TransformRotationLens};
use bevy_tweening::{Animator, EaseFunction, Tracks, Tween, TweeningPlugin};

use bevy_health_bar3d::prelude::{
BarBundle, BarHeight, BarOffset, BarWidth, ColorScheme, ForegroundColor, HealthBarPlugin,
Percentage,
BarHeight, BarSettings, ColorScheme, ForegroundColor, HealthBarPlugin, Percentage,
};

#[derive(Component, Reflect)]
Expand Down Expand Up @@ -132,16 +131,16 @@ fn setup(
max: 10.,
current: 8.,
},
BarBundle::<Distance> {
offset: BarOffset::new(15.),
BarSettings::<Distance> {
offset: 15.,
height: BarHeight::Static(1.),
width: BarWidth::new(10.),
width: 10.,
..default()
},
BarBundle::<Health> {
offset: BarOffset::new(17.),
BarSettings::<Health> {
offset: 17.,
height: BarHeight::Static(1.),
width: BarWidth::new(10.),
width: 10.,
..default()
},
));
Expand All @@ -153,10 +152,10 @@ fn setup(
max: 10.,
current: 10.,
},
BarBundle::<Health> {
offset: BarOffset::new(17.),
BarSettings::<Health> {
offset: 17.,
height: BarHeight::Static(1.),
width: BarWidth::new(10.),
width: 10.,
..default()
},
));
Expand Down
14 changes: 7 additions & 7 deletions examples/dual_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::configuration::ForegroundColor;
use bevy_health_bar3d::prelude::{
BarBundle, BarHeight, BarOffset, BarWidth, ColorScheme, HealthBarPlugin, Percentage,
BarHeight, BarSettings, ColorScheme, HealthBarPlugin, Percentage,
};

#[derive(Component, Reflect)]
Expand Down Expand Up @@ -83,19 +83,19 @@ fn setup(
max: 10.,
current: value,
},
BarBundle::<Health> {
offset: BarOffset::new(offset),
width: BarWidth::new(bar_width),
BarSettings::<Health> {
offset: offset,
width: bar_width,
height: BarHeight::Static(bar_height),
..default()
},
Mana {
max: 10.,
current: values[2 - i],
},
BarBundle::<Mana> {
offset: BarOffset::new(offset + bar_height + bar_height / 5.),
width: BarWidth::new(bar_width),
BarSettings::<Mana> {
offset: offset + bar_height + bar_height / 5.,
width: bar_width,
height: BarHeight::Static(bar_height),
..default()
},
Expand Down
8 changes: 4 additions & 4 deletions examples/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::prelude::{BarBundle, BarOffset, BarWidth, HealthBarPlugin, Percentage};
use bevy_health_bar3d::prelude::{BarSettings, HealthBarPlugin, Percentage};

#[derive(Component, Reflect)]
struct Health {
Expand Down Expand Up @@ -59,9 +59,9 @@ fn setup(
max: 10.,
current: 10.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand Down
14 changes: 7 additions & 7 deletions examples/multi_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy::pbr::*;
use bevy::prelude::*;
use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_health_bar3d::prelude::{BarBundle, BarOffset, BarWidth, HealthBarPlugin, Percentage};
use bevy_health_bar3d::prelude::{BarSettings, HealthBarPlugin, Percentage};
use bevy_inspector_egui::quick::WorldInspectorPlugin;

#[derive(Component, Reflect)]
Expand Down Expand Up @@ -67,9 +67,9 @@ fn setup(
max: 10.,
current: 8.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand All @@ -91,9 +91,9 @@ fn setup(
max: 10.,
current: 2.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
..default()
},
));
Expand Down
16 changes: 7 additions & 9 deletions examples/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::prelude::{
BarBundle, BarHeight, BarOffset, BarWidth, HealthBarPlugin, Percentage,
};
use bevy_health_bar3d::prelude::{BarHeight, BarSettings, HealthBarPlugin, Percentage};

#[derive(Component, Reflect)]
struct Health {
Expand Down Expand Up @@ -83,10 +81,10 @@ fn setup(
max: 10.,
current: 8.,
},
BarBundle::<Health> {
offset: BarOffset::new(18.),
BarSettings::<Health> {
offset: 18.,
height: BarHeight::Static(1.),
width: BarWidth::new(10.),
width: 10.,
..default()
},
Jim,
Expand All @@ -108,11 +106,11 @@ fn setup(
max: 10.,
current: 3.,
},
BarBundle::<Health> {
BarSettings::<Health> {
// Have to locate it higher than Jim's so there is no clipping during rotation
offset: BarOffset::new(21.),
offset: 21.,
height: BarHeight::Static(1.),
width: BarWidth::new(10.),
width: 10.,
..default()
},
Tom,
Expand Down
10 changes: 4 additions & 6 deletions examples/vertical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use bevy::utils::default;
use bevy::DefaultPlugins;
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_health_bar3d::prelude::{
BarBundle, BarOffset, BarOrientation, BarWidth, HealthBarPlugin, Percentage,
};
use bevy_health_bar3d::prelude::{BarOrientation, BarSettings, HealthBarPlugin, Percentage};

#[derive(Component, Reflect)]
struct Health {
Expand Down Expand Up @@ -70,9 +68,9 @@ fn setup(
max: 10.,
current: 8.,
},
BarBundle::<Health> {
offset: BarOffset::new(radius * 1.5),
width: BarWidth::new(radius * 2.),
BarSettings::<Health> {
offset: radius * 1.5,
width: radius * 2.,
orientation: BarOrientation::Vertical,
..default()
},
Expand Down

0 comments on commit 41b77d6

Please sign in to comment.