diff --git a/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs b/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs index 76e2916f13..1a132d701c 100644 --- a/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs @@ -111,7 +111,8 @@ // // FileSelectorPanel // - this.FileSelectorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.FileSelectorPanel.AllowDrop = true; + this.FileSelectorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.FileSelectorPanel.AutoScroll = true; @@ -120,6 +121,8 @@ this.FileSelectorPanel.Name = "FileSelectorPanel"; this.FileSelectorPanel.Size = new System.Drawing.Size(486, 214); this.FileSelectorPanel.TabIndex = 12; + this.FileSelectorPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.OnDragDrop); + this.FileSelectorPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnDragEnter); // // AddButton // diff --git a/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs b/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs index 2fa095fcff..68eb4f5754 100644 --- a/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs +++ b/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs @@ -33,8 +33,7 @@ namespace BizHawk.Client.EmuHawk { InitializeComponent(); Icon = ToolIcon; - SystemDropDown.Items.AddRange(new[] - { + SystemDropDown.Items.AddRange([ VSystemID.Raw.Amiga, VSystemID.Raw.AmstradCPC, VSystemID.Raw.AppleII, @@ -51,7 +50,7 @@ namespace BizHawk.Client.EmuHawk VSystemID.Raw.SAT, VSystemID.Raw.TI83, VSystemID.Raw.ZXSpectrum, - }); + ]); } public override void Restart() @@ -101,16 +100,7 @@ namespace BizHawk.Client.EmuHawk try { var xmlGame = XmlGame.Create(new HawkFile(xmlPath)); - for (int i = FileSelectorPanel.Controls.Count; i < xmlGame.AssetFullPaths.Count; i++) - { - AddButton_Click(null, null); - } - - var fileSelectors = FileSelectors.ToArray(); - for (int i = 0; i < xmlGame.AssetFullPaths.Count; i++) - { - fileSelectors[i].Path = xmlGame.AssetFullPaths[i]; - } + AddFiles(xmlGame.AssetFullPaths); } catch { @@ -118,6 +108,24 @@ namespace BizHawk.Client.EmuHawk } } + private void AddFiles(IList filePaths) + { + var existingEmptyControls = FileSelectors.Count(fileSelector => string.IsNullOrEmpty(fileSelector.Path)); + for (int i = existingEmptyControls; i < filePaths.Count; i++) + { + AddButton_Click(null, null); + } + + var fileSelectors = FileSelectors.ToArray(); + int currentFileSelector = 0; + foreach (string filePath in filePaths) + { + while (currentFileSelector < fileSelectors.Length && !string.IsNullOrEmpty(fileSelectors[currentFileSelector].Path)) + currentFileSelector++; + fileSelectors[currentFileSelector].Path = filePath; + } + } + private void CancelBtn_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; @@ -311,5 +319,26 @@ namespace BizHawk.Client.EmuHawk { Recalculate(); } + + private void OnDragDrop(object sender, DragEventArgs e) + { + string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop); + if (droppedFiles is null) return; + + string xmlPath = droppedFiles.FirstOrDefault(path => path.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)); + if (xmlPath is not null) + { + PopulateFromXmlFile(xmlPath); + } + else + { + AddFiles(droppedFiles); + } + } + + private void OnDragEnter(object sender, DragEventArgs e) + { + e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; + } } }