tree button (not yet clickable)
This commit is contained in:
parent
b448c40e54
commit
7bd31de293
65
Cargo.lock
generated
65
Cargo.lock
generated
@ -77,6 +77,12 @@ dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.11"
|
||||
@ -734,6 +740,7 @@ dependencies = [
|
||||
"bevy_ecs",
|
||||
"bevy_gizmos",
|
||||
"bevy_hierarchy",
|
||||
"bevy_image",
|
||||
"bevy_input",
|
||||
"bevy_log",
|
||||
"bevy_math",
|
||||
@ -1751,6 +1758,15 @@ dependencies = [
|
||||
"windows 0.54.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.14"
|
||||
@ -2210,6 +2226,15 @@ version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.2"
|
||||
@ -2222,6 +2247,16 @@ version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.4"
|
||||
@ -2738,6 +2773,7 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder-lite",
|
||||
"num-traits",
|
||||
"png",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3046,6 +3082,16 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "22.1.0"
|
||||
@ -3637,6 +3683,19 @@ version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "3.7.3"
|
||||
@ -4056,6 +4115,12 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "skrifa"
|
||||
version = "0.22.3"
|
||||
|
@ -32,6 +32,7 @@ bevy = { version = "0.15", default-features = false, features = [
|
||||
"sysinfo_plugin",
|
||||
"webgl2",
|
||||
"wayland",
|
||||
"png"
|
||||
]}
|
||||
bevy-inspector-egui = { version = "0.28", default-features = false, features = [
|
||||
"bevy_image",
|
||||
|
BIN
assets/ui/tree.png
Normal file
BIN
assets/ui/tree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/ui/tree_disabled.png
Normal file
BIN
assets/ui/tree_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
35
src/ui.rs
35
src/ui.rs
@ -1,6 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use mevy::*;
|
||||
use bevy::{input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::{dbg, HashMap}, window::PrimaryWindow};
|
||||
use bevy::{asset::embedded_asset, input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::{dbg, HashMap}, window::PrimaryWindow};
|
||||
|
||||
use crate::map::{self, MapMarker};
|
||||
|
||||
@ -9,6 +8,7 @@ impl bevy::prelude::Plugin for Plugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup)
|
||||
.add_systems(Update, zoom_with_scroll);
|
||||
embedded_asset!(app, "../assets/ui/tree.png");
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,12 +19,15 @@ struct PointersDragging(HashMap<PointerId, Vec2>);
|
||||
pub struct MapUIComponent;
|
||||
|
||||
fn setup(
|
||||
mut world: Commands
|
||||
mut world: Commands,
|
||||
asset_server: Res<AssetServer>
|
||||
) {
|
||||
spawn!{
|
||||
Node {width: 100%, height: 100%, display: Display::Block, flex_direction: FlexDirection::Column, !};
|
||||
PointersDragging(HashMap::new());
|
||||
MapUIComponent;
|
||||
Node {width: 100%, height: 100%, display: Display::Flex, flex_direction: FlexDirection::Column, !};
|
||||
PickingBehavior {
|
||||
should_block_lower: false,
|
||||
is_hoverable: true
|
||||
};
|
||||
.observe(move |trigger: Trigger<Pointer<DragStart>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||
if trigger.button == PointerButton::Primary {
|
||||
if let Ok(mut ptrs) = ptrs.get_mut(trigger.target) {
|
||||
@ -65,16 +68,32 @@ fn setup(
|
||||
}
|
||||
}
|
||||
);
|
||||
[map][
|
||||
Node{
|
||||
flex_grow: 1.,
|
||||
!};
|
||||
PointersDragging(HashMap::new());
|
||||
MapUIComponent;
|
||||
PickingBehavior {
|
||||
should_block_lower: false,
|
||||
is_hoverable: true
|
||||
};
|
||||
]
|
||||
[
|
||||
Node{
|
||||
width:100%,
|
||||
width: 100%,
|
||||
height: 10vh,
|
||||
align_self: AlignSelf::FlexEnd,
|
||||
!};
|
||||
Button;
|
||||
BorderColor(#F00);
|
||||
BackgroundColor(#77767b);
|
||||
[
|
||||
Text::new("Button")
|
||||
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/tree.png"));
|
||||
Node {
|
||||
height: 80%,
|
||||
margin: [>1vh],
|
||||
!};
|
||||
]
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user