Skip to content

Commit

Permalink
bevy 0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Dutton authored and kgv committed Jul 12, 2023
1 parent e032757 commit 64f90c7
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 36 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_fluent"
version = "0.6.1"
version = "0.7.0"
authors = ["g <kgv@users.noreply.github.com>"]
edition = "2021"
description = "Bevy plugin for localization using Fluent"
Expand All @@ -19,7 +19,7 @@ exclude = [".github/**/*"]

[dependencies]
anyhow = "1.0.70"
bevy = { version = "0.10.1", default-features = false, features = [
bevy = { version = "0.11.0", default-features = false, features = [
"bevy_asset",
] }
fluent = "0.16.0"
Expand All @@ -37,5 +37,5 @@ unic-langid = { version = "0.9.1", features = ["serde"] }
uuid = { version = "1.3.1", features = ["serde", "v4", "v5"] }

[dev-dependencies]
bevy = "0.10.1"
bevy = "0.11.0"
unic-langid = { version = "0.9.1", features = ["macros"] }
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

| bevy | bevy_fluent |
|-------|-------------|
| 0.11 | 0.7 |
| 0.10 | 0.6 |
| 0.9 | 0.5 |
| 0.8 | 0.4 |
Expand Down
4 changes: 2 additions & 2 deletions examples/fallback_chain/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub fn main() {
asset_folder: "examples/fallback_chain/assets".to_string(),
..default()
}))
.add_plugin(FluentPlugin)
.add_system(localized_hello_world)
.add_plugins(FluentPlugin)
.add_systems(Update, localized_hello_world)
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub fn main() {
asset_folder: "examples/minimal/assets".to_string(),
..default()
}))
.add_plugin(FluentPlugin)
.add_system(localized_hello_world)
.add_plugins(FluentPlugin)
.add_systems(Update, localized_hello_world)
.run();
}

Expand Down
18 changes: 7 additions & 11 deletions examples/ui/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ fn main() {
asset_folder: "examples/ui/assets".to_string(),
..default()
}))
.add_plugin(FluentPlugin)
.add_plugins(FluentPlugin)
.insert_resource(Locale::new(ru::RU).with_default(en::US))
.insert_resource(Locales(vec![de::DE, en::US, ru::BY, ru::RU]))
.init_resource::<Font>()
.add_state::<GameState>()
.add_systems((
load::setup.in_schedule(OnEnter(GameState::Load)),
load::update.in_set(OnUpdate(GameState::Load)),
))
// TODO: [nested tuples of systems](https://github.com/bevyengine/bevy/issues/7880)
.add_systems((
menu::setup.in_schedule(OnEnter(GameState::Menu)),
menu::cleanup.in_schedule(OnExit(GameState::Menu)),
))
.add_systems(OnEnter(GameState::Load), load::setup)
.add_systems(Update, load::update.run_if(in_state(GameState::Load)))
.add_systems(OnEnter(GameState::Menu), menu::setup)
.add_systems(OnExit(GameState::Menu), menu::cleanup)
.add_systems(
(menu::interaction, menu::next, menu::previous).in_set(OnUpdate(GameState::Menu)),
Update,
(menu::interaction, menu::next, menu::previous).run_if(in_state(GameState::Menu)),
)
.run();
}
Expand Down
33 changes: 21 additions & 12 deletions examples/ui/systems/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub fn setup(
commands
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
width: Val::Percent(100.0),
height: Val::Percent(100.0),
position_type: PositionType::Absolute,
flex_direction: FlexDirection::ColumnReverse,
align_items: AlignItems::Center,
Expand All @@ -43,7 +44,8 @@ pub fn setup(
parent
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(25.0)),
width: Val::Percent(100.0),
height: Val::Percent(25.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
Expand All @@ -68,7 +70,8 @@ pub fn setup(
parent
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(75.0)),
width: Val::Percent(100.0),
height: Val::Percent(75.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
margin: UiRect::all(Val::Auto),
Expand All @@ -82,8 +85,10 @@ pub fn setup(
PreviousButton,
ButtonBundle {
style: Style {
size: Size::new(Val::Percent(10.0), Val::Percent(20.0)),
min_size: Size::new(Val::Px(64.0), Val::Px(64.0)),
width: Val::Percent(10.0),
height: Val::Percent(20.0),
min_width: Val::Px(64.0),
min_height: Val::Px(64.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
Expand All @@ -108,8 +113,10 @@ pub fn setup(
parent
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(80.0), Val::Percent(20.0)),
min_size: Size::new(Val::Px(256.0), Val::Px(64.0)),
width: Val::Percent(80.0),
height: Val::Percent(20.0),
min_width: Val::Px(256.0),
min_height: Val::Px(64.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
Expand All @@ -135,8 +142,10 @@ pub fn setup(
NextButton,
ButtonBundle {
style: Style {
size: Size::new(Val::Percent(10.0), Val::Percent(20.0)),
min_size: Size::new(Val::Px(64.0), Val::Px(64.0)),
width: Val::Percent(10.0),
height: Val::Percent(20.0),
min_width: Val::Px(64.0),
min_height: Val::Px(64.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
Expand Down Expand Up @@ -173,7 +182,7 @@ pub fn interaction(
) {
for (interaction, mut color) in query.iter_mut() {
*color = match interaction {
Interaction::Clicked => Color::DARK_GRAY.into(),
Interaction::Pressed => Color::DARK_GRAY.into(),
Interaction::Hovered => Color::SILVER.into(),
Interaction::None => Color::GRAY.into(),
}
Expand All @@ -185,7 +194,7 @@ pub fn next(
mut next_state: ResMut<NextState<GameState>>,
query: Query<&Interaction, (Changed<Interaction>, With<NextButton>)>,
) {
if let Ok(Interaction::Clicked) = query.get_single() {
if let Ok(Interaction::Pressed) = query.get_single() {
swiper.next();
next_state.set(GameState::Load);
}
Expand All @@ -196,7 +205,7 @@ pub fn previous(
mut next_state: ResMut<NextState<GameState>>,
query: Query<&Interaction, (Changed<Interaction>, With<PreviousButton>)>,
) {
if let Ok(Interaction::Clicked) = query.get_single() {
if let Ok(Interaction::Pressed) = query.get_single() {
swiper.previous();
next_state.set(GameState::Load);
}
Expand Down
4 changes: 2 additions & 2 deletions src/assets/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Result;
use bevy::{
asset::{AssetLoader, AssetPath, LoadContext, LoadedAsset},
prelude::*,
reflect::TypeUuid,
reflect::{TypePath, TypeUuid},
utils::{
tracing::{self, instrument},
BoxedFuture,
Expand Down Expand Up @@ -57,7 +57,7 @@ async fn load(data: Data, load_context: &mut LoadContext<'_>) -> Result<()> {
/// [`FluentBundle`](fluent::bundle::FluentBundle) wrapper
///
/// Collection of [`FluentResource`]s for a single locale
#[derive(Clone, TypeUuid)]
#[derive(Clone, TypePath, TypeUuid)]
#[uuid = "929113bb-9187-44c3-87be-6027fc3b7ac5"]
pub struct BundleAsset {
pub(crate) bundle: Arc<FluentBundle<Arc<FluentResource>, IntlLangMemoizer>>,
Expand Down
4 changes: 2 additions & 2 deletions src/assets/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
use bevy::{
asset::{AssetLoader, LoadContext, LoadedAsset},
prelude::*,
reflect::TypeUuid,
reflect::{TypePath, TypeUuid},
utils::{
tracing::{self, instrument},
BoxedFuture,
Expand Down Expand Up @@ -36,7 +36,7 @@ fn load(data: Arc<FluentResource>, load_context: &mut LoadContext<'_>) {
}

/// [`FluentResource`](fluent::FluentResource) wrapper
#[derive(Clone, Debug, TypeUuid)]
#[derive(Clone, Debug, TypePath, TypeUuid)]
#[uuid = "0b2367cb-fb4a-4746-a305-df98b26dddf6"]
pub struct ResourceAsset(pub(crate) Arc<FluentResource>);

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Plugin for FluentPlugin {
app.add_asset::<ResourceAsset>()
.init_asset_loader::<ResourceAssetLoader>()
.add_asset::<BundleAsset>()
.init_asset_loader::<BundleAssetLoader>()
.add_system(update_bundle_asset.in_base_set(CoreSet::PreUpdate));
.init_asset_loader::<BundleAssetLoader>()
.add_systems(PreUpdate, update_bundle_asset);
}
}

0 comments on commit 64f90c7

Please sign in to comment.