Maybe fix #1483 re: drag+drop

This commit is contained in:
YoshiRulz 2021-11-19 04:51:46 +10:00
parent be13c08959
commit df97ef3dfe
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 18 additions and 18 deletions

View File

@ -2587,20 +2587,6 @@ namespace BizHawk.Client.EmuHawk
}
private void FormDragDrop(object sender, DragEventArgs e)
{
Sound.StopSound();
try
{
FormDragDrop_internal(e);
}
catch (Exception ex)
{
ShowMessageBox(owner: null, $"Exception on drag and drop:\n{ex}");
}
finally
{
Sound.StartSound();
}
}
=> PathsFromDragDrop = (string[]) e.Data.GetData(DataFormats.FileDrop);
}
}

View File

@ -214,7 +214,9 @@ namespace BizHawk.Client.EmuHawk
}
}
private void FormDragDrop_internal(DragEventArgs e)
private string[] PathsFromDragDrop;
private void FormDragDrop_internal()
{
/*
* Refactor, moving the loading of particular files into separate functions that can
@ -243,7 +245,6 @@ namespace BizHawk.Client.EmuHawk
* Make that order easy to change in the code, heavily suggesting ROM and playback as first and last respectively.
*/
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
Dictionary<LoadOrdering, List<FileInformation>> sortedFiles = new Dictionary<LoadOrdering, List<FileInformation>>();
// Initialize the dictionary's lists.
@ -252,7 +253,7 @@ namespace BizHawk.Client.EmuHawk
sortedFiles.Add(value, new List<FileInformation>());
}
ProcessFileList(filePaths.Select(EmuHawkUtil.ResolveShortcut), ref sortedFiles);
ProcessFileList(PathsFromDragDrop.Select(EmuHawkUtil.ResolveShortcut), ref sortedFiles);
// For each of the different types of item, if there are no items of that type, skip them.
// If there is exactly one of that type of item, load it.

View File

@ -2247,6 +2247,19 @@ namespace BizHawk.Client.EmuHawk
ScreenSaver.ResetTimerPeriodically();
}
if (PathsFromDragDrop is not null) this.DoWithTempMute(() =>
{
try
{
FormDragDrop_internal();
}
catch (Exception ex)
{
ShowMessageBox(owner: null, $"Exception on drag and drop:\n{ex}");
}
PathsFromDragDrop = null;
});
List<string[]> todo = new();
lock (_singleInstanceForwardedArgs)
{