diff --git a/File_Format_Library/FileFormats/BFRES/BFRES.cs b/File_Format_Library/FileFormats/BFRES/BFRES.cs index 733adca1..16716cfc 100644 --- a/File_Format_Library/FileFormats/BFRES/BFRES.cs +++ b/File_Format_Library/FileFormats/BFRES/BFRES.cs @@ -68,7 +68,7 @@ namespace FirstPlugin public IEnumerable ExportableTextures => TextureList; - public override string ExportFilter => Utils.GetAllFilters(new BFRES()); + public override string ExportFilter => Utils.GetAllFilters(this); //Stores the skeleton and models in this public DrawableContainer DrawableContainer = new DrawableContainer(); @@ -914,7 +914,7 @@ namespace FirstPlugin GC.SuppressFinalize(this); } - public void Save(System.IO.Stream stream) + public void Save(Stream stream) { var Models = GetModels(); if (Models != null && !IsParticlePrimitive) diff --git a/Switch_Toolbox_Library/Util/Util.cs b/Switch_Toolbox_Library/Util/Util.cs index 71df4f06..7d4fa06a 100644 --- a/Switch_Toolbox_Library/Util/Util.cs +++ b/Switch_Toolbox_Library/Util/Util.cs @@ -288,15 +288,26 @@ namespace Toolbox.Library { List f = new List(); f.Add(format); - return GetAllFilters(f); + return GetAllFilters(f, format); } - public static string GetAllFilters(IEnumerable format) + public static string GetAllFilters(IEnumerable format, IFileFormat targetFormat = null) { var alltypes = format; string Filter = "All Supported Files|"; List FilterEach = new List(); + + //Set the current extension used by the target's file information if used + if (targetFormat != null && targetFormat.FilePath != null) { + string extension = Path.GetExtension(targetFormat.FilePath); + if (extension != "" && !format.Any(x => x.Extension.Contains($"*{extension}"))) + { + Filter += $"*{extension};"; + FilterEach.Add($"({extension}) |*{extension}|"); + } + } + foreach (IFileFormat f in format) { for (int i = 0; i < f.Extension.Length; i++) diff --git a/Toolbox/MainForm.cs b/Toolbox/MainForm.cs index d85b6cac..8f128b7d 100644 --- a/Toolbox/MainForm.cs +++ b/Toolbox/MainForm.cs @@ -416,6 +416,7 @@ namespace Toolbox formats.Add((IFileFormat)fileFormat); } sfd.Filter = Utils.GetAllFilters(formats); + sfd.DefaultExt = Path.GetExtension(format.FilePath); if (sfd.ShowDialog() != DialogResult.OK) return; @@ -438,6 +439,7 @@ namespace Toolbox SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = Utils.GetAllFilters(format); sfd.FileName = format.FileName; + sfd.DefaultExt = Path.GetExtension(format.FilePath); if (sfd.ShowDialog() != DialogResult.OK) return;