mirror of https://github.com/Leinnan/rpack.git
File picker on saving on desktop
This commit is contained in:
parent
a1675b6892
commit
0d85d6a2e1
|
|
@ -3,6 +3,7 @@ use std::{collections::HashMap, io::Cursor};
|
|||
use egui::{CollapsingHeader, Color32, DroppedFile, FontFamily, FontId, Image, RichText, Vec2};
|
||||
use image::DynamicImage;
|
||||
|
||||
use rfd::FileDialog;
|
||||
use serde_json::Value;
|
||||
use texture_packer::{importer::ImageImporter, TexturePacker, TexturePackerConfig};
|
||||
pub const MY_ACCENT_COLOR32: Color32 = Color32::from_rgb(230, 102, 1);
|
||||
|
|
@ -211,7 +212,9 @@ impl TemplateApp {
|
|||
{
|
||||
let data = self.data.clone().unwrap().data;
|
||||
use std::io::Write;
|
||||
let mut file = std::fs::File::create("result.png").unwrap();
|
||||
let path_buf = FileDialog::new().set_directory(".").add_filter("Image", &["png"]).set_file_name("output.png").save_file();
|
||||
if let Some(path) = path_buf {
|
||||
let mut file = std::fs::File::create(path).unwrap();
|
||||
let write_result = file.write_all(&data);
|
||||
if write_result.is_err() {
|
||||
self.error = Some(format!(
|
||||
|
|
@ -222,6 +225,7 @@ impl TemplateApp {
|
|||
println!("Output texture stored in {:?}", file);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
let data = self.data.clone().unwrap().data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue