Merge pull request #9980 from penev92/chromeLogic
Allow loading of ChromeLogic properties from YAML
This commit is contained in:
@@ -67,7 +67,14 @@ namespace OpenRA
|
|||||||
foreach (var c in child.Value.Nodes)
|
foreach (var c in child.Value.Nodes)
|
||||||
LoadWidget(args, widget, c);
|
LoadWidget(args, widget, c);
|
||||||
|
|
||||||
|
var logicNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "Logic");
|
||||||
|
var logic = logicNode == null ? null : logicNode.Value.ToDictionary();
|
||||||
|
args.Add("logicArgs", logic);
|
||||||
|
|
||||||
widget.PostInit(args);
|
widget.PostInit(args);
|
||||||
|
|
||||||
|
args.Remove("logicArgs");
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class AssetBrowserLogic : ChromeLogic
|
public class AssetBrowserLogic : ChromeLogic
|
||||||
{
|
{
|
||||||
static readonly string[] AllowedExtensions = { ".shp", ".r8", "tmp", ".tem", ".des", ".sno", ".int", ".jun", ".vqa" };
|
static string[] allowedExtensions;
|
||||||
|
|
||||||
readonly World world;
|
readonly World world;
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
int currentFrame;
|
int currentFrame;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public AssetBrowserLogic(Widget widget, Action onExit, World world)
|
public AssetBrowserLogic(Widget widget, Action onExit, World world, Dictionary<string, MiniYaml> logicArgs)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
@@ -212,6 +212,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
prevButton.IsVisible = () => !isVideoLoaded;
|
prevButton.IsVisible = () => !isVideoLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logicArgs.ContainsKey("SupportedFormats"))
|
||||||
|
allowedExtensions = FieldLoader.GetValue<string[]>("SupportedFormats", logicArgs["SupportedFormats"].Value);
|
||||||
|
else
|
||||||
|
allowedExtensions = new string[0];
|
||||||
|
|
||||||
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();
|
||||||
@@ -359,7 +364,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var files = assetSource.AllFileNames().OrderBy(s => s);
|
var files = assetSource.AllFileNames().OrderBy(s => s);
|
||||||
foreach (var file in files)
|
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)))
|
||||||
{
|
{
|
||||||
AddAsset(assetList, file, template);
|
AddAsset(assetList, file, template);
|
||||||
availableShps.Add(file);
|
availableShps.Add(file);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
Container@ASSETBROWSER_PANEL:
|
Container@ASSETBROWSER_PANEL:
|
||||||
Logic: AssetBrowserLogic
|
Logic: AssetBrowserLogic
|
||||||
|
SupportedFormats: .shp, .tem, .des, .sno, .jun, .vqa
|
||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width: 695
|
Width: 695
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
Background@ASSETBROWSER_PANEL:
|
Background@ASSETBROWSER_PANEL:
|
||||||
Logic: AssetBrowserLogic
|
Logic: AssetBrowserLogic
|
||||||
|
SupportedFormats: .shp, .r8, .tmp, .tem, .des, .sno, .int, .vqa
|
||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width: 700
|
Width: 700
|
||||||
|
|||||||
Reference in New Issue
Block a user