Use sync file dialog for screenshots
This commit is contained in:
		
							parent
							
								
									422fe23cf2
								
							
						
					
					
						commit
						3ac13d0cf2
					
				| 
						 | 
					@ -311,12 +311,11 @@ impl GameWindow {
 | 
				
			||||||
        self.client
 | 
					        self.client
 | 
				
			||||||
            .send_command(EmulatorCommand::Screenshot(self.sim_id, tx));
 | 
					            .send_command(EmulatorCommand::Screenshot(self.sim_id, tx));
 | 
				
			||||||
        let bytes = rx.await.context("Could not take screenshot")?;
 | 
					        let bytes = rx.await.context("Could not take screenshot")?;
 | 
				
			||||||
        let file = rfd::AsyncFileDialog::new()
 | 
					        let file = rfd::FileDialog::new()
 | 
				
			||||||
            .add_filter("PNG images", &["png"])
 | 
					            .add_filter("PNG images", &["png"])
 | 
				
			||||||
            .set_file_name("screenshot.png")
 | 
					            .set_file_name("screenshot.png")
 | 
				
			||||||
            .save_file()
 | 
					            .save_file();
 | 
				
			||||||
            .await;
 | 
					        let Some(path) = file else {
 | 
				
			||||||
        let Some(file) = file else {
 | 
					 | 
				
			||||||
            return Ok(None);
 | 
					            return Ok(None);
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        if bytes.len() != 384 * 224 * 2 {
 | 
					        if bytes.len() != 384 * 224 * 2 {
 | 
				
			||||||
| 
						 | 
					@ -328,10 +327,8 @@ impl GameWindow {
 | 
				
			||||||
            let y = (index / 2) / 384;
 | 
					            let y = (index / 2) / 384;
 | 
				
			||||||
            screencap.put_pixel(x as u32, y as u32, image::Luma([pixel]));
 | 
					            screencap.put_pixel(x as u32, y as u32, image::Luma([pixel]));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        screencap
 | 
					        screencap.save(&path).context("Could not save screenshot")?;
 | 
				
			||||||
            .save(&file.path())
 | 
					        Ok(Some(path.display().to_string()))
 | 
				
			||||||
            .context("Could not save screenshot")?;
 | 
					 | 
				
			||||||
        Ok(Some(file.path().display().to_string()))
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn show_options_menu(&mut self, ctx: &Context, ui: &mut Ui) {
 | 
					    fn show_options_menu(&mut self, ctx: &Context, ui: &mut Ui) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue