Small tidy in AssetBrowserLogic.

This commit is contained in:
Paul Chote
2016-02-15 03:16:53 +00:00
parent a4337648e1
commit edf59b159f

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly IEnumerable<IReadOnlyPackage> acceptablePackages; readonly IEnumerable<IReadOnlyPackage> acceptablePackages;
readonly World world; readonly World world;
readonly ModData modData;
Widget panel; Widget panel;
@@ -49,6 +50,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public AssetBrowserLogic(Widget widget, Action onExit, World world, Dictionary<string, MiniYaml> logicArgs) public AssetBrowserLogic(Widget widget, Action onExit, World world, Dictionary<string, MiniYaml> logicArgs)
{ {
this.world = world; this.world = world;
modData = Game.ModData;
panel = widget; panel = widget;
@@ -217,7 +219,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
else else
allowedExtensions = new string[0]; allowedExtensions = new string[0];
acceptablePackages = Game.ModData.ModFiles.MountedPackages.Where(p => acceptablePackages = modData.ModFiles.MountedPackages.Where(p =>
p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant()))); p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant())));
assetList = panel.Get<ScrollPanelWidget>("ASSET_LIST"); assetList = panel.Get<ScrollPanelWidget>("ASSET_LIST");
@@ -309,7 +311,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename))
return false; return false;
if (!Game.ModData.ModFiles.Exists(filename)) if (!modData.DefaultFileSystem.Exists(filename))
return false; return false;
if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa") if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa")
@@ -356,7 +358,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
assetList.RemoveChildren(); assetList.RemoveChildren();
availableShps.Clear(); availableShps.Clear();
var files = assetSource != null ? assetSource.Contents : Game.ModData.ModFiles.MountedPackages.SelectMany(f => f.Contents).Distinct(); var files = assetSource != null ? assetSource.Contents : modData.ModFiles.MountedPackages.SelectMany(f => f.Contents).Distinct();
foreach (var file in files.OrderBy(s => s)) foreach (var file in files.OrderBy(s => s))
{ {
if (allowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture))) if (allowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture)))