pub fn file_dialog(
    mut query: Query<'_, '_, &mut Concrete>,
    mut name: ResMut<'_, PolyName>,
    file_dialog_state: Res<'_, FileDialogState>,
    file_dialog: NonSend<'_, FileDialogToken>,
) {
    if file_dialog_state.is_changed() {
        match file_dialog_state.mode {
            // We want to save a file.
            FileDialogMode::Save => {
                if let Some(path) = file_dialog.save_file(file_dialog_state.unwrap_name()) {
                    if let Some(p) = query.iter_mut().next() {
                        if let Err(err) = p.con().to_path(&path, Default::default()) {
                            eprintln!("File saving failed: {}", err);
                        }
                    }
                }
            }

            // We want to open a file.
            FileDialogMode::Open => {
                if let Some(path) = file_dialog.pick_file() {
                    if let Some(mut p) = query.iter_mut().next() {
                        match Concrete::from_path(&path) {
                            Ok(q) => {
                                *p = q;
                                let file_name = path.file_name().unwrap().to_str().unwrap();
                                name.0 = file_name[..file_name.len()-4].into();
                            }
                            Err(err) => eprintln!("File open failed: {}", err),
                        }
                    }
                }
            }

            // There's nothing to do with the file dialog this frame.
            FileDialogMode::Disabled => {}
        }
    }
}
/// The system in charge of showing the file dialog.
The system in charge of showing the file dialog.
The system in charge of showing the file dialog .
pub fn file_dialog(
    mut query: Query<'_, '_, &mut Concrete>,
    mut name: ResMut<'_, PolyName>,
    file_dialog_state: Res<'_, FileDialogState>,
    file_dialog: NonSend<'_, FileDialogToken>,
) {
    if file_dialog_state.is_changed() {
        match file_dialog_state.mode {
            // We want to save a file.
            FileDialogMode::Save => {
                if let Some(path) = file_dialog.save_file(file_dialog_state.unwrap_name()) {
                    if let Some(p) = query.iter_mut().next() {
                        if let Err(err) = p.con().to_path(&path, Default::default()) {
                            eprintln!("File saving failed: {}", err);
                        }
                    }
                }
            }
            // We want to open a file.
            FileDialogMode::Open => {
                if let Some(path) = file_dialog.pick_file() {
                    if let Some(mut p) = query.iter_mut().next() {
                        match Concrete::from_path(&path) {
                            Ok(q) => {
                                *p = q;
                                let file_name = path.file_name().unwrap().to_str().unwrap();
                                name.0 = file_name[..file_name.len()-4].into();
                            }
                            Err(err) => eprintln!("File open failed: {}", err),
                        }
                    }
                }
            }
            // There's nothing to do with the file dialog this frame.
            FileDialogMode::Disabled => {}
        }
    }
}
pub fn file_dialog ( mut query : Query < ' _ , ' _ , & mut Concrete > , mut name : ResMut < ' _ , PolyName > , file_dialog_state : Res < ' _ , FileDialogState > , file_dialog : NonSend < ' _ , FileDialogToken > , ) { if file_dialog_state . is_changed ( ) { match file_dialog_state . mode { // We want to save a file. FileDialogMode :: Save => { if let Some ( path ) = file_dialog . save_file ( file_dialog_state . unwrap_name ( ) ) { if let Some ( p ) = query . iter_mut ( ) . next ( ) { if let Err ( err ) = p . con ( ) . to_path ( & path , Default :: default ( ) ) { eprintln ! ( " " err ) ; } } } } // We want to open a file. FileDialogMode :: Open => { if let Some ( path ) = file_dialog . pick_file ( ) { if let Some ( mut p ) = query . iter_mut ( ) . next ( ) { match Concrete :: from_path ( & path ) { Ok ( q ) => { * p = q ; let file_name = path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ; name . 0 = file_name [ .. file_name . len ( ) - 4 ] . into ( ) ; } Err ( err ) => eprintln ! ( " " err ) , } } } } // There's nothing to do with the file dialog this frame. FileDialogMode :: Disabled => { } } } }
The system in charge of showing the file dialog.
The system in charge of showing the file dialog .
query
Query<'_, '_, &mut Concrete>
name
ResMut<'_, PolyName>
file_dialog_state
Res<'_, FileDialogState>
file_dialog
NonSend<'_, FileDialogToken>