From 2b625e9c53fcb9223e7344601a593dadd6a123b8 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 4 May 2017 17:54:21 -0500 Subject: [PATCH] Advanced loader - if magic folder necessary for the feature to work doesn't exist, create it. Allow drag and drop of dll files on the Current Core box --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 4 +++ .../OpenAdvancedChooser.Designer.cs | 3 ++ BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs | 28 +++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 7fa16390ed..c27cab28dc 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1316,6 +1316,10 @@ namespace BizHawk.Client.EmuHawk else { ofd.InitialDirectory = PathManager.GetPathType("Libretro", "Cores"); + if (!Directory.Exists(ofd.InitialDirectory)) + { + Directory.CreateDirectory(ofd.InitialDirectory); + } } ofd.RestoreDirectory = true; diff --git a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.Designer.cs b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.Designer.cs index 8a28b697c4..af6c2fcc75 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.Designer.cs +++ b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.Designer.cs @@ -97,11 +97,14 @@ // // txtLibretroCore // + this.txtLibretroCore.AllowDrop = true; this.txtLibretroCore.Location = new System.Drawing.Point(81, 23); this.txtLibretroCore.Name = "txtLibretroCore"; this.txtLibretroCore.ReadOnly = true; this.txtLibretroCore.Size = new System.Drawing.Size(314, 20); this.txtLibretroCore.TabIndex = 6; + this.txtLibretroCore.DragDrop += new System.Windows.Forms.DragEventHandler(this.txtLibretroCore_DragDrop); + this.txtLibretroCore.DragEnter += new System.Windows.Forms.DragEventHandler(this.txtLibretroCore_DragEnter); // // btnLibretroLaunchGame // diff --git a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs index 6eb0d2790a..e6d1684bce 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs +++ b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs @@ -130,22 +130,44 @@ namespace BizHawk.Client.EmuHawk SuggestedExtensionFilter = filter; Result = Command.RetroLaunchGame; - DialogResult = System.Windows.Forms.DialogResult.OK; + DialogResult = DialogResult.OK; Close(); } private void btnClassicLaunchGame_Click(object sender, EventArgs e) { Result = Command.ClassicLaunchGame; - DialogResult = System.Windows.Forms.DialogResult.OK; + DialogResult = DialogResult.OK; Close(); } private void btnLibretroLaunchNoGame_Click(object sender, EventArgs e) { Result = Command.RetroLaunchNoGame; - DialogResult = System.Windows.Forms.DialogResult.OK; + DialogResult = DialogResult.OK; Close(); } + + private void txtLibretroCore_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); + if (Path.GetExtension(filePaths[0]).ToUpper() == ".DLL") + { + e.Effect = DragDropEffects.Copy; + return; + } + } + + e.Effect = DragDropEffects.None; + } + + private void txtLibretroCore_DragDrop(object sender, DragEventArgs e) + { + var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); + Global.Config.LibretroCore = filePaths[0]; + RefreshLibretroCore(false); + } } }