you can now import images
This commit is contained in:
parent
1da4c5b473
commit
374fce86e1
4 changed files with 265 additions and 13 deletions
15
src/ui.rs
15
src/ui.rs
|
@ -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(": :");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue