예제 #1
0
        protected override void UpdateNode(IAssetNodePresenter node)
        {
            if (!(node.Asset is MaterialViewModel))
            {
                return;
            }

            // Bypass the Attributes node to display directly the attribute items
            if (node.Name == nameof(MaterialAsset.Attributes) && node.Value is MaterialAttributes)
            {
                node.BypassNode();
            }

            if (node.Name == nameof(ComputeShaderClassBase <ComputeNode> .MixinReference) && node.Parent != null && typeof(IComputeNode).IsAssignableFrom(node.Parent.Type))
            {
                // Pick only effect shaders visible from the package in which the related asset is contained
                var asset = node.Asset;
                node.AttachedProperties.Add(MaterialData.Key, asset.Directory.Package.AllAssets.Where(x => x.AssetType == typeof(EffectShaderAsset)).Select(x => x.Name));
            }

            // The node is a material blend layer
            if (typeof(MaterialBlendLayer).IsAssignableFrom(node.Type))
            {
                var layer = (MaterialBlendLayer)node.Value;
                node.DisplayName = !string.IsNullOrWhiteSpace(layer.Name) ? layer.Name : $"Layer {node.Index}";
                node[nameof(MaterialBlendLayer.Name)].IsVisible = false;
                if (node.Commands.All(x => x.Name != RenameStringKeyCommand.CommandName))
                {
                    node.Commands.Add(new SyncAnonymousNodePresenterCommand(RenameStringKeyCommand.CommandName, (x, name) => x[nameof(MaterialBlendLayer.Name)].UpdateValue(name)));
                }
                node.AddDependency(node[nameof(MaterialBlendLayer.Name)], false);
            }
        }
예제 #2
0
        protected override void UpdateNode(IAssetNodePresenter node)
        {
            if (!(node.Asset is GameSettingsViewModel))
            {
                return;
            }

            if (node.Name == nameof(GameSettingsAsset.Defaults) && node.Value is List <Configuration> )
            {
                foreach (var item in node.Children.ToList())
                {
                    item.Order = node.Order + item.Index.Int;
                    item.AttachedProperties.Add(CategoryData.Key, true);
                }
                node.BypassNode();
            }

            if (typeof(Configuration).IsAssignableFrom(node.Type))
            {
                node.DisplayName = DisplayAttribute.GetDisplayName(node.Value?.GetType()) ?? DisplayAttribute.GetDisplayName(typeof(Configuration));
            }

            if (typeof(ConfigurationOverride).IsAssignableFrom(node.Type))
            {
                node.DisplayName = $"Override {node.Index}";
                node.AttachedProperties.Add(CategoryData.Key, true);
            }

            if (node.Parent != null && typeof(ConfigurationOverride).IsAssignableFrom(node.Parent.Type) && node.Name == nameof(ConfigurationOverride.SpecificFilter))
            {
                if (node.Commands.All(x => x.Name != "ClearSelection"))
                {
                    node.Commands.Add(new SyncAnonymousNodePresenterCommand("ClearSelection", (n, x) => n.UpdateValue(-1)));
                }
            }

            if (typeof(ICollection <Configuration>).IsAssignableFrom(node.Type))
            {
                var types = node.AttachedProperties.Get(AbstractNodeEntryData.Key);
                types = types.Where(x => ((ICollection <Configuration>)node.Value).All(y => !(x is AbstractNodeType && y.GetType() == ((AbstractNodeType)x).Type)));
                node.AttachedProperties.Set(AbstractNodeEntryData.Key, types);
            }
        }