From 8a0751ac4fa7e159aad6c2c378778a4e83108de3 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Wed, 7 May 2025 11:01:32 +0200 Subject: [PATCH] Deps update --- Cargo.toml | 4 ++++ crates/bevy_rpack/CHANGELOG.md | 10 ++++++++++ crates/bevy_rpack/Cargo.toml | 8 ++++---- crates/bevy_rpack/README.md | 1 + crates/bevy_rpack/src/plugin.rs | 29 +++++++++++++++++++++++++---- crates/rpack_cli/Cargo.toml | 6 +++--- crates/rpack_egui/Cargo.toml | 6 +++--- 7 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 149d668..316521b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,7 @@ strip = true # Optimize all dependencies even in debug builds: [profile.dev.package."*"] opt-level = 2 + +[workspace.dependencies] +texture_packer = { version = "0.30", features = ["common"] } +image = { version = "0.25", features = ["jpeg", "png"] } \ No newline at end of file diff --git a/crates/bevy_rpack/CHANGELOG.md b/crates/bevy_rpack/CHANGELOG.md index 865b9a9..2a6446a 100644 --- a/crates/bevy_rpack/CHANGELOG.md +++ b/crates/bevy_rpack/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2025-05-07 + +### Added + +- `RpackAtlasAssetLoaderSettings` for asset loading + +### Changed + +- Updated to Bevy 0.16 + ## [0.1.2] - 2025-01-27 ### Added diff --git a/crates/bevy_rpack/Cargo.toml b/crates/bevy_rpack/Cargo.toml index 4a9b337..5b25cc3 100644 --- a/crates/bevy_rpack/Cargo.toml +++ b/crates/bevy_rpack/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_rpack" description = "Bevy plugin with rpack atlas support" -version = "0.1.2" +version = "0.2.0" edition = "2021" repository = "https://github.com/Leinnan/rpack.git" homepage = "https://github.com/Leinnan/rpack" @@ -15,18 +15,18 @@ default = ["bevy"] bevy = ["dep:bevy"] [dependencies] -bevy = { version = "0.15", optional = true, default-features = false, features = [ +bevy = { version = "0.16", optional = true, default-features = false, features = [ "bevy_asset", "bevy_sprite", "bevy_image", - "bevy_ui", + "bevy_ui" ] } serde = { version = "1.0", features = ["derive"] } serde_json = "1" thiserror = "2" [dev-dependencies] -bevy = { version = "0.15", default-features = false, features = [ +bevy = { version = "0.16", default-features = false, features = [ "bevy_asset", "bevy_core_pipeline", "bevy_render", diff --git a/crates/bevy_rpack/README.md b/crates/bevy_rpack/README.md index 680b00f..5eeaff1 100644 --- a/crates/bevy_rpack/README.md +++ b/crates/bevy_rpack/README.md @@ -112,4 +112,5 @@ fn atlas_loaded( Bevy version | Crate version --- | --- +0.16 | 0.2 0.15 | 0.1 diff --git a/crates/bevy_rpack/src/plugin.rs b/crates/bevy_rpack/src/plugin.rs index 0e3fdc3..a83c8b3 100644 --- a/crates/bevy_rpack/src/plugin.rs +++ b/crates/bevy_rpack/src/plugin.rs @@ -2,7 +2,8 @@ use crate::{AtlasAsset, SerializableRect}; use bevy::asset::{AssetLoader, AsyncReadExt}; use bevy::ecs::system::SystemParam; use bevy::image::ImageSampler; -use bevy::{prelude::*, utils::HashMap}; +use bevy::prelude::*; +use bevy::platform::collections::HashMap; use thiserror::Error; /// Errors that can occur while accessing and creating components from [`RpackAtlasAsset`]. @@ -193,13 +194,33 @@ impl From for RpackAtlasAssetError { } } +/// Configuration settings for the `RpackAtlasAssetLoaderSettings`. +#[derive(Debug, serde::Deserialize, serde::Serialize)] +pub struct RpackAtlasAssetLoaderSettings { + /// The [`ImageSampler`] to use during font image rendering. Determines + /// how the font's texture is sampled when scaling or transforming it. + /// + /// The default is `nearest`, which scales the image without blurring, + /// preserving a crisp, pixelated appearance. This is usually ideal for + /// pixel-art. + pub image_sampler: ImageSampler, +} + +impl Default for RpackAtlasAssetLoaderSettings { + fn default() -> Self { + Self { + image_sampler: ImageSampler::Descriptor(bevy::image::ImageSamplerDescriptor::nearest()), + } + } +} + /// The loader responsible for loading `RpackAtlasAsset` files from `.rpack.json` files. #[derive(Default)] pub struct RpackAtlasAssetLoader; impl AssetLoader for RpackAtlasAssetLoader { type Asset = RpackAtlasAsset; - type Settings = (); + type Settings = RpackAtlasAssetLoaderSettings; type Error = RpackAtlasAssetError; fn extensions(&self) -> &[&str] { @@ -209,7 +230,7 @@ impl AssetLoader for RpackAtlasAssetLoader { async fn load( &self, reader: &mut dyn bevy::asset::io::Reader, - _settings: &(), + settings: &RpackAtlasAssetLoaderSettings, load_context: &mut bevy::asset::LoadContext<'_>, ) -> Result { let mut file = String::new(); @@ -233,7 +254,7 @@ impl AssetLoader for RpackAtlasAssetLoader { .ok_or(RpackAtlasAssetError::LoadingImageAsset( "failed to load image asset, does it exist".to_string(), ))?; - image.sampler = ImageSampler::nearest(); + image.sampler = settings.image_sampler.clone(); let mut layout = TextureAtlasLayout::new_empty(UVec2::new(asset.size[0], asset.size[1])); let mut files = HashMap::new(); diff --git a/crates/rpack_cli/Cargo.toml b/crates/rpack_cli/Cargo.toml index bec4c72..ca5b924 100644 --- a/crates/rpack_cli/Cargo.toml +++ b/crates/rpack_cli/Cargo.toml @@ -5,7 +5,7 @@ description = "CLI application for generating rpack atlases" repository = "https://github.com/Leinnan/rpack.git" homepage = "https://github.com/Leinnan/rpack" license = "MIT OR Apache-2.0" -version = "0.1.1" +version = "0.2.0" edition = "2021" [features] @@ -15,10 +15,10 @@ basis = ["dep:basis-universal"] dds = ["dep:image_dds"] [dependencies] -bevy_rpack = { default-features = false, path = "../bevy_rpack", version = "0.1" } +bevy_rpack = { default-features = false, path = "../bevy_rpack", version = "0.2" } serde = { version = "1", features = ["derive"] } serde_json = "1" -texture_packer = { version = "0.29", features = ["common"] } +texture_packer = { workspace = true } image = { version = "0.25", features = ["jpeg", "png"] } thiserror = "2" diff --git a/crates/rpack_egui/Cargo.toml b/crates/rpack_egui/Cargo.toml index 2358fa5..7a30419 100644 --- a/crates/rpack_egui/Cargo.toml +++ b/crates/rpack_egui/Cargo.toml @@ -19,13 +19,13 @@ eframe = { version = "0.30", default-features = false, features = [ ] } log = "0.4" egui_json_tree = "0.10" -rpack_cli = { default-features = false, path = "../rpack_cli", version = "0.1" } +rpack_cli = { default-features = false, path = "../rpack_cli", version = "0.2" } # You only need serde if you want app persistence: serde = { version = "1", features = ["derive"] } serde_json = "1" -texture_packer = { version = "0.29", features = ["common"] } -image = { version = "0.25", features = ["jpeg", "png"] } +texture_packer = { workspace = true } +image = { workspace = true } egui_extras = { version = "0.30", features = ["all_loaders"] } rfd = { version = "0.15", features = [] } wasm-bindgen-futures = "0.4"