-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathGameSettingsAssetNodeUpdater.cs
More file actions
49 lines (45 loc) · 2.31 KB
/
Copy pathGameSettingsAssetNodeUpdater.cs
File metadata and controls
49 lines (45 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using Stride.Core.Assets.Editor.Extensions;
using Stride.Core.Assets.Editor.Quantum.NodePresenters;
using Stride.Core.Assets.Editor.Quantum.NodePresenters.Commands;
using Stride.Core.Assets.Editor.Quantum.NodePresenters.Keys;
using Stride.Core;
using Stride.Core.Presentation.Quantum.Presenters;
using Stride.Assets.Presentation.ViewModel;
using Stride.Data;
namespace Stride.Assets.Presentation.NodePresenters.Updaters
{
internal sealed class GameSettingsAssetNodeUpdater : AssetNodePresenterUpdaterBase
{
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);
}
if (!node.Commands.Any(cmd => cmd.Name == AddNewItemCommand.CommandName))
node.Commands.Add(new AddNewItemCommand());
if (!node.Commands.Any(cmd => cmd.Name == RemoveItemCommand.CommandName))
node.Commands.Add(new RemoveItemCommand());
}
if (typeof(Configuration).IsAssignableFrom(node.Type))
{
node.DisplayName = DisplayAttribute.GetDisplayName(node.Value?.GetType()) ?? DisplayAttribute.GetDisplayName(typeof(Configuration));
}
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);
}
}
}
}