From 0e93d852738d09a8a01ce5d29a6353d5e6cd41a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 1 Jan 2020 12:22:09 +0100 Subject: [PATCH] Move the AssetBrowserFileEndingsFilter to IGlobalModData to avoid mods having to duplicate the whole chrome layout. --- OpenRA.Mods.Common/AssetBrowser.cs | 19 +++++++++++++++++++ .../Widgets/Logic/AssetBrowserLogic.cs | 6 ++---- mods/cnc/chrome/assetbrowser.yaml | 1 - mods/cnc/mod.yaml | 3 +++ mods/common/chrome/assetbrowser.yaml | 1 - mods/d2k/mod.yaml | 3 +++ mods/ra/mod.yaml | 3 +++ mods/ts/mod.yaml | 3 +++ 8 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 OpenRA.Mods.Common/AssetBrowser.cs diff --git a/OpenRA.Mods.Common/AssetBrowser.cs b/OpenRA.Mods.Common/AssetBrowser.cs new file mode 100644 index 0000000000..b98d43f3f8 --- /dev/null +++ b/OpenRA.Mods.Common/AssetBrowser.cs @@ -0,0 +1,19 @@ +#region Copyright & License Information +/* + * Copyright 2007-2020 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +namespace OpenRA +{ + public class AssetBrowser : IGlobalModData + { + [FieldLoader.Require] + public readonly string[] SupportedExtensions = new string[0]; + } +} diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 5caf4c3d18..18c8a2e3e8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -214,10 +214,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic prevButton.IsVisible = () => !isVideoLoaded; } - if (logicArgs.ContainsKey("SupportedFormats")) - allowedExtensions = FieldLoader.GetValue("SupportedFormats", logicArgs["SupportedFormats"].Value); - else - allowedExtensions = new string[0]; + var assetBrowserModData = modData.Manifest.Get(); + allowedExtensions = assetBrowserModData.SupportedExtensions; acceptablePackages = modData.ModFiles.MountedPackages.Where(p => p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant()))); diff --git a/mods/cnc/chrome/assetbrowser.yaml b/mods/cnc/chrome/assetbrowser.yaml index d55e9d928b..b52537d147 100644 --- a/mods/cnc/chrome/assetbrowser.yaml +++ b/mods/cnc/chrome/assetbrowser.yaml @@ -1,6 +1,5 @@ Container@ASSETBROWSER_PANEL: Logic: AssetBrowserLogic - SupportedFormats: .shp, .tem, .des, .sno, .jun, .vqa X: (WINDOW_RIGHT - WIDTH) / 2 Y: (WINDOW_BOTTOM - HEIGHT) / 2 Width: 695 diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index d5e57bf133..b7ebf10a4f 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -222,6 +222,9 @@ SpriteSequenceFormat: TilesetSpecificSpriteSequence ModelSequenceFormat: PlaceholderModelSequence +AssetBrowser: + SupportedExtensions: .shp, .tem, .des, .sno, .jun, .vqa + GameSpeeds: slowest: Name: Slowest diff --git a/mods/common/chrome/assetbrowser.yaml b/mods/common/chrome/assetbrowser.yaml index beab6d3933..86fb0cbc54 100644 --- a/mods/common/chrome/assetbrowser.yaml +++ b/mods/common/chrome/assetbrowser.yaml @@ -1,6 +1,5 @@ Background@ASSETBROWSER_PANEL: Logic: AssetBrowserLogic - SupportedFormats: .shp, .r8, .tmp, .tem, .des, .sno, .int, .vqa X: (WINDOW_RIGHT - WIDTH) / 2 Y: (WINDOW_BOTTOM - HEIGHT) / 2 Width: 700 diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 8cddaab406..d7a8dcba66 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -198,6 +198,9 @@ SpriteSequenceFormat: DefaultSpriteSequence ModelSequenceFormat: PlaceholderModelSequence +AssetBrowser: + SupportedExtensions: .shp, .r8, .vqa + GameSpeeds: slowest: Name: Slowest diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 3678dc0377..6c67da9062 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -223,6 +223,9 @@ SpriteSequenceFormat: TilesetSpecificSpriteSequence ModelSequenceFormat: PlaceholderModelSequence +AssetBrowser: + SupportedExtensions: .shp, .tmp, .tem, .des, .sno, .int, .vqa + GameSpeeds: slowest: Name: Slowest diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index cc48d95a55..8750b4fea4 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -259,6 +259,9 @@ SpriteSequenceFormat: TilesetSpecificSpriteSequence ModelSequenceFormat: VoxelModelSequence +AssetBrowser: + SupportedExtensions: .shp, .tem, .sno, .vqa + GameSpeeds: slowest: Name: Slowest