Skip to content
Snippets Groups Projects
Verified Commit 68a86456 authored by Louis's avatar Louis :fire:
Browse files

v2

- Move common dependencies to workspace level
- Use micro_musicbox instead of git repository
- Use specific versions of deps
- Fix splash image scaling
- Use virtual size for camera, window size for window
parent 44c295c3
No related branches found
Tags v2
No related merge requests found
......@@ -110,9 +110,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.62"
version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305"
checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
[[package]]
name = "approx"
......@@ -453,14 +453,15 @@ dependencies = [
[[package]]
name = "bevy_kira_audio"
version = "0.11.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7d902ab6a15bd45af04d47b208a24f95205d8d2fd1fa15dd4e86a570fad813b"
checksum = "0379febb94c497ac6f6b5c0ef27775f7302f65dc780a33dbcec0c743a474b5f4"
dependencies = [
"anyhow",
"bevy",
"kira",
"parking_lot 0.12.1",
"thiserror",
]
[[package]]
......@@ -1357,15 +1358,6 @@ dependencies = [
"syn",
]
[[package]]
name = "encoding_rs"
version = "0.8.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "env_logger"
version = "0.8.4"
......@@ -1493,7 +1485,7 @@ dependencies = [
"fastrand",
"iyes_loopless",
"log 0.4.17",
"musicbox",
"micro_musicbox",
"remote_events",
"serde",
"serde_json",
......@@ -1883,7 +1875,6 @@ dependencies = [
"atomic-arena",
"cpal",
"ringbuf",
"symphonia",
]
[[package]]
......@@ -2010,6 +2001,16 @@ dependencies = [
"objc",
]
[[package]]
name = "micro_musicbox"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51777e5d26d5e3faf89e2f8265d27c579ef97088e57f9ea2ba933c67d9757d5e"
dependencies = [
"bevy",
"bevy_kira_audio",
]
[[package]]
name = "mime"
version = "0.2.6"
......@@ -2046,17 +2047,6 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "musicbox"
version = "0.2.0-pre.1"
source = "git+https://lab.lcr.gr/microhacks/micro-bevy-musicbox.git?rev=5ab4120a983e54ef0786ddca43b92a70605efd49#5ab4120a983e54ef0786ddca43b92a70605efd49"
dependencies = [
"bevy",
"bevy_kira_audio",
"serde",
"serde_json",
]
[[package]]
name = "naga"
version = "0.9.0"
......@@ -2839,18 +2829,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.143"
version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553"
checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.143"
version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391"
checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
dependencies = [
"proc-macro2",
"quote",
......@@ -2859,9 +2849,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.83"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
dependencies = [
"itoa",
"ryu",
......@@ -2950,91 +2940,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2"
[[package]]
name = "symphonia"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17033fe05e4f7f10a6ad602c272bafd2520b2e5cdd9feb61494d9cdce08e002f"
dependencies = [
"lazy_static",
"symphonia-bundle-mp3",
"symphonia-codec-vorbis",
"symphonia-core",
"symphonia-format-ogg",
"symphonia-metadata",
]
[[package]]
name = "symphonia-bundle-mp3"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db5d3d53535ae2b7d0e39e82f683cac5398a6c8baca25ff1183e107d13959d3e"
dependencies = [
"bitflags",
"lazy_static",
"log 0.4.17",
"symphonia-core",
"symphonia-metadata",
]
[[package]]
name = "symphonia-codec-vorbis"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "323b94435a1a807e1001e29490aeaef2660fb72b145d47497e8429a6cb1d67c3"
dependencies = [
"log 0.4.17",
"symphonia-core",
"symphonia-utils-xiph",
]
[[package]]
name = "symphonia-core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "199a6417cd4115bac79289b64b859358ea050b7add0ceb364dc991f628c5b347"
dependencies = [
"arrayvec",
"bitflags",
"bytemuck",
"lazy_static",
"log 0.4.17",
]
[[package]]
name = "symphonia-format-ogg"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d2f741469a0f103607ed1f2605f7f00b13ba044ea9ddc616764558c6d3d9b7d"
dependencies = [
"log 0.4.17",
"symphonia-core",
"symphonia-metadata",
"symphonia-utils-xiph",
]
[[package]]
name = "symphonia-metadata"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed71acf6b5e6e8bee1509597b86365a06b78c1d73218df47357620a6fe5997b"
dependencies = [
"encoding_rs",
"lazy_static",
"log 0.4.17",
"symphonia-core",
]
[[package]]
name = "symphonia-utils-xiph"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73cbb0766ce77a8aef535f9438db645e7b6f1b2c4cf3be9bf246b4e11a7d5531"
dependencies = [
"symphonia-core",
"symphonia-metadata",
]
[[package]]
name = "syn"
version = "1.0.99"
......@@ -3084,18 +2989,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.32"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.32"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
......
......@@ -6,6 +6,15 @@ members = [
"game_core",
]
[workspace.dependencies]
fastrand = "1.8.0"
anyhow = "1.0.65"
log = "0.4.17"
thiserror = "1.0.37"
serde = "1.0.145"
serde_json = "1.0.85"
iyes_loopless = "0.7.1"
[profile.release]
debug = 0
opt-level = 3
......@@ -6,22 +6,22 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fastrand = "1.7"
anyhow = "1"
log = "0.4"
thiserror = "1"
serde = "1"
serde_json = "1"
iyes_loopless = "0.7"
fastrand.workspace = true
anyhow.workspace = true
log.workspace = true
thiserror.workspace = true
serde.workspace = true
serde_json.workspace = true
iyes_loopless.workspace = true
musicbox = { git = "https://lab.lcr.gr/microhacks/micro-bevy-musicbox.git", rev = "5ab4120a983e54ef0786ddca43b92a70605efd49"}
micro_musicbox = "0.4.0"
remote_events = { git = "https://lab.lcr.gr/microhacks/micro-bevy-remote-events.git", rev = "be0c6b43a73e4c5e7ece20797e3d6f59340147b4"}
[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3.58", features = ["Window"] }
[dependencies.bevy]
version = "0.8"
version = "0.8.1"
default-features = false
features = [
"render",
......
......@@ -16,8 +16,9 @@
}
#start_container {
width: 100vw;
width: auto;
height: 100vh;
aspect-ratio: 1;
display: flex;
justify-content: center;
align-items: center;
......
......@@ -4,7 +4,7 @@ use bevy::asset::LoadState;
use bevy::ecs::system::SystemParam;
use bevy::prelude::*;
use bevy::reflect::TypeUuid;
use musicbox::prelude::AudioSource;
use micro_musicbox::prelude::AudioSource;
use crate::assets::{AssetHandles, FixedAssetNameMapping, SpriteSheetConfig};
......
use bevy::prelude::*;
use bevy::utils::HashMap;
use musicbox::prelude::AudioSource;
use musicbox::utilities::SuppliesAudio;
use micro_musicbox::prelude::AudioSource;
use micro_musicbox::utilities::{SuppliesAudio, TrackType};
#[derive(Copy, Clone, Debug)]
pub struct SpriteSheetConfig {
......@@ -69,6 +69,14 @@ impl AssetHandles {
}
impl SuppliesAudio for AssetHandles {
fn resolve_track_name<T: ToString>(&self, name: T) -> TrackType<String> {
if self.sounds.contains_key(&name.to_string()) {
TrackType::Single(name.to_string())
} else {
TrackType::Missing
}
}
fn get_audio_track<T: ToString>(&self, name: T) -> Option<Handle<AudioSource>> {
self.sounds.get(&name.to_string()).map(Handle::clone_weak)
}
......
use bevy::prelude::*;
use game_core::assets::AssetHandles;
use game_core::system::flow::AppState;
use game_core::system::resources::DefaultResourcesPlugin;
use iyes_loopless::prelude::AppLooplessStateExt;
use musicbox::CombinedAudioPlugins;
use micro_musicbox::CombinedAudioPlugins;
use remote_events::RemoteEventPlugin;
fn main() {
......@@ -11,7 +12,7 @@ fn main() {
.add_plugin(DefaultResourcesPlugin)
.add_plugins(DefaultPlugins)
.add_plugin(game_core::assets::AssetsPlugin)
.add_plugins(CombinedAudioPlugins)
.add_plugins(CombinedAudioPlugins::<AssetHandles>::new())
.add_plugin(game_core::splash_screen::SplashScreenPlugin)
.add_plugin(game_core::system::camera::CameraManagementPlugin)
.add_plugin(RemoteEventPlugin::<
......
use bevy::prelude::*;
use bevy::render::render_resource::FilterMode;
use bevy::render::texture::ImageSampler;
use iyes_loopless::state::NextState;
use musicbox::prelude::MusicBox;
use micro_musicbox::music_box::MusicBox;
use crate::assets::AssetHandles;
use crate::splash_screen::components::{
SplashAnimation, SplashAnimationBundle, SplashAnimationTimer, SplashAnimationType,
};
use crate::system::flow::AppState;
use crate::system::load_config::virtual_size;
use crate::system::utilities::f32_min;
use crate::system::window::WindowManager;
const C_TRANS: Color = Color::rgba(1.0, 1.0, 1.0, 0.0);
const C_WHITE: Color = Color::rgba(1.0, 1.0, 1.0, 1.0);
......@@ -33,17 +32,9 @@ pub fn setup_splash_screen(
mut commands: Commands,
mut image_assets: ResMut<Assets<Image>>,
handles: Res<AssetHandles>,
windows: WindowManager,
mut music_box: MusicBox<AssetHandles>,
) {
let window_size = match windows.get_primary_window() {
Some(size) => size,
None => {
log::error!("Missing window for splash screen");
commands.insert_resource(NextState(AppState::Menu));
return;
}
};
let (window_width, window_height) = virtual_size();
let handle = match handles.images.get("splash") {
Some(handle) => handle,
......@@ -59,13 +50,13 @@ pub fn setup_splash_screen(
commands.insert_resource(ClearColor(Color::hex("001122").unwrap()));
let scale_factor = match window_size.width() > window_size.height() {
true => window_size.height() / image_data.texture_descriptor.size.height as f32,
false => window_size.width() / image_data.texture_descriptor.size.width as f32,
let scale_factor = match window_width > window_height {
true => window_height / image_data.texture_descriptor.size.height as f32,
false => window_width / image_data.texture_descriptor.size.width as f32,
};
image_data.sampler_descriptor = ImageSampler::linear();
music_box.play_effect_once("splash_sting");
music_box.play_sfx("splash_sting");
commands
.spawn_bundle(SpriteBundle {
......
......@@ -8,7 +8,7 @@ use bevy::render::camera::ScalingMode;
use iyes_loopless::prelude::AppLooplessStateExt;
use crate::system::flow::AppState;
use crate::system::load_config::initial_size;
use crate::system::load_config::virtual_size;
/// A flag component to indicate which entity should be followed by the camera
#[derive(Component)]
......@@ -19,7 +19,7 @@ pub struct GameCamera;
/// System that creates a default orthographic camera, with correct tags for querying
pub fn spawn_orthographic_camera(mut commands: Commands) {
let (target_width, target_height) = initial_size();
let (target_width, target_height) = virtual_size();
commands
.spawn_bundle(Camera2dBundle {
projection: OrthographicProjection {
......
......@@ -12,6 +12,9 @@ mod setup {
pub fn initial_size() -> (f32, f32) {
(1280.0, 720.0)
}
pub fn virtual_size() -> (f32, f32) {
(1280.0, 720.0)
}
}
#[cfg(target_arch = "wasm32")]
......@@ -19,7 +22,9 @@ mod setup {
pub fn get_asset_path_string() -> String {
String::from("assets")
}
pub fn virtual_size() -> (f32, f32) {
(1280.0, 720.0)
}
#[cfg(feature = "no_aspect")]
pub fn initial_size() -> (f32, f32) {
static default_width: f32 = 1280.0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment