From 7bd31de293e9c42fd0e55b2e1091aa92fbe25891 Mon Sep 17 00:00:00 2001 From: Arkitu <85173315+Arkitu@users.noreply.github.com> Date: Thu, 23 Jan 2025 19:42:39 +0100 Subject: [PATCH] tree button (not yet clickable) --- Cargo.lock | 65 ++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + assets/ui/tree.png | Bin 0 -> 2848 bytes assets/ui/tree_disabled.png | Bin 0 -> 1955 bytes src/ui.rs | 35 ++++++++++++++----- 5 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 assets/ui/tree.png create mode 100644 assets/ui/tree_disabled.png diff --git a/Cargo.lock b/Cargo.lock index 9a4cf0a..83e5dc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index 07f3f64..9e20725 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", diff --git a/assets/ui/tree.png b/assets/ui/tree.png new file mode 100644 index 0000000000000000000000000000000000000000..e7827982045faebd2b3a3da06d6c12d9df2a22f0 GIT binary patch literal 2848 zcmV+*3*YpKP)9&kS~KY*(=a%3xQGXY44Of&*10pzXp*(`}(rHw~2l^=s1z%&KbD#54_Rvj|2_ zr6z3^I}%B|s0vY}R)Qw8NSkI82!@ED*dB-&&sg|_$b(JrN6!Cwo;71;JYVQcg(|w^(XeYnPc5;*=&Y#mT9$63xl86)mm)2*4R$DV`7_k;ripK+OV} zn3(9}f9O@Jza%bbAcTGv!WpW8ss)gZ^Uw0>QE~(Z_Z|i_nauH6EH+D3P?Z3<)kj%< z?~rTtx_~a^myQG{_6dWO6@MNJRpeoSZy@mhTchEotY5`A-%> zMIpIt0i@IEXSoY9NDi%G5uAjr%Duj<8~`of8Q(0}Uj3b&oh5BnQUHi6a4qC8j%;EW z-{_hR1%PZH37?Dk#xl#c+qF^epr`<{{e0`P{mf#9(hHL`$;aH{ocCN?LmRa=w0cK( zTZ}9tF+V@Qt5}_&q1bO_i#$;>92oq)TmPp^w?}B?_GQobrRZ(nPTj5Dw0FxM+QH|B z6K!p6g)RFF{ji`1up#b`%wDE5$+L8cA0dKji8Mb%`@Z~LPYgIWm16loK>?&vsc|y2 z^~3O|Z@lgqUNi@~en3w~zHO=y3WkFF1b{vyt7U);1Fih@^*89u%{NIVFupGY(_p(E zXD=|2`&^y?Os(-FuK(iFulO-ds@TtA;io-6Cc~IzFA&T10(q4{j{676Fyq7J|NMg^ zN{tWTX`c38w{%je5$(;*&3UEbJP%-6>_4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O2 z{kz=f6|xI}f)jNG{6tm4?DsVV1~@!CEKE#He8P{zps;|Ze|mX&xd6-<+YL;mQdwYH ztx7s%QJ0pMjI6dAZ4g08i>O>W+fS25>m=$PmIXr??-3MupM_*qb zmAFIP;NZ{U;2T|Fv(_bSb8|Br_gOk8Cns=maq-*hMn^}Xx3?GKf&xBV?3uRFH_%!} z5ScMl^mv?`Mt662Rb6*;a|3aK_vhgH`ueM_rjfC93MFfRTgX$kyNK-V?NxPM5Ckwd zI0%-BrCVrhy@I1YLLrru+YrL#+A6Ip4S63HIPELX)VrvsiIMFRU>Jpxzlfm$n zHql(FSS-Tn>1oy1XEGThfnem{^Z4=n_V#u+o6W|$YUgwt$toC|z0c!&T14Uo}2b@+%OBjO`;~wxzoD_fwhKGl#XJJ_F^*B?f3x&cicur#K z0&o`Av>1hANyOq+A_S05r+exsqe?`(sMClQPr0`Q!q z!~h}GL9KCvM3N$a&rkCs1E`ZEJPCL& zfJTpS$0cE}MUVsmG~~x|w^9WlnMVD%?@Pj73!u&=;7S7U7_S9T&l2!Ec>O5owE&pR zcMyi5w~erUj{!np;NjuH+c>~?0o1hwT#3(tpzi`;891MpguN9&BTK-Q_`D?StpFNX z0R5yW2HY633>fU|YAmK5-6pu$!kH-@~c3m6(2 zn!z_yCDla~!g!%jD1s+=B>z()ycdnIym0{(q~YM(IJ!1{e}C`I z0og{HMA?Q0AALTxq6xqbU#N@7#l=N+<;D)WO@ pi=Zfqq9}@@D2k#eilQhk@*l~ym{_K_qR9XN002ovPDHLkV1lT~Y^neN literal 0 HcmV?d00001 diff --git a/src/ui.rs b/src/ui.rs index f135c5a..9ce9ccd 100644 --- a/src/ui.rs +++ b/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); pub struct MapUIComponent; fn setup( - mut world: Commands + mut world: Commands, + asset_server: Res ) { 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>, 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], + !}; ] ] }