made export remember where the last save location was

This commit is contained in:
grimsace
2026-04-20 14:04:59 -05:00
parent 5227aa4b4d
commit d7cf07756d
3 changed files with 24 additions and 2 deletions
+9 -2
View File
@@ -133,8 +133,11 @@ fn collect_scene_data(layout: &DungeonLayout, settings: &UiSettings) -> SceneDat
// Open a dialog to select an export destination.
pub fn select_export_target(settings: &UiSettings) -> Result<ExportTarget, String> {
if settings.export_format == ExportFormat::Folder {
let folder = FileDialog::new()
.set_title("Export composite masks folder")
let mut dialog = FileDialog::new().set_title("Export composite masks folder");
if let Some(ref last_path) = settings.last_export_path {
dialog = dialog.set_directory(last_path);
}
let folder = dialog
.pick_folder()
.ok_or_else(|| "Export canceled".to_string())?;
return Ok(ExportTarget::Folder(folder));
@@ -149,6 +152,10 @@ pub fn select_export_target(settings: &UiSettings) -> Result<ExportTarget, Strin
.set_file_name(&default_name)
.add_filter(settings.export_format.label(), &[ext]);
if let Some(ref last_path) = settings.last_export_path {
dialog = dialog.set_directory(last_path);
}
let mut path = dialog
.save_file()
.ok_or_else(|| "Export canceled".to_string())?;
+13
View File
@@ -174,6 +174,19 @@ impl eframe::App for DungeonApp {
return;
}
};
// Update the last export path in settings to remember the directory.
match &target {
exporter::ExportTarget::File(path) => {
if let Some(parent) = path.parent() {
self.settings.last_export_path = Some(parent.to_string_lossy().to_string());
}
}
exporter::ExportTarget::Folder(path) => {
self.settings.last_export_path = Some(path.to_string_lossy().to_string());
}
}
let layout = self.layout.clone();
let settings = self.settings.clone();
let (tx, rx) = mpsc::channel();
+2
View File
@@ -131,6 +131,7 @@ pub struct UiSettings {
pub export_height: u32,
pub allow_export_aspect_change: bool,
pub export_show_grid: bool,
pub last_export_path: Option<String>,
pub add_tool: AddTool,
pub add_text_value: String,
pub min_start_marker_size: usize,
@@ -184,6 +185,7 @@ impl Default for UiSettings {
export_height: 1080,
allow_export_aspect_change: false,
export_show_grid: true,
last_export_path: None,
add_tool: AddTool::None,
add_text_value: "Text".to_string(),
min_start_marker_size: 1,