mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
FileDialog.
This commit is contained in:
parent
09c2264de4
commit
7b6dac8e0b
2 changed files with 16 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Dalamud.Interface.ImGuiFileDialog;
|
||||||
using Dalamud.Interface.ImGuiNotification;
|
using Dalamud.Interface.ImGuiNotification;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
|
|
@ -41,6 +42,7 @@ public class EphemeralConfig : ISavable, IDisposable, IService
|
||||||
public string LastModPath { get; set; } = string.Empty;
|
public string LastModPath { get; set; } = string.Empty;
|
||||||
public bool AdvancedEditingOpen { get; set; } = false;
|
public bool AdvancedEditingOpen { get; set; } = false;
|
||||||
public bool ForceRedrawOnFileChange { get; set; } = false;
|
public bool ForceRedrawOnFileChange { get; set; } = false;
|
||||||
|
public FileDialog.SortingField FilePickerSortingField { get; set; } = FileDialog.SortingField.FileName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load the current configuration.
|
/// Load the current configuration.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class FileDialogService : IDisposable, IUiService
|
||||||
public FileDialogService(CommunicatorService communicator, Configuration config)
|
public FileDialogService(CommunicatorService communicator, Configuration config)
|
||||||
{
|
{
|
||||||
_communicator = communicator;
|
_communicator = communicator;
|
||||||
_manager = SetupFileManager(config.ModDirectory);
|
_manager = SetupFileManager(config);
|
||||||
_communicator.ModDirectoryChanged.Subscribe(OnModDirectoryChange, ModDirectoryChanged.Priority.FileDialogService);
|
_communicator.ModDirectoryChanged.Subscribe(OnModDirectoryChange, ModDirectoryChanged.Priority.FileDialogService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,6 +65,8 @@ public class FileDialogService : IDisposable, IUiService
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
_manager.SetDefaultSortOrder = null;
|
||||||
|
_manager.GetDefaultSortOrder = null;
|
||||||
_startPaths.Clear();
|
_startPaths.Clear();
|
||||||
_manager.Reset();
|
_manager.Reset();
|
||||||
_communicator.ModDirectoryChanged.Unsubscribe(OnModDirectoryChange);
|
_communicator.ModDirectoryChanged.Unsubscribe(OnModDirectoryChange);
|
||||||
|
|
@ -115,12 +117,21 @@ public class FileDialogService : IDisposable, IUiService
|
||||||
?? ".";
|
?? ".";
|
||||||
|
|
||||||
/// <summary> Set up the file selector with the right flags and custom side bar items. </summary>
|
/// <summary> Set up the file selector with the right flags and custom side bar items. </summary>
|
||||||
private static FileDialogManager SetupFileManager(string modDirectory)
|
private static FileDialogManager SetupFileManager(Configuration config)
|
||||||
{
|
{
|
||||||
var fileManager = new FileDialogManager
|
var fileManager = new FileDialogManager
|
||||||
{
|
{
|
||||||
AddedWindowFlags = ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoDocking,
|
AddedWindowFlags = ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoDocking,
|
||||||
};
|
};
|
||||||
|
fileManager.SetDefaultSortOrder = v =>
|
||||||
|
{
|
||||||
|
if (v == config.Ephemeral.FilePickerSortingField)
|
||||||
|
return;
|
||||||
|
|
||||||
|
config.Ephemeral.FilePickerSortingField = v;
|
||||||
|
config.Ephemeral.Save();
|
||||||
|
};
|
||||||
|
fileManager.GetDefaultSortOrder = () => config.Ephemeral.FilePickerSortingField;
|
||||||
|
|
||||||
if (Functions.GetDownloadsFolder(out var downloadsFolder))
|
if (Functions.GetDownloadsFolder(out var downloadsFolder))
|
||||||
fileManager.CustomSideBarItems.Add(("Downloads", downloadsFolder, FontAwesomeIcon.Download, -1));
|
fileManager.CustomSideBarItems.Add(("Downloads", downloadsFolder, FontAwesomeIcon.Download, -1));
|
||||||
|
|
@ -130,7 +141,7 @@ public class FileDialogService : IDisposable, IUiService
|
||||||
fileManager.CustomSideBarItems.Add(($"{name}##{idx}", path, FontAwesomeIcon.Folder, -1));
|
fileManager.CustomSideBarItems.Add(($"{name}##{idx}", path, FontAwesomeIcon.Folder, -1));
|
||||||
|
|
||||||
// Add Penumbra Root. This is not updated if the root changes right now.
|
// Add Penumbra Root. This is not updated if the root changes right now.
|
||||||
fileManager.CustomSideBarItems.Add(("Root Directory", modDirectory, FontAwesomeIcon.Gamepad, 0));
|
fileManager.CustomSideBarItems.Add(("Root Directory", config.ModDirectory, FontAwesomeIcon.Gamepad, 0));
|
||||||
|
|
||||||
// Remove Videos and Music.
|
// Remove Videos and Music.
|
||||||
fileManager.CustomSideBarItems.Add(("Videos", string.Empty, 0, -1));
|
fileManager.CustomSideBarItems.Add(("Videos", string.Empty, 0, -1));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue