diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index ed965d79f8..7d18ea944c 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -13,34 +13,9 @@ namespace BizHawk.Client.Common /// public static bool IsValidMovieExtension(string extension) { - return SupportedExtensions.Any(e => string.Equals(extension, e, StringComparison.OrdinalIgnoreCase)); - } - - /// - /// Attempts to convert a movie with the given filename to a support - /// type - /// - /// The path to the file to import - /// The callback that will be called if an error occurs - /// The callback that will be called if any messages need to be presented to the user - public static void Import(string fn, Action conversionErrorCallback, Action messageCallback) - { - var d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null); - var m = ImportFile(fn, out var errorMsg, out var warningMsg); - - if (!string.IsNullOrWhiteSpace(errorMsg)) - { - conversionErrorCallback(errorMsg); - } - - messageCallback(!string.IsNullOrWhiteSpace(warningMsg) - ? warningMsg - : $"{Path.GetFileName(fn)} imported as {m.Filename}"); - - if (!Directory.Exists(d)) - { - Directory.CreateDirectory(d); - } + return Importers + .Select(i => i.Value) + .Any(e => string.Equals(extension, e, StringComparison.OrdinalIgnoreCase)); } // Attempt to import another type of movie file into a movie object. @@ -106,10 +81,5 @@ namespace BizHawk.Client.Common .Any()) .ToDictionary(tkey => tkey, tvalue => ((ImportExtensionAttribute)tvalue.GetCustomAttributes(typeof(ImportExtensionAttribute)) .First()).Extension); - - - private static IEnumerable SupportedExtensions => Importers - .Select(i => i.Value) - .ToList(); } } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 0d6329802f..97de293b91 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -3852,14 +3852,24 @@ namespace BizHawk.Client.EmuHawk } } - private static void ShowConversionError(string errorMsg) - { - MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - private static void ProcessMovieImport(string fn) { - MovieImport.Import(fn, ShowConversionError, GlobalWin.OSD.AddMessage); + var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null); + var movie = MovieImport.ImportFile(fn, out var errorMsg, out var warningMsg); + + if (!string.IsNullOrWhiteSpace(errorMsg)) + { + MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + GlobalWin.OSD.AddMessage(!string.IsNullOrWhiteSpace(warningMsg) + ? warningMsg + : $"{Path.GetFileName(fn)} imported as {movie.Filename}"); + + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } } public void EnableRewind(bool enabled)