using Dalamud.Interface; using Dalamud.Plugin.Services; using ImGuiNET; using OtterGui; using OtterGui.Classes; using OtterGui.Filesystem; using OtterGui.FileSystem.Selector; using OtterGui.Log; using OtterGui.Raii; using System; using System.Numerics; using static CustomizePlus.UI.Windows.MainWindow.Tabs.Templates.TemplateFileSystemSelector; using Newtonsoft.Json; using System.Windows.Forms; using System.Linq; using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.ImGuiFileDialog; using System.IO; using System.Reflection; using CustomizePlus.Templates; using CustomizePlus.Configuration.Data; using CustomizePlus.Profiles; using CustomizePlus.Core.Helpers; using CustomizePlus.Anamnesis; using CustomizePlus.Profiles.Data; using CustomizePlus.Templates.Events; using CustomizePlus.Profiles.Events; using CustomizePlus.Templates.Data; using CustomizePlus.Configuration.Helpers; using CustomizePlus.Configuration.Data.Version3; using CustomizePlus.GameData.Data; using static OtterGui.Classes.MessageService; using CustomizePlus.Configuration.Data.Version2; namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Templates; public class TemplateFileSystemSelector : FileSystemSelector { private readonly PluginConfiguration _configuration; private readonly TemplateEditorManager _editorManager; private readonly TemplateManager _templateManager; private readonly TemplateChanged _templateChangedEvent; private readonly ProfileChanged _profileChangedEvent; private readonly ProfileManager _profileManager; private readonly MessageService _messageService; private readonly PoseFileBoneLoader _poseFileBoneLoader; private readonly Logger _logger; private readonly PopupSystem _popupSystem; private readonly FileDialogManager _importFilePicker = new(); private string? _clipboardText; private Template? _cloneTemplate; private string _newName = string.Empty; public bool IncognitoMode { get => _configuration.UISettings.IncognitoMode; set { _configuration.UISettings.IncognitoMode = value; _configuration.Save(); } } public struct TemplateState { public ColorId Color; } public TemplateFileSystemSelector( TemplateFileSystem fileSystem, IKeyState keyState, Logger logger, PluginConfiguration configuration, TemplateEditorManager editorManager, TemplateManager templateManager, TemplateChanged templateChangedEvent, ProfileChanged profileChangedEvent, ProfileManager profileManager, MessageService messageService, PoseFileBoneLoader poseFileBoneLoader, PopupSystem popupSystem) : base(fileSystem, keyState, logger, allowMultipleSelection: true) { _configuration = configuration; _editorManager = editorManager; _templateManager = templateManager; _templateChangedEvent = templateChangedEvent; _profileChangedEvent = profileChangedEvent; _profileManager = profileManager; _messageService = messageService; _poseFileBoneLoader = poseFileBoneLoader; _logger = logger; _popupSystem = popupSystem; _popupSystem.RegisterPopup("template_editor_active_warn", "You need to stop bone editing before doing this action"/*, false, new Vector2(5, 12)*/); _popupSystem.RegisterPopup("clipboard_data_unsupported_version", "Clipboard data you are trying to use cannot be used in this version of Customize+."); _templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.TemplateFileSystemSelector); _profileChangedEvent.Subscribe(OnProfileChange, ProfileChanged.Priority.TemplateFileSystemSelector); AddButton(NewButton, 0); AddButton(AnamnesisImportButton, 10); AddButton(ClipboardImportButton, 20); AddButton(CloneButton, 30); AddButton(DeleteButton, 1000); SetFilterTooltip(); } public void Dispose() { base.Dispose(); _templateChangedEvent.Unsubscribe(OnTemplateChange); _profileChangedEvent.Unsubscribe(OnProfileChange); } protected override uint ExpandedFolderColor => ColorId.FolderExpanded.Value(); protected override uint CollapsedFolderColor => ColorId.FolderCollapsed.Value(); protected override uint FolderLineColor => ColorId.FolderLine.Value(); protected override bool FoldersDefaultOpen => _configuration.UISettings.FoldersDefaultOpen; protected override void DrawLeafName(FileSystem