private void FormDragDrop_internal(DragEventArgs e) { /* * Refactor, moving the loading of particular files into separate functions that can * then be used by this code, and loading individual files through the file dialogue. * * Step 1: * Build a dictionary of relevant files from everything that was dragged and dropped. * This includes peeking into all relevant archives and using their files. * * Step 2: * Perhaps ask the user which of a particular file type they want to use. * Example: rom1.nes, rom2.smc, rom3.cue are drag-dropped, ask the user which they want to use. * * Step 3: * Load all of the relevant files, in priority order: * 1) The ROM * 2) State * 3) Watch files * 4) Code Data Logger (CDL) * 5) LUA sessions * 6) LUA scripts * 7) Cheat files * 8) Movie Playback Files * * Bonus: * 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. foreach (LoadOrdering value in Enum.GetValues(typeof(LoadOrdering))) { sortedFiles.Add(value, new List <FileInformation>()); } ProcessFileList(HawkFile.Util_ResolveLinks(filePaths), 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. // If there is more than one, ask. foreach (LoadOrdering value in Enum.GetValues(typeof(LoadOrdering))) { switch (sortedFiles[value].Count) { case 0: break; case 1: var fileInformation = sortedFiles[value].First(); string filename = Path.Combine(new[] { fileInformation.DirectoryName, fileInformation.FileName }); switch (value) { case LoadOrdering.Rom: LoadRom(filename, fileInformation.ArchiveName); break; case LoadOrdering.State: LoadStateFile(filename, fileInformation.ArchiveName); break; case LoadOrdering.Watch: LoadWatch(filename, fileInformation.ArchiveName); break; case LoadOrdering.CdFile: LoadCdl(filename, fileInformation.ArchiveName); break; case LoadOrdering.LuaSession: LoadLuaSession(filename, fileInformation.ArchiveName); break; case LoadOrdering.LuaScript: LoadLuaFile(filename, fileInformation.ArchiveName); break; case LoadOrdering.Cheat: LoadCheats(filename, fileInformation.ArchiveName); break; case LoadOrdering.MovieFile: case LoadOrdering.LegacyMovieFile: // I don't really like this hack, but for now, we only want to load one movie file. if (sortedFiles[LoadOrdering.MovieFile].Count + sortedFiles[LoadOrdering.LegacyMovieFile].Count > 1) { break; } if (value == LoadOrdering.MovieFile) { LoadMovie(filename, fileInformation.ArchiveName); } else { LoadLegacyMovie(filename, fileInformation.ArchiveName); } break; } break; } } }