Merge remote-tracking branch 'origin/master' into 1.9

# Conflicts:
#	Source/Engine/Audio/Audio.cpp
This commit is contained in:
Wojtek Figat
2024-07-05 22:18:40 +02:00
122 changed files with 8832 additions and 4272 deletions

View File

@@ -61,6 +61,8 @@ namespace FlaxEditor.Content.GUI
private bool _isRubberBandSpanning;
private Float2 _mousePressLocation;
private Rectangle _rubberBandRectangle;
private bool _isCutting;
private List<ContentItem> _cutItems = new List<ContentItem>();
private bool _validDragOver;
private DragActors _dragActors;
@@ -83,9 +85,9 @@ namespace FlaxEditor.Content.GUI
public event Action<List<ContentItem>> OnDelete;
/// <summary>
/// Called when user wants to paste the files/folders.
/// Called when user wants to paste the files/folders. Bool is for cutting.
/// </summary>
public event Action<string[]> OnPaste;
public event Action<string[], bool> OnPaste;
/// <summary>
/// Called when user wants to duplicate the item(s).
@@ -210,6 +212,12 @@ namespace FlaxEditor.Content.GUI
}),
new InputActionsContainer.Binding(options => options.Copy, Copy),
new InputActionsContainer.Binding(options => options.Paste, Paste),
new InputActionsContainer.Binding(options => options.Cut, Cut),
new InputActionsContainer.Binding(options => options.Undo, () =>
{
if (_isCutting)
UpdateContentItemCut(false);
}),
new InputActionsContainer.Binding(options => options.Duplicate, Duplicate),
});
}
@@ -462,6 +470,7 @@ namespace FlaxEditor.Content.GUI
/// </summary>
public void Duplicate()
{
UpdateContentItemCut(false);
OnDuplicate?.Invoke(_selection);
}
@@ -475,6 +484,7 @@ namespace FlaxEditor.Content.GUI
var files = _selection.ConvertAll(x => x.Path).ToArray();
Clipboard.Files = files;
UpdateContentItemCut(false);
}
/// <summary>
@@ -496,7 +506,36 @@ namespace FlaxEditor.Content.GUI
if (files == null || files.Length == 0)
return;
OnPaste?.Invoke(files);
OnPaste?.Invoke(files, _isCutting);
UpdateContentItemCut(false);
}
/// <summary>
/// Cuts the items.
/// </summary>
public void Cut()
{
Copy();
UpdateContentItemCut(true);
}
private void UpdateContentItemCut(bool cut)
{
_isCutting = cut;
// Add selection to cut list
if (cut)
_cutItems.AddRange(_selection);
// Update item with if it is being cut.
foreach (var item in _cutItems)
{
item.IsBeingCut = cut;
}
// Clean up cut items
if (!cut)
_cutItems.Clear();
}
/// <summary>

View File

@@ -182,6 +182,11 @@ namespace FlaxEditor.Content
/// </summary>
public const int DefaultHeight = (DefaultThumbnailSize + 2 * DefaultMarginSize + DefaultTextHeight);
/// <summary>
/// Whether the item is being but.
/// </summary>
public bool IsBeingCut;
private ContentFolder _parentFolder;
private bool _isMouseDown;
@@ -747,6 +752,12 @@ namespace FlaxEditor.Content
Render2D.PushClip(ref textRect);
Render2D.DrawText(style.FontMedium, ShowFileExtension || view.ShowFileExtensions ? FileName : ShortName, textRect, style.Foreground, nameAlignment, TextAlignment.Center, TextWrapping.WrapWords, 1f, 0.95f);
Render2D.PopClip();
if (IsBeingCut)
{
var color = style.LightBackground.AlphaMultiplied(0.5f);
Render2D.FillRectangle(clientRect, color);
}
}
/// <inheritdoc />

View File

@@ -67,32 +67,35 @@ namespace FlaxEditor.CustomEditors.Dedicated
// Use default prefab instance as a reference for the editor
Values.SetReferenceValue(prefabInstance);
// Add some UI
var panel = layout.CustomContainer<UniformGridPanel>();
panel.CustomControl.Height = 20.0f;
panel.CustomControl.SlotsVertically = 1;
panel.CustomControl.SlotsHorizontally = 3;
// Selecting actor prefab asset
var selectPrefab = panel.Button("Select Prefab");
selectPrefab.Button.Clicked += () =>
if (Presenter == Editor.Instance.Windows.PropertiesWin.Presenter)
{
Editor.Instance.Windows.ContentWin.ClearItemsSearch();
Editor.Instance.Windows.ContentWin.Select(prefab);
};
// Add some UI
var panel = layout.CustomContainer<UniformGridPanel>();
panel.CustomControl.Height = 20.0f;
panel.CustomControl.SlotsVertically = 1;
panel.CustomControl.SlotsHorizontally = 3;
// Selecting actor prefab asset
var selectPrefab = panel.Button("Select Prefab");
selectPrefab.Button.Clicked += () =>
{
Editor.Instance.Windows.ContentWin.ClearItemsSearch();
Editor.Instance.Windows.ContentWin.Select(prefab);
};
// Edit selected prefab asset
var editPrefab = panel.Button("Edit Prefab");
editPrefab.Button.Clicked += () =>
{
Editor.Instance.Windows.ContentWin.ClearItemsSearch();
Editor.Instance.Windows.ContentWin.Select(prefab);
Editor.Instance.Windows.ContentWin.Open(Editor.Instance.Windows.ContentWin.View.Selection[0]);
};
// Edit selected prefab asset
var editPrefab = panel.Button("Edit Prefab");
editPrefab.Button.Clicked += () =>
{
Editor.Instance.Windows.ContentWin.ClearItemsSearch();
Editor.Instance.Windows.ContentWin.Select(prefab);
Editor.Instance.Windows.ContentWin.Open(Editor.Instance.Windows.ContentWin.View.Selection[0]);
};
// Viewing changes applied to this actor
var viewChanges = panel.Button("View Changes");
viewChanges.Button.Clicked += () => ViewChanges(viewChanges.Button, new Float2(0.0f, 20.0f));
// Viewing changes applied to this actor
var viewChanges = panel.Button("View Changes");
viewChanges.Button.Clicked += () => ViewChanges(viewChanges.Button, new Float2(0.0f, 20.0f));
}
// Link event to update editor on prefab apply
_linkedPrefabId = prefab.ID;

View File

@@ -182,6 +182,9 @@ namespace FlaxEditor.Modules
var cam = scene.AddChild<Camera>();
cam.Name = "Camera";
cam.Position = new Vector3(0, 150, -300);
//
var audioListener = cam.AddChild<AudioListener>();
audioListener.Name = "Audio Listener";
// Serialize
var bytes = Level.SaveSceneToBytes(scene);

View File

@@ -160,16 +160,23 @@ namespace FlaxEditor.Windows.Assets
var result = base.OnDragDrop(ref location, data);
if (result == DragDropEffect.None)
{
_window._isDropping = true;
// Drag assets
if (_dragAssets != null && _dragAssets.HasValidDrag)
{
List<SceneGraphNode> graphNodes = new List<SceneGraphNode>();
for (int i = 0; i < _dragAssets.Objects.Count; i++)
{
var item = _dragAssets.Objects[i];
var actor = item.OnEditorDrop(this);
actor.Name = item.ShortName;
_window.Spawn(actor);
var graphNode = _window.Graph.Root.Find(actor);;
if (graphNode != null)
graphNodes.Add(graphNode);
}
if (graphNodes.Count > 0)
_window.Select(graphNodes);
result = DragDropEffect.Move;
}
// Drag actor type
@@ -213,6 +220,7 @@ namespace FlaxEditor.Windows.Assets
// Drag script item
else if (_dragScriptItems != null && _dragScriptItems.HasValidDrag)
{
List<SceneGraphNode> graphNodes = new List<SceneGraphNode>();
for (int i = 0; i < _dragScriptItems.Objects.Count; i++)
{
var item = _dragScriptItems.Objects[i];
@@ -227,8 +235,13 @@ namespace FlaxEditor.Windows.Assets
}
actor.Name = actorType.Name;
_window.Spawn(actor);
var graphNode = _window.Graph.Root.Find(actor);;
if (graphNode != null)
graphNodes.Add(graphNode);
}
}
if (graphNodes.Count > 0)
_window.Select(graphNodes);
result = DragDropEffect.Move;
}
_dragHandlers.OnDragDrop(null);

View File

@@ -42,6 +42,7 @@ namespace FlaxEditor.Windows.Assets
private bool _liveReload = false;
private bool _isUpdatingSelection, _isScriptsReloading;
private DateTime _modifiedTime = DateTime.MinValue;
private bool _isDropping = false;
/// <summary>
/// Gets the prefab hierarchy tree control.
@@ -273,11 +274,16 @@ namespace FlaxEditor.Windows.Assets
return true;
}
if (button == MouseButton.Left && _treePanel.ContainsPoint(ref location))
if (button == MouseButton.Left && _treePanel.ContainsPoint(ref location) && !_isDropping)
{
_tree.Deselect();
return true;
}
if (_isDropping)
{
_isDropping = false;
return true;
}
return false;
}

View File

@@ -128,11 +128,9 @@ namespace FlaxEditor.Windows
else
{
cm.AddButton("Delete", () => Delete(item));
cm.AddSeparator();
cm.AddButton("Duplicate", _view.Duplicate);
cm.AddButton("Cut", _view.Cut);
cm.AddButton("Copy", _view.Copy);
}

View File

@@ -741,7 +741,8 @@ namespace FlaxEditor.Windows
/// Pastes the specified files.
/// </summary>
/// <param name="files">The files paths to import.</param>
public void Paste(string[] files)
/// <param name="isCutting">Whether a cutting action is occuring.</param>
public void Paste(string[] files, bool isCutting)
{
var importFiles = new List<string>();
foreach (var sourcePath in files)
@@ -752,7 +753,10 @@ namespace FlaxEditor.Windows
var newPath = StringUtils.NormalizePath(Path.Combine(CurrentViewFolder.Path, item.FileName));
if (sourcePath.Equals(newPath))
newPath = GetClonedAssetPath(item);
Editor.ContentDatabase.Copy(item, newPath);
if (isCutting)
Editor.ContentDatabase.Move(item, newPath);
else
Editor.ContentDatabase.Copy(item, newPath);
}
else
importFiles.Add(sourcePath);

View File

@@ -38,12 +38,29 @@ namespace FlaxEditor.Windows.Profiler
: base("Assets")
{
// Layout
var panel = new Panel(ScrollBars.Vertical)
var mainPanel = new Panel(ScrollBars.None)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
Parent = this,
};
// Chart
_memoryUsageChart = new SingleChart
{
Title = "Assets Memory Usage (CPU)",
AnchorPreset = AnchorPresets.HorizontalStretchTop,
FormatSample = v => Utilities.Utils.FormatBytesCount((int)v),
Parent = mainPanel,
};
_memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged;
var panel = new Panel(ScrollBars.Vertical)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, _memoryUsageChart.Height + 2, 0),
Parent = mainPanel,
};
var layout = new VerticalPanel
{
AnchorPreset = AnchorPresets.HorizontalStretchTop,
@@ -52,15 +69,6 @@ namespace FlaxEditor.Windows.Profiler
Parent = panel,
};
// Chart
_memoryUsageChart = new SingleChart
{
Title = "Assets Memory Usage (CPU)",
FormatSample = v => Utilities.Utils.FormatBytesCount((int)v),
Parent = layout,
};
_memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged;
// Table
var style = Style.Current;
var headerColor = style.LightBackground;

View File

@@ -57,12 +57,30 @@ namespace FlaxEditor.Windows.Profiler
: base("CPU")
{
// Layout
var panel = new Panel(ScrollBars.Vertical)
var mainPanel = new Panel(ScrollBars.None)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
Parent = this,
};
// Chart
_mainChart = new SingleChart
{
Title = "Update",
AnchorPreset = AnchorPresets.HorizontalStretchTop,
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = mainPanel,
};
_mainChart.SelectedSampleChanged += OnSelectedSampleChanged;
var panel = new Panel(ScrollBars.Vertical)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, _mainChart.Height + 2, 0),
Parent = mainPanel,
};
//panel.Y = _mainChart.Height + 2;
var layout = new VerticalPanel
{
AnchorPreset = AnchorPresets.HorizontalStretchTop,
@@ -70,16 +88,7 @@ namespace FlaxEditor.Windows.Profiler
IsScrollable = true,
Parent = panel,
};
// Chart
_mainChart = new SingleChart
{
Title = "Update",
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = layout,
};
_mainChart.SelectedSampleChanged += OnSelectedSampleChanged;
// Timeline
_timeline = new Timeline
{

View File

@@ -25,12 +25,39 @@ namespace FlaxEditor.Windows.Profiler
: base("GPU")
{
// Layout
var panel = new Panel(ScrollBars.Vertical)
var mainPanel = new Panel(ScrollBars.None)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
Parent = this,
};
// Chart
_drawTimeCPU = new SingleChart
{
Title = "Draw (CPU)",
AnchorPreset = AnchorPresets.HorizontalStretchTop,
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = mainPanel,
};
_drawTimeCPU.SelectedSampleChanged += OnSelectedSampleChanged;
_drawTimeGPU = new SingleChart
{
Title = "Draw (GPU)",
AnchorPreset = AnchorPresets.HorizontalStretchTop,
Offsets = new Margin(0, 0, _drawTimeCPU.Height + 2, 0),
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = mainPanel,
};
_drawTimeGPU.SelectedSampleChanged += OnSelectedSampleChanged;
var panel = new Panel(ScrollBars.Vertical)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, _drawTimeCPU.Height + _drawTimeGPU.Height + 4, 0),
Parent = mainPanel,
};
var layout = new VerticalPanel
{
AnchorPreset = AnchorPresets.HorizontalStretchTop,
@@ -39,22 +66,6 @@ namespace FlaxEditor.Windows.Profiler
Parent = panel,
};
// Chart
_drawTimeCPU = new SingleChart
{
Title = "Draw (CPU)",
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = layout,
};
_drawTimeCPU.SelectedSampleChanged += OnSelectedSampleChanged;
_drawTimeGPU = new SingleChart
{
Title = "Draw (GPU)",
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = layout,
};
_drawTimeGPU.SelectedSampleChanged += OnSelectedSampleChanged;
// Timeline
_timeline = new Timeline
{

View File

@@ -39,12 +39,29 @@ namespace FlaxEditor.Windows.Profiler
: base("GPU Memory")
{
// Layout
var panel = new Panel(ScrollBars.Vertical)
var mainPanel = new Panel(ScrollBars.None)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
Parent = this,
};
// Chart
_memoryUsageChart = new SingleChart
{
Title = "GPU Memory Usage",
AnchorPreset = AnchorPresets.HorizontalStretchTop,
FormatSample = v => Utilities.Utils.FormatBytesCount((int)v),
Parent = mainPanel,
};
_memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged;
var panel = new Panel(ScrollBars.Vertical)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, _memoryUsageChart.Height + 2, 0),
Parent = mainPanel,
};
var layout = new VerticalPanel
{
AnchorPreset = AnchorPresets.HorizontalStretchTop,
@@ -53,15 +70,6 @@ namespace FlaxEditor.Windows.Profiler
Parent = panel,
};
// Chart
_memoryUsageChart = new SingleChart
{
Title = "GPU Memory Usage",
FormatSample = v => Utilities.Utils.FormatBytesCount((int)v),
Parent = layout,
};
_memoryUsageChart.SelectedSampleChanged += OnSelectedSampleChanged;
// Table
var style = Style.Current;
var headerColor = style.LightBackground;

View File

@@ -33,6 +33,7 @@ namespace FlaxEditor.Windows
private DragControlType _dragControlType;
private DragScriptItems _dragScriptItems;
private DragHandlers _dragHandlers;
private bool _isDropping = false;
/// <summary>
/// Scene tree panel.
@@ -356,10 +357,12 @@ namespace FlaxEditor.Windows
if (buttons == MouseButton.Left)
{
if (Editor.StateMachine.CurrentState.CanEditScene)
if (Editor.StateMachine.CurrentState.CanEditScene && !_isDropping)
{
Editor.SceneEditing.Deselect();
}
if (_isDropping)
_isDropping = false;
return true;
}
@@ -439,9 +442,11 @@ namespace FlaxEditor.Windows
var result = base.OnDragDrop(ref location, data);
if (result == DragDropEffect.None)
{
_isDropping = true;
// Drag assets
if (_dragAssets != null && _dragAssets.HasValidDrag)
{
List<SceneGraphNode> graphNodes = new List<SceneGraphNode>();
for (int i = 0; i < _dragAssets.Objects.Count; i++)
{
var item = _dragAssets.Objects[i];
@@ -453,8 +458,13 @@ namespace FlaxEditor.Windows
var actor = item.OnEditorDrop(this);
actor.Name = item.ShortName;
Level.SpawnActor(actor);
var graphNode = Editor.Scene.GetActorNode(actor.ID);
if (graphNode != null)
graphNodes.Add(graphNode);
Editor.Scene.MarkSceneEdited(actor.Scene);
}
if (graphNodes.Count > 0)
Editor.SceneEditing.Select(graphNodes);
result = DragDropEffect.Move;
}
// Drag actor type
@@ -500,6 +510,7 @@ namespace FlaxEditor.Windows
// Drag script item
else if (_dragScriptItems != null && _dragScriptItems.HasValidDrag)
{
List<SceneGraphNode> graphNodes = new List<SceneGraphNode>();
for (int i = 0; i < _dragScriptItems.Objects.Count; i++)
{
var item = _dragScriptItems.Objects[i];
@@ -514,9 +525,14 @@ namespace FlaxEditor.Windows
}
actor.Name = actorType.Name;
Level.SpawnActor(actor);
var graphNode = Editor.Scene.GetActorNode(actor.ID);
if (graphNode != null)
graphNodes.Add(graphNode);
Editor.Scene.MarkSceneEdited(actor.Scene);
}
}
if (graphNodes.Count > 0)
Editor.SceneEditing.Select(graphNodes);
result = DragDropEffect.Move;
}