diff --git a/Source/Core/Controls/ImageBrowserControl.cs b/Source/Core/Controls/ImageBrowserControl.cs index 8a561bbd..ebdff7c3 100755 --- a/Source/Core/Controls/ImageBrowserControl.cs +++ b/Source/Core/Controls/ImageBrowserControl.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; +using System.Linq; // biwa using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Windows; @@ -474,13 +475,17 @@ namespace CodeImp.DoomBuilder.Controls // C# not Java. public void AddItem(ImageData image, string tooltip = "") { - // check if there are already items with this texturename. - // remove them. ImageBrowserItem newItem = new ImageBrowserItem(image, tooltip, uselongtexturenames); - items.RemoveAll(item => item.TextureName == newItem.TextureName); items.Add(newItem); } + // biwa. Removes all duplicates. That was done each time in AddItem before. Much faster + // to do it in one go. Not sure when there are actually duplicates + public void MakeTexturesUnique() + { + items = items.GroupBy(item => item.TextureName).Select(item => item.Last()).ToList(); + } + // This fills the list based on the objectname filter private void RefillList(bool selectfirst) { diff --git a/Source/Core/Windows/TextureBrowserForm.cs b/Source/Core/Windows/TextureBrowserForm.cs index ef76d58c..a393f533 100755 --- a/Source/Core/Windows/TextureBrowserForm.cs +++ b/Source/Core/Windows/TextureBrowserForm.cs @@ -547,7 +547,9 @@ namespace CodeImp.DoomBuilder.Windows // Add all available textures foreach(ImageData img in set.Textures) browser.AddItem(img); } - + + browser.MakeTexturesUnique(); // biwa + // Done adding browser.EndAdding(); }