PoC of ammo ui

This commit is contained in:
2025-04-01 21:57:44 +08:00
parent 7fbf24a49b
commit d9fad37e07
4 changed files with 25 additions and 0 deletions

11
Cargo.lock generated
View File

@@ -478,6 +478,16 @@ dependencies = [
"syn", "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]] [[package]]
name = "bevy_a11y" name = "bevy_a11y"
version = "0.15.3" version = "0.15.3"
@@ -2914,6 +2924,7 @@ dependencies = [
"avian3d", "avian3d",
"bevy", "bevy",
"bevy-inspector-egui", "bevy-inspector-egui",
"bevy-ui-gradients",
"bevy_asset_loader", "bevy_asset_loader",
"bevy_ballistic", "bevy_ballistic",
"bevy_polyline", "bevy_polyline",

View File

@@ -32,6 +32,7 @@ rand = "=0.8.5"
bevy-inspector-egui = { version = "0.30", optional = true } bevy-inspector-egui = { version = "0.30", optional = true }
bevy_polyline = "0.11.0" bevy_polyline = "0.11.0"
bevy_ballistic = "0.1.0" bevy_ballistic = "0.1.0"
bevy-ui-gradients = "0.2.0"
[lints.clippy] [lints.clippy]
too_many_arguments = "allow" too_many_arguments = "allow"

View File

@@ -6,6 +6,8 @@ use crate::{
sounds::PlaySound, sounds::PlaySound,
}; };
use bevy::prelude::*; use bevy::prelude::*;
use bevy_ui_gradients::{AngularColorStop, BackgroundGradient, ConicGradient, Position};
use std::f32::consts::PI;
pub static HEAD_COUNT: usize = 18; pub static HEAD_COUNT: usize = 18;
static HEAD_SLOTS: usize = 5; static HEAD_SLOTS: usize = 5;
@@ -138,7 +140,16 @@ fn spawn_head_ui(
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
..default() ..default()
}, },
BorderRadius::all(Val::Px(9999.)),
ImageNode::new(regular), 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 parent
.spawn((Node { .spawn((Node {

View File

@@ -29,6 +29,7 @@ use bevy::render::view::ColorGrading;
use bevy_polyline::PolylinePlugin; use bevy_polyline::PolylinePlugin;
use bevy_sprite3d::Sprite3dPlugin; use bevy_sprite3d::Sprite3dPlugin;
use bevy_trenchbroom::prelude::*; use bevy_trenchbroom::prelude::*;
use bevy_ui_gradients::UiGradientsPlugin;
use control::controller::CharacterControllerPlugin; use control::controller::CharacterControllerPlugin;
use loading_assets::AudioAssets; use loading_assets::AudioAssets;
use utils::billboards; use utils::billboards;
@@ -79,6 +80,7 @@ fn main() {
app.add_plugins(PolylinePlugin); app.add_plugins(PolylinePlugin);
app.add_plugins(Sprite3dPlugin); app.add_plugins(Sprite3dPlugin);
app.add_plugins(TrenchBroomPlugin(TrenchBroomConfig::new("hedz"))); app.add_plugins(TrenchBroomPlugin(TrenchBroomConfig::new("hedz")));
app.add_plugins(UiGradientsPlugin);
#[cfg(feature = "dbg")] #[cfg(feature = "dbg")]
{ {