diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index ef886e957..484b883ee 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -648,6 +648,7 @@ public partial class FileDialog private void AddFileNameInSelection(string name, bool setLastSelection) { this.selectedFileNames.Add(name); + this.SelectionChanged(this, this.GetFilePathName()); if (this.selectedFileNames.Count == 1) { this.fileNameBuffer = name; diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs index e33fc2fc4..b9ac634ab 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs @@ -97,6 +97,8 @@ public partial class FileDialog this.SetupSideBar(); } + public event EventHandler? SelectionChanged; + /// /// Shows the dialog. /// diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs index ee12e7424..eca65cd72 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using Dalamud.Bindings.ImGui; +using FFXIVClientStructs; + namespace Dalamud.Interface.ImGuiFileDialog; /// @@ -25,11 +27,13 @@ public class FileDialogManager #pragma warning restore SA1401 #pragma warning restore SA1201 + public event EventHandler? SelectionChanged; private FileDialog? dialog; private Action? callback; private Action>? multiCallback; private string savedPath = "."; + /// /// Create a dialog which selects an already existing folder. /// @@ -175,6 +179,13 @@ public class FileDialogManager this.multiCallback = null; } + public string? GetCurrentPath() + { + return this.dialog?.GetCurrentPath(); + } + + private void OnSelectionChange(object sender, string path) => this.SelectionChanged(sender, path); + private void SetDialog( string id, string title, @@ -200,9 +211,11 @@ public class FileDialogManager if (this.dialog is not null) { this.dialog.SortOrderChanged -= this.OnSortOrderChange; + this.dialog.SelectionChanged -= this.OnSelectionChange; } this.dialog = new FileDialog(id, title, filters, path, defaultFileName, defaultExtension, selectionCountMax, isModal, flags); + if (this.GetDefaultSortOrder is not null) { try @@ -217,6 +230,7 @@ public class FileDialogManager } this.dialog.SortOrderChanged += this.OnSortOrderChange; + this.dialog.SelectionChanged += this.OnSelectionChange; this.dialog.WindowFlags |= this.AddedWindowFlags; foreach (var (name, location, icon, position) in this.CustomSideBarItems) this.dialog.SetQuickAccess(name, location, icon, position);