11using System ;
2+ using System . IO ;
23using System . Linq ;
34using System . Numerics ;
45using System . Runtime . InteropServices ;
56using Dalamud . Game . ClientState . Keys ;
67using Dalamud . Interface ;
8+ using Dalamud . Interface . DragDrop ;
79using Dalamud . Interface . Internal . Notifications ;
810using ImGuiNET ;
911using OtterGui ;
@@ -33,12 +35,13 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
3335 private readonly CollectionManager _collectionManager ;
3436 private readonly TutorialService _tutorial ;
3537 private readonly ModImportManager _modImportManager ;
38+ private readonly IDragDropManager _dragDrop ;
3639 public ModSettings SelectedSettings { get ; private set ; } = ModSettings . Empty ;
3740 public ModCollection SelectedSettingCollection { get ; private set ; } = ModCollection . Empty ;
3841
3942 public ModFileSystemSelector ( KeyState keyState , CommunicatorService communicator , ModFileSystem fileSystem , ModManager modManager ,
4043 CollectionManager collectionManager , Configuration config , TutorialService tutorial , FileDialogService fileDialog , ChatService chat ,
41- ModImportManager modImportManager )
44+ ModImportManager modImportManager , IDragDropManager dragDrop )
4245 : base ( fileSystem , keyState , HandleException )
4346 {
4447 _communicator = communicator ;
@@ -49,6 +52,7 @@ public ModFileSystemSelector(KeyState keyState, CommunicatorService communicator
4952 _fileDialog = fileDialog ;
5053 _chat = chat ;
5154 _modImportManager = modImportManager ;
55+ _dragDrop = dragDrop ;
5256
5357 // @formatter:off
5458 SubscribeRightClickFolder ( EnableDescendants , 10 ) ;
@@ -82,6 +86,28 @@ public ModFileSystemSelector(KeyState keyState, CommunicatorService communicator
8286 OnCollectionChange ( CollectionType . Current , null , _collectionManager . Active . Current , "" ) ;
8387 }
8488
89+ private static readonly string [ ] ValidModExtensions = new [ ]
90+ {
91+ ".ttmp" ,
92+ ".ttmp2" ,
93+ ".pmp" ,
94+ ".zip" ,
95+ ".rar" ,
96+ ".7z" ,
97+ } ;
98+
99+ public new void Draw ( float width )
100+ {
101+ _dragDrop . CreateImGuiSource ( "ModDragDrop" , m => m . Extensions . Any ( e => ValidModExtensions . Contains ( e . ToLowerInvariant ( ) ) ) , m =>
102+ {
103+ ImGui . TextUnformatted ( $ "Dragging mods for import:\n \t { string . Join ( "\n \t " , m . Files . Select ( Path . GetFileName ) ) } ") ;
104+ return true ;
105+ } ) ;
106+ base . Draw ( width ) ;
107+ if ( _dragDrop . CreateImGuiTarget ( "ModDragDrop" , out var files , out _ ) )
108+ _modImportManager . AddUnpack ( files . Where ( f => ValidModExtensions . Contains ( Path . GetExtension ( f . ToLowerInvariant ( ) ) ) ) ) ;
109+ }
110+
85111 public override void Dispose ( )
86112 {
87113 base . Dispose ( ) ;
@@ -655,7 +681,7 @@ private bool ApplyFiltersAndState(ModFileSystem.Leaf leaf, out ModState state)
655681 private bool DrawFilterCombo ( ref bool everything )
656682 {
657683 using var combo = ImRaii . Combo ( "##filterCombo" , string . Empty ,
658- ImGuiComboFlags . NoPreview | ImGuiComboFlags . PopupAlignLeft | ImGuiComboFlags . HeightLargest ) ;
684+ ImGuiComboFlags . NoPreview | ImGuiComboFlags . PopupAlignLeft | ImGuiComboFlags . HeightLargest ) ;
659685 var ret = ImGui . IsItemClicked ( ImGuiMouseButton . Right ) ;
660686 if ( ! combo )
661687 return ret ;
@@ -695,12 +721,12 @@ protected override (float, bool) CustomFilters(float width)
695721
696722 ImGui . SetCursorPos ( comboPos ) ;
697723 // Draw combo button
698- using var color = ImRaii . PushColor ( ImGuiCol . Button , Colors . FilterActive , ! everything ) ;
699- var rightClick = DrawFilterCombo ( ref everything ) ;
724+ using var color = ImRaii . PushColor ( ImGuiCol . Button , Colors . FilterActive , ! everything ) ;
725+ var rightClick = DrawFilterCombo ( ref everything ) ;
700726 _tutorial . OpenTutorial ( BasicTutorialSteps . ModFilters ) ;
701727 if ( rightClick )
702728 {
703- _stateFilter = ModFilterExtensions . UnfilteredStateMods ;
729+ _stateFilter = ModFilterExtensions . UnfilteredStateMods ;
704730 SetFilterDirty ( ) ;
705731 }
706732
0 commit comments