diff --git a/Cargo.toml b/Cargo.toml index c87801bcc288144d1b5eb858ae997cdc60d39c02..29a251e1a30c7b4bb8035b59667e45910bc7801b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "micro_musicbox" -version = "0.4.0" +version = "0.5.0" edition = "2021" license = "Apache-2.0" authors = ["Louis Capitanchik <louis@microhacks.co.uk>"] @@ -19,10 +19,10 @@ wav = ["bevy_kira_audio/wav"] ogg = ["bevy_kira_audio/ogg"] [dependencies] -bevy = { version = "0.8", default-features = false } -bevy_kira_audio = { version = "0.12", default-features = false } +bevy = { version = "0.9.0", default-features = false } +bevy_kira_audio = { version = "0.13.0", default-features = false } serde = { version = "1", optional = true } [dev_dependencies] -bevy = "0.8" +bevy = "0.9.0" log = "0.4" \ No newline at end of file diff --git a/README.md b/README.md index 6e576fc698e82810b9be96485b9c3c041fcfaffb..f03d22efdfd450d254a1cb500bcc0d2c7fb8ce3b 100644 --- a/README.md +++ b/README.md @@ -134,3 +134,10 @@ The examples in this repository use assets available under the following license - The-Great-Madeja.mp3 by [Rolemusic](http://rolemusic.sawsquarenoise.com/) is licensed under a [CC-BY-4.0 Attribution License](https://creativecommons.org/licenses/by/4.0/). - The-White-Kitty.mp3 by [Rolemusic](http://rolemusic.sawsquarenoise.com/) is licensed under a [CC-BY-4.0 Attribution License](https://creativecommons.org/licenses/by/4.0/). - KenneyBlocks.ttf by [Kenney](https://www.kenney.nl) is licensed under a [CC-0 Public Domain License](http://creativecommons.org/publicdomain/zero/1.0/) + +## Compatibility + +| musicbox version | bevy version | bka version | +|------------------|--------------|-------------| +| 0.5 | 0.9 | 0.13 | +| 0.4 | 0.8.0 | 0.12 | \ No newline at end of file diff --git a/src/channels.rs b/src/channels.rs index eb49fc74b93611a51c6f9af93ae153ff9be08a66..5812baa00096495e454310636743c0c5eb4b0d16 100644 --- a/src/channels.rs +++ b/src/channels.rs @@ -1,3 +1,5 @@ +use bevy::prelude::Resource; + /// The channel used for playing main background music tracks. When a track is started in this /// channel, the currently playing track (if it exist) will be stopped. Tweens can be applied to /// control this transition @@ -5,6 +7,7 @@ /// - *Volume Type:* Music /// - *Supports Concurrent Sounds:* No /// - *Supports Transitions*: Yes +#[derive(Resource)] pub struct MusicAudioChannel; /// The channel used for playing an ambient background track. An ambient background track can /// be considered similar to a music track, but consisting of composite sound effects to create @@ -13,12 +16,14 @@ pub struct MusicAudioChannel; /// - *Volume Type:* SFX /// - *Supports Concurrent Sounds:* No /// - *Supports Transitions*: Yes +#[derive(Resource)] pub struct AmbianceAudioChannel; /// The channel used for generic one shot sound effects, such as spells, hits, attacks, grunts, etc. /// /// - *Volume Type:* SFX /// - *Supports Concurrent Sounds:* Yes /// - *Supports Transitions:* Yes +#[derive(Resource)] pub struct SfxAudioChannel; /// The channel used for any UI related one-shot sound effects. The volume of ui sfx can be /// controlled separately from game related sound effects @@ -26,4 +31,5 @@ pub struct SfxAudioChannel; /// - *Volume Type:* UI SFX /// - *Supports Concurrent Sounds:* Yes /// - *Supports Transitions:* Yes +#[derive(Resource)] pub struct UiSfxAudioChannel; diff --git a/src/lib.rs b/src/lib.rs index 0a68d8c4c1d3b63b2bb35805e5586e669a7c9bc2..9e59e4ed0c3f82398da305bd37b2c15561fe0796 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,9 @@ impl<T: SuppliesAudio> CombinedAudioPlugins<T> { } impl<T: SuppliesAudio> PluginGroup for CombinedAudioPlugins<T> { - fn build(&mut self, group: &mut PluginGroupBuilder) { - group.add(AudioPlugin).add(MusicBoxPlugin::<T>::new()); + fn build(self) -> PluginGroupBuilder { + let mut group = PluginGroupBuilder::start::<Self>(); + group = group.add(AudioPlugin).add(MusicBoxPlugin::<T>::new()); + group } } diff --git a/src/music_box.rs b/src/music_box.rs index 2a410f44f80781380ceba30655854080d1f21934..36be07f82b23072eea1e2b5eb7ad0013ca8c8a01 100644 --- a/src/music_box.rs +++ b/src/music_box.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use bevy::ecs::system::SystemParam; -use bevy::prelude::{Assets, Commands, DetectChanges, Handle, Res, ResMut}; +use bevy::prelude::{Assets, Commands, DetectChanges, Handle, Res, ResMut, Resource}; use bevy_kira_audio::{AudioChannel, AudioControl, AudioInstance, AudioSource, AudioTween}; use crate::utilities::{AudioSettings, SuppliesAudio, TrackType}; @@ -36,7 +36,7 @@ pub struct MusicBox<'w, 's, T: SuppliesAudio> { /// Tracks the currently active audio instance singleton channels, to allow /// for transitions -#[derive(Debug, Default)] +#[derive(Debug, Default, Resource)] pub struct MusicBoxState { pub active_music: Option<Handle<AudioInstance>>, pub active_ambiance: Option<Handle<AudioInstance>>, diff --git a/src/utilities.rs b/src/utilities.rs index 24d3a4f03dc21649d24eb912f9210a24db35c7bb..5c6cc40335d31dc199b8c47de2ff89aee8e9955b 100644 --- a/src/utilities.rs +++ b/src/utilities.rs @@ -32,7 +32,7 @@ pub trait SuppliesAudio: Resource { fn get_audio_track<T: ToString>(&self, name: T) -> Option<Handle<AudioSource>>; } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Resource)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AudioSettings { pub master_volume: f32,