diff --git a/BizHawk.Client.Common/movie/MovieService.cs b/BizHawk.Client.Common/movie/MovieService.cs index ca612e9c11..d94e8e6c99 100644 --- a/BizHawk.Client.Common/movie/MovieService.cs +++ b/BizHawk.Client.Common/movie/MovieService.cs @@ -20,12 +20,12 @@ namespace BizHawk.Client.Common /// /// Gets the file extension for the default movie implementation used in the client /// - public static string DefaultExtension => "bk2"; + public const string DefaultExtension = "bk2"; /// /// Gets a list of extensions for all implementations /// - public static IEnumerable MovieExtensions => new[] { "bk2", "tasproj" }; + public static IEnumerable MovieExtensions => new[] { DefaultExtension, TasMovie.Extension }; public static bool IsValidMovieExtension(string ext) { diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index c1380841af..4dabc80e46 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -8,6 +8,11 @@ namespace BizHawk.Client.Common { public static class MovieImport { + private static readonly Dictionary Importers = Assembly.GetAssembly(typeof(ImporterForAttribute)).GetTypes() + .Select(t => (t, attr: (ImporterForAttribute) t.GetCustomAttributes(typeof(ImporterForAttribute)).FirstOrDefault())) + .Where(tuple => tuple.attr != null) + .ToDictionary(tuple => tuple.t, tuple => tuple.attr); + /// /// Returns a value indicating whether or not there is an importer for the given extension /// @@ -54,12 +59,5 @@ namespace BizHawk.Client.Common { return Importers.FirstOrDefault(i => string.Equals(i.Value.Extension, ext, StringComparison.OrdinalIgnoreCase)).Key; } - - private static readonly Dictionary Importers = Assembly.GetAssembly(typeof(ImporterForAttribute)) - .GetTypes() - .Where(t => t.GetCustomAttributes(typeof(ImporterForAttribute)) - .Any()) - .ToDictionary(tkey => tkey, tvalue => ((ImporterForAttribute)tvalue.GetCustomAttributes(typeof(ImporterForAttribute)) - .First())); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs index 792de5d523..035a650cee 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs @@ -391,12 +391,11 @@ namespace BizHawk.Client.EmuHawk return (int)form.Handle; } - [LuaMethodExample("local stforope = forms.openfile( \"C:\\filename.bin\", \"C:\\\", \"All files ( *.* )|*.*\");")] + [LuaMethodExample(@"local filename = forms.openfile(""C:\filename.bin"", ""C:\"", ""Raster Images (*.bmp;*.gif;*.jpg;*.png)|*.bmp;*.gif;*.jpg;*.png|All Files (*.*)|*.*"")")] [LuaMethod( "openfile", "Creates a standard openfile dialog with optional parameters for the filename, directory, and filter. The return value is the directory that the user picked. If they chose to cancel, it will return an empty string")] - public string OpenFile(string fileName = null, string initialDirectory = null, string filter = "All files (*.*)|*.*") + public string OpenFile(string fileName = null, string initialDirectory = null, string filter = null) { - // filterext format ex: "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*" var openFileDialog1 = new OpenFileDialog(); if (initialDirectory != null) { @@ -408,11 +407,8 @@ namespace BizHawk.Client.EmuHawk openFileDialog1.FileName = fileName; } - if (filter != null) - { - openFileDialog1.AddExtension = true; - openFileDialog1.Filter = filter; - } + openFileDialog1.AddExtension = true; + openFileDialog1.Filter = filter ?? "All Files (*.*)|*"; if (openFileDialog1.ShowDialog() == DialogResult.OK) {