Only list packages with viewable contents.

This commit is contained in:
Matthias Mailänder
2016-02-07 16:43:20 +01:00
parent f87a4bf16f
commit aec74d8f7f

View File

@@ -22,7 +22,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
public class AssetBrowserLogic : ChromeLogic public class AssetBrowserLogic : ChromeLogic
{ {
static string[] allowedExtensions; readonly string[] allowedExtensions;
readonly IEnumerable<IReadOnlyPackage> acceptablePackages;
readonly World world; readonly World world;
@@ -216,6 +217,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
else else
allowedExtensions = new string[0]; allowedExtensions = new string[0];
acceptablePackages = Game.ModData.ModFiles.MountedPackages.Where(p =>
p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant())));
assetList = panel.Get<ScrollPanelWidget>("ASSET_LIST"); assetList = panel.Get<ScrollPanelWidget>("ASSET_LIST");
template = panel.Get<ScrollItemWidget>("ASSET_TEMPLATE"); template = panel.Get<ScrollItemWidget>("ASSET_TEMPLATE");
PopulateAssetList(); PopulateAssetList();
@@ -342,7 +346,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return item; 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); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem);
return true; return true;
} }