Skip to content

Commit d71cbc0

Browse files
committed
[Editor] Add commands to copy/paste from asset explorer
1 parent d4969a3 commit d71cbc0

File tree

12 files changed

+603
-15
lines changed

12 files changed

+603
-15
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
2+
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
4+
using Stride.Core.Assets.Analysis;
5+
using Stride.Core.Assets.Presentation.ViewModels;
6+
using Stride.Core.Presentation.Dirtiables;
7+
8+
namespace Stride.Core.Assets.Editor.Quantum;
9+
10+
internal sealed class FixAssetReferenceOperation : DirtyingOperation
11+
{
12+
private readonly bool fixOnUndo;
13+
private readonly bool fixOnRedo;
14+
private IReadOnlyCollection<AssetViewModel> assets;
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="FixAssetReferenceOperation"/> class.
18+
/// </summary>
19+
/// <param name="assets">The list of assets to fix.</param>
20+
/// <param name="fixOnUndo">Indicates whether this action item should fix the reference during an Undo operation.</param>
21+
/// <param name="fixOnRedo">Indicates whether this action item should fix the reference during a Redo operation.</param>
22+
public FixAssetReferenceOperation(IReadOnlyCollection<AssetViewModel> assets, bool fixOnUndo, bool fixOnRedo)
23+
: base(assets)
24+
{
25+
this.assets = assets;
26+
this.fixOnUndo = fixOnUndo;
27+
this.fixOnRedo = fixOnRedo;
28+
}
29+
30+
public void FixAssetReferences()
31+
{
32+
AssetAnalysis.FixAssetReferences(assets.Select(x => x.AssetItem));
33+
}
34+
35+
/// <inheritdoc/>
36+
protected override void FreezeContent()
37+
{
38+
assets = null;
39+
}
40+
41+
/// <inheritdoc/>
42+
protected override void Undo()
43+
{
44+
if (!fixOnUndo)
45+
return;
46+
47+
FixAssetReferences();
48+
}
49+
50+
/// <inheritdoc/>
51+
protected override void Redo()
52+
{
53+
if (!fixOnRedo)
54+
return;
55+
56+
FixAssetReferences();
57+
}
58+
}

0 commit comments

Comments
 (0)