diff --git a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs index 4ae0dd4..a4defd2 100644 --- a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs +++ b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs @@ -36,4 +36,5 @@ public class MareConfig : IMareConfiguration public int TransferBarsWidth { get; set; } = 250; public int Version { get; set; } = 1; public NotificationLocation WarningNotification { get; set; } = NotificationLocation.Both; + public string ExportFolder { get; set; } = string.Empty; } \ No newline at end of file diff --git a/MareSynchronos/UI/GposeUi.cs b/MareSynchronos/UI/GposeUi.cs index 3bb3702..7b44bc1 100644 --- a/MareSynchronos/UI/GposeUi.cs +++ b/MareSynchronos/UI/GposeUi.cs @@ -43,12 +43,16 @@ public class GposeUi : WindowMediatorSubscriberBase { if (UiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF")) { - _fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, path) => + _fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, paths) => { if (!success) return; + if (paths.FirstOrDefault() is not { } path) return; + + _configService.Current.ExportFolder = Path.GetDirectoryName(path) ?? string.Empty; + _configService.Save(); Task.Run(() => _mareCharaFileManager.LoadMareCharaFile(path)); - }); + }, 1, Directory.Exists(_configService.Current.ExportFolder) ? _configService.Current.ExportFolder : null); } UiSharedService.AttachToolTip("Applies it to the currently selected GPose actor"); if (_mareCharaFileManager.LoadedCharaFile != null) diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 1917d1e..db5567c 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -362,10 +362,16 @@ public class SettingsUi : WindowMediatorSubscriberBase ImGui.InputTextWithHint("Export Descriptor", "This description will be shown on loading the data", ref _exportDescription, 255); if (UiSharedService.IconTextButton(FontAwesomeIcon.Save, "Export Character as MCDF")) { - _uiShared.FileDialogManager.SaveFileDialog("Export Character to file", ".mcdf", "export.mcdf", ".mcdf", (success, path) => + string defaultFileName = string.IsNullOrEmpty(_exportDescription) + ? "export.mcdf" + : string.Join('_', $"{_exportDescription}.mcdf".Split(Path.GetInvalidFileNameChars())); + _uiShared.FileDialogManager.SaveFileDialog("Export Character to file", ".mcdf", defaultFileName, ".mcdf", (success, path) => { if (!success) return; + _configService.Current.ExportFolder = Path.GetDirectoryName(path) ?? string.Empty; + _configService.Save(); + Task.Run(() => { try @@ -378,7 +384,7 @@ public class SettingsUi : WindowMediatorSubscriberBase _logger.LogCritical(ex, "Error saving data"); } }); - }); + }, Directory.Exists(_configService.Current.ExportFolder) ? _configService.Current.ExportFolder : null); } UiSharedService.ColorTextWrapped("Note: For best results make sure you have everything you want to be shared as well as the correct character appearance" + " equipped and redraw your character before exporting.", ImGuiColors.DalamudYellow);