Merge pull request #10716 from Mailaender/all-assets
Re-enabled All Packages which seems to be fast enough now.
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
@@ -50,7 +51,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
panel = widget;
|
panel = widget;
|
||||||
assetSource = Game.ModData.ModFiles.MountedPackages.First();
|
|
||||||
|
|
||||||
var ticker = panel.GetOrNull<LogicTickerWidget>("ANIMATION_TICKER");
|
var ticker = panel.GetOrNull<LogicTickerWidget>("ANIMATION_TICKER");
|
||||||
if (ticker != null)
|
if (ticker != null)
|
||||||
@@ -217,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();
|
||||||
@@ -343,9 +346,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Re-enable "All Packages" once list generation is done in a background thread
|
var sources = new[] { (IReadOnlyPackage)null }.Concat(acceptablePackages);
|
||||||
// var sources = new[] { (IPackage)null }.Concat(GlobalFileSystem.MountedFolders);
|
|
||||||
var sources = Game.ModData.ModFiles.MountedPackages;
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -355,14 +356,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
assetList.RemoveChildren();
|
assetList.RemoveChildren();
|
||||||
availableShps.Clear();
|
availableShps.Clear();
|
||||||
|
|
||||||
// TODO: This is too slow to run in the main thread
|
var files = assetSource != null ? assetSource.Contents : Game.ModData.ModFiles.MountedPackages.SelectMany(f => f.Contents).Distinct();
|
||||||
// var files = AssetSource != null ? AssetSource.AllFileNames() :
|
foreach (var file in files.OrderBy(s => s))
|
||||||
// GlobalFileSystem.MountedFolders.SelectMany(f => f.AllFileNames());
|
|
||||||
if (assetSource == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var files = assetSource.Contents.OrderBy(s => s);
|
|
||||||
foreach (var file in files)
|
|
||||||
{
|
{
|
||||||
if (allowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture)))
|
if (allowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture)))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user