From d9fad37e07346f186a44b122092be6c139854da9 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Tue, 1 Apr 2025 21:57:44 +0800 Subject: [PATCH] PoC of ammo ui --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/heads_ui.rs | 11 +++++++++++ src/main.rs | 2 ++ 4 files changed, 25 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 8bb235b..e78f1ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -478,6 +478,16 @@ dependencies = [ "syn", ] +[[package]] +name = "bevy-ui-gradients" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ba75b56bfdaefc61b0a96d84cd26b6d8d94eeea838121a649881ccc09a6dcff" +dependencies = [ + "bevy", + "bytemuck", +] + [[package]] name = "bevy_a11y" version = "0.15.3" @@ -2914,6 +2924,7 @@ dependencies = [ "avian3d", "bevy", "bevy-inspector-egui", + "bevy-ui-gradients", "bevy_asset_loader", "bevy_ballistic", "bevy_polyline", diff --git a/Cargo.toml b/Cargo.toml index be86a4f..5866f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ rand = "=0.8.5" bevy-inspector-egui = { version = "0.30", optional = true } bevy_polyline = "0.11.0" bevy_ballistic = "0.1.0" +bevy-ui-gradients = "0.2.0" [lints.clippy] too_many_arguments = "allow" diff --git a/src/heads_ui.rs b/src/heads_ui.rs index f737f08..5f2079d 100644 --- a/src/heads_ui.rs +++ b/src/heads_ui.rs @@ -6,6 +6,8 @@ use crate::{ sounds::PlaySound, }; use bevy::prelude::*; +use bevy_ui_gradients::{AngularColorStop, BackgroundGradient, ConicGradient, Position}; +use std::f32::consts::PI; pub static HEAD_COUNT: usize = 18; static HEAD_SLOTS: usize = 5; @@ -138,7 +140,16 @@ fn spawn_head_ui( position_type: PositionType::Absolute, ..default() }, + BorderRadius::all(Val::Px(9999.)), ImageNode::new(regular), + BackgroundGradient::from(ConicGradient { + stops: vec![ + AngularColorStop::new(Color::linear_rgba(0., 0., 0., 0.9), 0.), + AngularColorStop::new(Color::linear_rgba(0., 0., 0., 0.9), PI * 1.5), + AngularColorStop::new(Color::linear_rgba(0., 0., 0., 0.0), PI * 1.5), + ], + position: Position::CENTER, + }), )); parent .spawn((Node { diff --git a/src/main.rs b/src/main.rs index ccabd62..8ebbbe5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ use bevy::render::view::ColorGrading; use bevy_polyline::PolylinePlugin; use bevy_sprite3d::Sprite3dPlugin; use bevy_trenchbroom::prelude::*; +use bevy_ui_gradients::UiGradientsPlugin; use control::controller::CharacterControllerPlugin; use loading_assets::AudioAssets; use utils::billboards; @@ -79,6 +80,7 @@ fn main() { app.add_plugins(PolylinePlugin); app.add_plugins(Sprite3dPlugin); app.add_plugins(TrenchBroomPlugin(TrenchBroomConfig::new("hedz"))); + app.add_plugins(UiGradientsPlugin); #[cfg(feature = "dbg")] {