you can now import images

This commit is contained in:
RustyStriker 2022-08-01 19:40:21 +03:00
parent 1da4c5b473
commit 374fce86e1
4 changed files with 265 additions and 13 deletions

249
Cargo.lock generated
View file

@ -194,6 +194,18 @@ version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
[[package]]
name = "atk-sys"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6"
dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps",
]
[[package]]
name = "atomic_refcell"
version = "0.1.8"
@ -848,7 +860,7 @@ dependencies = [
"bevy_input",
"bevy_math",
"bevy_utils",
"raw-window-handle",
"raw-window-handle 0.4.3",
"web-sys",
]
@ -866,7 +878,7 @@ dependencies = [
"bevy_utils",
"bevy_window",
"crossbeam-channel",
"raw-window-handle",
"raw-window-handle 0.4.3",
"wasm-bindgen",
"web-sys",
"winit",
@ -962,6 +974,16 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cairo-sys-rs"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
dependencies = [
"libc",
"system-deps",
]
[[package]]
name = "cc"
version = "1.0.73"
@ -986,6 +1008,15 @@ dependencies = [
"nom",
]
[[package]]
name = "cfg-expr"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db"
dependencies = [
"smallvec",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
@ -1582,6 +1613,36 @@ dependencies = [
"byteorder",
]
[[package]]
name = "gdk-pixbuf-sys"
version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7"
dependencies = [
"gio-sys",
"glib-sys",
"gobject-sys",
"libc",
"system-deps",
]
[[package]]
name = "gdk-sys"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88"
dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
"gio-sys",
"glib-sys",
"gobject-sys",
"libc",
"pango-sys",
"pkg-config",
"system-deps",
]
[[package]]
name = "gethostname"
version = "0.2.3"
@ -1639,6 +1700,19 @@ dependencies = [
"winapi",
]
[[package]]
name = "gio-sys"
version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d"
dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps",
"winapi",
]
[[package]]
name = "glam"
version = "0.21.2"
@ -1649,6 +1723,16 @@ dependencies = [
"serde",
]
[[package]]
name = "glib-sys"
version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
dependencies = [
"libc",
"system-deps",
]
[[package]]
name = "glob"
version = "0.3.0"
@ -1713,6 +1797,17 @@ dependencies = [
"xi-unicode",
]
[[package]]
name = "gobject-sys"
version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
dependencies = [
"glib-sys",
"libc",
"system-deps",
]
[[package]]
name = "gpu-alloc"
version = "0.5.3"
@ -1752,6 +1847,24 @@ dependencies = [
"bitflags",
]
[[package]]
name = "gtk-sys"
version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84"
dependencies = [
"atk-sys",
"cairo-sys-rs",
"gdk-pixbuf-sys",
"gdk-sys",
"gio-sys",
"glib-sys",
"gobject-sys",
"libc",
"pango-sys",
"system-deps",
]
[[package]]
name = "guillotiere"
version = "0.6.2"
@ -1801,6 +1914,12 @@ dependencies = [
"serde",
]
[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]]
name = "hermit-abi"
version = "0.1.19"
@ -2595,6 +2714,18 @@ dependencies = [
"ttf-parser",
]
[[package]]
name = "pango-sys"
version = "0.15.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa"
dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps",
]
[[package]]
name = "parking"
version = "2.0.0"
@ -2771,6 +2902,15 @@ dependencies = [
"cty",
]
[[package]]
name = "raw-window-handle"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a"
dependencies = [
"cty",
]
[[package]]
name = "rectangle-pack"
version = "0.4.2"
@ -2818,6 +2958,30 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
[[package]]
name = "rfd"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea"
dependencies = [
"block",
"dispatch",
"glib-sys",
"gobject-sys",
"gtk-sys",
"js-sys",
"lazy_static",
"log",
"objc",
"objc-foundation",
"objc_id",
"raw-window-handle 0.5.0",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"windows",
]
[[package]]
name = "rodio"
version = "0.15.0"
@ -2921,6 +3085,7 @@ dependencies = [
"bevy",
"bevy_egui",
"bevy_prototype_lyon",
"rfd",
]
[[package]]
@ -3026,6 +3191,19 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "system-deps"
version = "6.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1a45a1c4c9015217e12347f2a411b57ce2c4fc543913b14b6fe40483328e709"
dependencies = [
"cfg-expr",
"heck",
"pkg-config",
"toml",
"version-compare",
]
[[package]]
name = "taffy"
version = "0.1.0"
@ -3264,6 +3442,12 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version-compare"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73"
[[package]]
name = "version_check"
version = "0.9.4"
@ -3400,7 +3584,7 @@ dependencies = [
"log",
"naga",
"parking_lot 0.12.1",
"raw-window-handle",
"raw-window-handle 0.4.3",
"smallvec",
"wasm-bindgen",
"wasm-bindgen-futures",
@ -3427,7 +3611,7 @@ dependencies = [
"naga",
"parking_lot 0.12.1",
"profiling",
"raw-window-handle",
"raw-window-handle 0.4.3",
"smallvec",
"thiserror",
"web-sys",
@ -3465,7 +3649,7 @@ dependencies = [
"parking_lot 0.12.1",
"profiling",
"range-alloc",
"raw-window-handle",
"raw-window-handle 0.4.3",
"renderdoc-sys",
"thiserror",
"wasm-bindgen",
@ -3529,17 +3713,30 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
dependencies = [
"windows_aarch64_msvc 0.37.0",
"windows_i686_gnu 0.37.0",
"windows_i686_msvc 0.37.0",
"windows_x86_64_gnu 0.37.0",
"windows_x86_64_msvc 0.37.0",
]
[[package]]
name = "windows-sys"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_msvc",
"windows_aarch64_msvc 0.36.1",
"windows_i686_gnu 0.36.1",
"windows_i686_msvc 0.36.1",
"windows_x86_64_gnu 0.36.1",
"windows_x86_64_msvc 0.36.1",
]
[[package]]
@ -3548,30 +3745,60 @@ version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]]
name = "windows_aarch64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]]
name = "windows_i686_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]]
name = "windows_i686_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]]
name = "windows_x86_64_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]]
name = "windows_x86_64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]]
name = "winit"
version = "0.26.1"
@ -3595,7 +3822,7 @@ dependencies = [
"objc",
"parking_lot 0.11.2",
"percent-encoding",
"raw-window-handle",
"raw-window-handle 0.4.3",
"wasm-bindgen",
"web-sys",
"winapi",

View file

@ -9,3 +9,4 @@ edition = "2021"
bevy = "0.8.0"
bevy_egui = { version = "0.15.0", features = ["manage_clipboard"] }
bevy_prototype_lyon = "0.6.0"
rfd = "0.10.0"

View file

@ -10,7 +10,16 @@ Eventually, this will be a level editor... But until then, I guess it's just fun
- [x] Highlight opened shapes in the tree(maybe allow only 1 opened shape? - I dont think egui allows me to do that)
- [x] Drag camera around
- [x] Zome in/out
- [ ] Import images
- [ ] Import images:
- [ ] Insert images
- [ ] Show images in tree view
- [ ] Show/Hide images
- [ ] Move/Drag images around
- [ ] Control images Z value(so we could reorder them)
- [ ] Delete images
- [ ] Name images
- [ ] Duplicate images(and also shapes maybe?)?
- [ ] Show hide shapes
- [ ] Snap to grid
- [ ] Change grid size
- [ ] Show/Hide grid(also make a visible grid in the first place)
@ -18,3 +27,5 @@ Eventually, this will be a level editor... But until then, I guess it's just fun
- [ ] Save? (maybe just import and export directly?)
- [ ] Export
- [ ] Import
- Quality of life todo:
- [ ] Double click on shape in tree view will center the relevant shape

View file

@ -5,6 +5,8 @@ use bevy_prototype_lyon::prelude::{Path, DrawMode, FillMode, StrokeMode};
use crate::*;
pub fn action_bar_sys(
mut coms: Commands,
assets: Res<AssetServer>,
mut egui_ctx: ResMut<EguiContext>,
mut state: ResMut<UiState>,
colors: Res<ButtonsColors>,
@ -28,7 +30,18 @@ pub fn action_bar_sys(
hui.label(" | ");
if hui.button(" I ").on_hover_text("Import Image").clicked() {
println!("Importing Images is still not supported!");
let file = rfd::FileDialog::new()
.add_filter("Pngs", &["png"])
.set_directory("./")
.set_title("Please dont try to pick a cat instead of an image(although you can pick a cat image)")
.pick_file();
if let Some(file) = file {
let image: Handle<Image> = assets.load(file);
coms.spawn_bundle(SpriteBundle {
texture: image,
..Default::default()
});
}
}
hui.label(": :");