Skip to content

Commit

Permalink
feat: bevy 0.9 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Dec 22, 2022
1 parent 5507af7 commit 4295592
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 68 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/" # Location of package manifests
open-pull-requests-limit: 0
schedule:
interval: "weekly"
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot#enabling-dependabot-version-updates-for-actions
- package-ecosystem: "github-actions"
directory: "/"
open-pull-requests-limit: 1
schedule:
interval: "weekly"
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates#example-disabling-version-updates-for-some-dependencies
# ignore:
14 changes: 14 additions & 0 deletions .github/workflows/cancel-stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://github.com/marketplace/actions/cancel-workflow-action#advanced-pull-requests-from-forks
name: Cancel stale workflows
on:
workflow_run:
workflows: ["main"]
types:
- requested
jobs:
cancel:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
workflow_id: ${{ github.event.workflow.id }}
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
components: rustfmt, clippy
- uses: actions/checkout@v2

- uses: Swatinem/rust-cache@v2

- run: cargo check --release --no-default-features

- run: cargo check --release
Expand Down Expand Up @@ -60,6 +62,7 @@ jobs:
toolchain: stable
override: true
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- uses: actions/upload-artifact@v2
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_assets_bundler"
version = "0.4.0"
version = "0.5.0"

description = "Assets Bundler for bevy, with content encryption support."

Expand Down Expand Up @@ -37,8 +37,7 @@ encryption = [
# compression = ["brotli"]

[dependencies]
# https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements
bevy = {version = "~0.8", default-features = false, features = ["bevy_asset"]}
bevy = {version = "0.9", default-features = false, features = ["bevy_asset"]}

anyhow = "1"
bs58 = "0.4"
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Assets Bundler for bevy, with content encryption support. Current archive format
```toml
# Cargo.toml
[dependencies]
bevy = "0.8"
bevy_assets_bundler = "0.4"
bevy = "0.9"
bevy_assets_bundler = "0.5"

[build-dependencies]
bevy_assets_bundler = "0.4"
bevy_assets_bundler = "0.5"
```

## [Build Script](https://github.com/hanabi1224/bevy_assets_bundler/blob/main/example/build.rs)
Expand Down Expand Up @@ -66,11 +66,13 @@ fn main() {
options.enabled_on_debug_build = true;

App::new()
.add_plugins_with(DefaultPlugins, |group| {
group.add_before::<AssetPlugin, _>(BundledAssetIoPlugin::from(
options.clone(),
))
})
.add_plugins(
DefaultPlugins
.build()
.add_before::<bevy::asset::AssetPlugin, _>(BundledAssetIoPlugin::from(
options,
)),
)
.add_startup_system(setup)
.run();
}
Expand Down Expand Up @@ -105,6 +107,7 @@ pub struct AssetBundlingOptions {
|bevy|bevy_assets_bundler|
|---|---|
|main|bevy_main|
|0.9|0.5|
|0.8|0.4|
|0.7|0.3|
|0.6|0.2|
Expand Down
4 changes: 1 addition & 3 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ version = "0.1.0"
publish = false

[dependencies]
bevy = "0.8"
futures-lite = "1"
bevy = "0.9"
lazy_static = "1"
rand = "0"

bevy_assets_bundler = {path = "../"}

Expand Down
95 changes: 48 additions & 47 deletions example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,76 +1,77 @@
mod r#mod;
use r#mod::BUNDLE_OPTIONS;

use bevy::{log::Level, log::LogSettings, prelude::*};
use bevy::{log::Level, log::LogPlugin, prelude::*};
use bevy_assets_bundler::BundledAssetIoPlugin;
use std::env;

/// This example illustrates the various features of Bevy UI.
fn main() {
println!("cwd: {:?}", env::current_dir());
let log_setting = LogSettings {
level: Level::INFO,
..Default::default()
};
App::new()
.insert_resource(log_setting)
.add_plugins_with(DefaultPlugins, |group| {
// the custom asset io plugin must be inserted in-between the
// `CorePlugin' and `AssetPlugin`. It needs to be after the
// CorePlugin, so that the IO task pool has already been constructed.
// And it must be before the `AssetPlugin` so that the asset plugin
// doesn't create another instance of an assert server. In general,
// the AssetPlugin should still run so that other aspects of the
// asset system are initialized correctly.
group.add_before::<bevy::asset::AssetPlugin, _>(BundledAssetIoPlugin::from(
BUNDLE_OPTIONS.clone(),
))
})
.add_plugins(
DefaultPlugins
.set(LogPlugin {
level: Level::INFO,
..Default::default()
})
.build()
// the custom asset io plugin must be inserted in-between the
// `CorePlugin' and `AssetPlugin`. It needs to be after the
// CorePlugin, so that the IO task pool has already been constructed.
// And it must be before the `AssetPlugin` so that the asset plugin
// doesn't create another instance of an asset server. In general,
// the AssetPlugin should still run so that other aspects of the
// asset system are initialized correctly.
.add_before::<bevy::asset::AssetPlugin, _>(BundledAssetIoPlugin::from(
BUNDLE_OPTIONS.clone(),
)),
)
.add_startup_system(setup)
.run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// ui camera
commands.spawn_bundle(Camera2dBundle::default());
commands.spawn(Camera2dBundle::default());
// root node
commands
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
justify_content: JustifyContent::SpaceBetween,
..Default::default()
},
color: Color::NONE.into(),
background_color: Color::NONE.into(),
..Default::default()
})
.with_children(|parent| {
// left vertical fill (border)
parent
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(200.0), Val::Percent(100.0)),
border: UiRect::all(Val::Px(2.0)),
..Default::default()
},
color: Color::rgb(0.65, 0.65, 0.65).into(),
background_color: Color::rgb(0.65, 0.65, 0.65).into(),
..Default::default()
})
.with_children(|parent| {
// left vertical fill (content)
parent
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
align_items: AlignItems::FlexEnd,
..Default::default()
},
color: Color::rgb(0.15, 0.15, 0.15).into(),
background_color: Color::rgb(0.15, 0.15, 0.15).into(),
..Default::default()
})
.with_children(|parent| {
// text
parent.spawn_bundle(TextBundle {
parent.spawn(TextBundle {
style: Style {
margin: UiRect::all(Val::Px(5.0)),
..Default::default()
Expand All @@ -88,17 +89,17 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
});
});
// right vertical fill
parent.spawn_bundle(NodeBundle {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(200.0), Val::Percent(100.0)),
..Default::default()
},
color: Color::rgb(0.15, 0.15, 0.15).into(),
background_color: Color::rgb(0.15, 0.15, 0.15).into(),
..Default::default()
});
// absolute positioning
parent
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(200.0), Val::Px(200.0)),
position_type: PositionType::Absolute,
Expand All @@ -110,44 +111,44 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
border: UiRect::all(Val::Px(20.0)),
..Default::default()
},
color: Color::rgb(0.4, 0.4, 1.0).into(),
background_color: Color::rgb(0.4, 0.4, 1.0).into(),
..Default::default()
})
.with_children(|parent| {
parent.spawn_bundle(NodeBundle {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
..Default::default()
},
color: Color::rgb(0.8, 0.8, 1.0).into(),
background_color: Color::rgb(0.8, 0.8, 1.0).into(),
..Default::default()
});
});
// render order test: reddest in the back, whitest in the front (flex center)
parent
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
position_type: PositionType::Absolute,
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..Default::default()
},
color: Color::NONE.into(),
background_color: Color::NONE.into(),
..Default::default()
})
.with_children(|parent| {
parent
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)),
..Default::default()
},
color: Color::rgb(1.0, 0.0, 0.0).into(),
background_color: Color::rgb(1.0, 0.0, 0.0).into(),
..Default::default()
})
.with_children(|parent| {
parent.spawn_bundle(NodeBundle {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute,
Expand All @@ -158,10 +159,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
},
..Default::default()
},
color: Color::rgb(1.0, 0.3, 0.3).into(),
background_color: Color::rgb(1.0, 0.3, 0.3).into(),
..Default::default()
});
parent.spawn_bundle(NodeBundle {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute,
Expand All @@ -172,10 +173,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
},
..Default::default()
},
color: Color::rgb(1.0, 0.5, 0.5).into(),
background_color: Color::rgb(1.0, 0.5, 0.5).into(),
..Default::default()
});
parent.spawn_bundle(NodeBundle {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute,
Expand All @@ -186,11 +187,11 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
},
..Default::default()
},
color: Color::rgb(1.0, 0.7, 0.7).into(),
background_color: Color::rgb(1.0, 0.7, 0.7).into(),
..Default::default()
});
// alpha test
parent.spawn_bundle(NodeBundle {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute,
Expand All @@ -201,27 +202,27 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
},
..Default::default()
},
color: Color::rgba(1.0, 0.9, 0.9, 0.4).into(),
background_color: Color::rgba(1.0, 0.9, 0.9, 0.4).into(),
..Default::default()
});
});
});
// bevy logo (flex center)
parent
.spawn_bundle(NodeBundle {
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
position_type: PositionType::Absolute,
justify_content: JustifyContent::Center,
align_items: AlignItems::FlexEnd,
..Default::default()
},
color: Color::NONE.into(),
background_color: Color::NONE.into(),
..Default::default()
})
.with_children(|parent| {
// bevy logo (image)
parent.spawn_bundle(ImageBundle {
parent.spawn(ImageBundle {
style: Style {
size: Size::new(Val::Px(500.0), Val::Auto),
..Default::default()
Expand Down
Loading

0 comments on commit 4295592

Please sign in to comment.