From aec74d8f7fd132a6b5106fef8e93875dc20417ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 7 Feb 2016 16:43:20 +0100 Subject: [PATCH] Only list packages with viewable contents. --- OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index ad33313fb1..ea4254fac4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -22,7 +22,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class AssetBrowserLogic : ChromeLogic { - static string[] allowedExtensions; + readonly string[] allowedExtensions; + readonly IEnumerable acceptablePackages; readonly World world; @@ -216,6 +217,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic else allowedExtensions = new string[0]; + acceptablePackages = Game.ModData.ModFiles.MountedPackages.Where(p => + p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant()))); + assetList = panel.Get("ASSET_LIST"); template = panel.Get("ASSET_TEMPLATE"); PopulateAssetList(); @@ -342,7 +346,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic return item; }; - var sources = new[] { (IReadOnlyPackage)null }.Concat(Game.ModData.ModFiles.MountedPackages); + var sources = new[] { (IReadOnlyPackage)null }.Concat(acceptablePackages); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem); return true; }