diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 97d0baa0e4..6240abbc74 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -154,6 +154,7 @@ Bk2Movie.cs + diff --git a/BizHawk.Client.Common/movie/import/BkmImport.cs b/BizHawk.Client.Common/movie/import/BkmImport.cs new file mode 100644 index 0000000000..78a47f3d47 --- /dev/null +++ b/BizHawk.Client.Common/movie/import/BkmImport.cs @@ -0,0 +1,20 @@ +using BizHawk.Client.Common.MovieConversionExtensions; + +namespace BizHawk.Client.Common.movie.import +{ + // ReSharper disable once UnusedMember.Global + [ImportExtension(".bkm")] + public class BkmImport : MovieImporter + { + protected override void RunImport() + { + var movie = new BkmMovie + { + Filename = SourceFile.FullName + }; + + movie.Load(false); + Result.Movie = movie.ToBk2(); + } + } +} diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index 0e634a051f..185fce9d55 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -3,29 +3,17 @@ using System.Collections.Generic; using System.Linq; using System.IO; using System.Reflection; -using BizHawk.Common.BufferExtensions; -using BizHawk.Common.IOExtensions; - -using BizHawk.Emulation.Common; -using BizHawk.Client.Common.MovieConversionExtensions; namespace BizHawk.Client.Common { public static class MovieImport { - // Movies 2.0 TODO: this is Movie.cs specific, can it be IMovie based? If not, needs to be refactored to a hardcoded 2.0 implementation, client needs to know what kind of type it imported to, or the mainform method needs to be moved here - private const string EMULATIONORIGIN = "emuOrigin"; - private const string JAPAN = "Japan"; - private const string MD5 = "MD5"; - private const string MOVIEORIGIN = "MovieOrigin"; - /// /// Returns a value indicating whether or not there is an importer for the given extension /// public static bool IsValidMovieExtension(string extension) { - return SupportedExtensions.Any(e => string.Equals(extension, e, StringComparison.OrdinalIgnoreCase)) - || UsesLegacyImporter(extension); + return SupportedExtensions.Any(e => string.Equals(extension, e, StringComparison.OrdinalIgnoreCase)); } /// @@ -62,11 +50,6 @@ namespace BizHawk.Client.Common warningMsg = ""; string ext = path != null ? Path.GetExtension(path).ToUpper() : ""; - if (UsesLegacyImporter(ext)) - { - return LegacyImportFile(ext, path, out errorMsg, out warningMsg).ToBk2(); - } - var importerType = ImporterForExtension(ext); if (importerType == default) @@ -117,40 +100,6 @@ namespace BizHawk.Client.Common return Importers.FirstOrDefault(i => string.Equals(i.Value, ext, StringComparison.OrdinalIgnoreCase)).Key; } - private static BkmMovie LegacyImportFile(string ext, string path, out string errorMsg, out string warningMsg) - { - errorMsg = ""; - warningMsg = ""; - - BkmMovie m = new BkmMovie(); - - try - { - switch (ext) - { - case ".BKM": - m.Filename = path; - m.Load(false); - break; - } - } - catch (Exception except) - { - errorMsg = except.ToString(); - } - - if (m != null) - { - m.Filename += $".{BkmMovie.Extension}"; - } - else - { - throw new Exception(errorMsg); - } - - return m; - } - private static readonly Dictionary Importers = Assembly.GetAssembly(typeof(ImportExtensionAttribute)) .GetTypes() .Where(t => t.GetCustomAttributes(typeof(ImportExtensionAttribute)) @@ -162,15 +111,5 @@ namespace BizHawk.Client.Common private static IEnumerable SupportedExtensions => Importers .Select(i => i.Value) .ToList(); - - // Return whether or not the type of file provided is currently imported by a legacy (i.e. to BKM not BK2) importer - private static bool UsesLegacyImporter(string extension) - { - string[] extensions = - { - "BKM" - }; - return extensions.Any(ext => extension.ToUpper() == $".{ext}"); - } } }