Merge branch 'master' into local

This commit is contained in:
Nejcraft
2021-08-23 20:40:37 +02:00
committed by GitHub
79 changed files with 21230 additions and 640 deletions
+7 -11
View File
@@ -32,14 +32,14 @@ namespace FlaxEditor.Content.GUI
/// </summary>
public enum SortType
{
/// <summary>
/// <summary>
/// The classic alphabetic sort method (A-Z).
/// </summary>
AlphabeticOrder,
/// <summary>
/// <summary>
/// The reverse alphabetic sort method (Z-A).
/// </summary>
/// </summary>
AlphabeticReverse
}
@@ -272,18 +272,14 @@ namespace FlaxEditor.Content.GUI
if (sortType == SortType.AlphabeticReverse)
{
if (control.CompareTo(control1) > 0)
{
return -1;
}
return -1;
if (control.CompareTo(control1) == 0)
{
return 0;
}
return 0;
return 1;
}
return control.CompareTo(control1);
}));
// Unload and perform UI layout
IsLayoutLocked = wasLayoutLocked;
PerformLayout();
@@ -625,10 +625,11 @@ namespace FlaxEditor.CustomEditors.Dedicated
group.Panel.Open(false);
// Customize
var typeAttributes = scriptType.GetAttributes(true);
var typeAttributes = scriptType.GetAttributes(false);
group.Panel.TooltipText = scriptType.TypeName;
var tooltip = (TooltipAttribute)typeAttributes.FirstOrDefault(x => x is TooltipAttribute);
if (tooltip != null)
group.Panel.TooltipText = tooltip.Text;
group.Panel.TooltipText += '\n' + tooltip.Text;
if (script.HasPrefabLink)
group.Panel.HeaderTextColor = FlaxEngine.GUI.Style.Current.ProgressNormal;
+12 -1
View File
@@ -83,7 +83,18 @@ namespace FlaxEditor.GUI
{
_editor._mainPanel.ViewOffset += delta;
_movingViewLastPos = location;
Cursor = CursorType.SizeAll;
switch (_editor.EnablePanning)
{
case UseMode.Vertical:
Cursor = CursorType.SizeNS;
break;
case UseMode.Horizontal:
Cursor = CursorType.SizeWE;
break;
case UseMode.On:
Cursor = CursorType.SizeAll;
break;
}
}
return;
+41 -10
View File
@@ -46,10 +46,16 @@ namespace FlaxEditor.GUI.Timeline.GUI
var areaLeft = -X;
var areaRight = Parent.Width + mediaBackground.ControlsBounds.BottomRight.X;
var height = Height;
var leftSideMin = PointFromParent(Vector2.Zero);
var leftSideMax = BottomLeft;
var rightSideMin = UpperRight;
var rightSideMax = PointFromParent(Parent.BottomRight) + mediaBackground.ControlsBounds.BottomRight;
// Calculate the timeline range in the view to optimize background drawing
Render2D.PeekClip(out var globalClipping);
Render2D.PeekTransform(out var globalTransform);
var globalRect = new Rectangle(globalTransform.M31 + areaLeft, globalTransform.M32, areaRight * globalTransform.M11, height * globalTransform.M22);
var globalMask = Rectangle.Shared(globalClipping, globalRect);
var globalTransformInv = Matrix3x3.Invert(globalTransform);
var localRect = Rectangle.FromPoints(Matrix3x3.Transform2D(globalMask.UpperLeft, globalTransformInv), Matrix3x3.Transform2D(globalMask.BottomRight, globalTransformInv));
var localRectMin = localRect.UpperLeft;
var localRectMax = localRect.BottomRight;
// Draw lines between tracks
Render2D.DrawLine(new Vector2(areaLeft, 0.5f), new Vector2(areaRight, 0.5f), linesColor);
@@ -77,8 +83,8 @@ namespace FlaxEditor.GUI.Timeline.GUI
var minDistanceBetweenTicks = 50.0f;
var maxDistanceBetweenTicks = 100.0f;
var zoom = Timeline.UnitsPerSecond * _timeline.Zoom;
var left = Vector2.Min(leftSideMin, rightSideMax).X;
var right = Vector2.Max(leftSideMin, rightSideMax).X;
var left = Vector2.Min(localRectMin, localRectMax).X;
var right = Vector2.Max(localRectMin, localRectMax).X;
var leftFrame = Mathf.Floor((left - Timeline.StartOffset) / zoom) * _timeline.FramesPerSecond;
var rightFrame = Mathf.Ceil((right - Timeline.StartOffset) / zoom) * _timeline.FramesPerSecond;
var min = leftFrame;
@@ -146,9 +152,15 @@ namespace FlaxEditor.GUI.Timeline.GUI
}
// Darken area outside the duration
var outsideDurationAreaColor = new Color(0, 0, 0, 100);
Render2D.FillRectangle(new Rectangle(leftSideMin, leftSideMax.X - leftSideMin.X, height), outsideDurationAreaColor);
Render2D.FillRectangle(new Rectangle(rightSideMin, rightSideMax.X - rightSideMin.X, height), outsideDurationAreaColor);
{
var outsideDurationAreaColor = new Color(0, 0, 0, 100);
var leftSideMin = PointFromParent(Vector2.Zero);
var leftSideMax = BottomLeft;
var rightSideMin = UpperRight;
var rightSideMax = PointFromParent(Parent.BottomRight) + mediaBackground.ControlsBounds.BottomRight;
Render2D.FillRectangle(new Rectangle(leftSideMin, leftSideMax.X - leftSideMin.X, height), outsideDurationAreaColor);
Render2D.FillRectangle(new Rectangle(rightSideMin, rightSideMax.X - rightSideMin.X, height), outsideDurationAreaColor);
}
// Draw time axis header
var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y;
@@ -211,11 +223,30 @@ namespace FlaxEditor.GUI.Timeline.GUI
// Zoom in/out
if (IsMouseOver && Root.GetKey(KeyboardKeys.Control))
{
// TODO: preserve the view center point for easier zooming
var locationTimeOld = _timeline.MediaBackground.PointFromParent(_timeline, _timeline.Size * 0.5f).X;
var frame = (locationTimeOld - Timeline.StartOffset * 2.0f) / _timeline.Zoom / Timeline.UnitsPerSecond * _timeline.FramesPerSecond;
_timeline.Zoom += delta * 0.1f;
var locationTimeNew = frame / _timeline.FramesPerSecond * Timeline.UnitsPerSecond * _timeline.Zoom + Timeline.StartOffset * 2.0f;
var locationTimeDelta = locationTimeNew - locationTimeOld;
var scroll = _timeline.MediaBackground.HScrollBar;
if (scroll.Visible && scroll.Enabled)
scroll.TargetValue += locationTimeDelta;
return true;
}
// Scroll view horizontally
if (IsMouseOver && Root.GetKey(KeyboardKeys.Shift))
{
var scroll = _timeline.MediaBackground.HScrollBar;
if (scroll.Visible && scroll.Enabled)
{
scroll.TargetValue -= delta * Timeline.UnitsPerSecond / _timeline.Zoom;
return true;
}
}
return false;
}
@@ -18,6 +18,9 @@ namespace FlaxEditor.GUI.Timeline.GUI
public BackgroundArea(Timeline timeline)
: base(ScrollBars.Both)
{
ScrollBarsSize = 18.0f;
VScrollBar.ThumbThickness = 10.0f;
HScrollBar.ThumbThickness = 10.0f;
_timeline = timeline;
}
@@ -17,7 +17,90 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// <seealso cref="MemberTrack" />
public abstract class CurvePropertyTrackBase : MemberTrack
{
private sealed class Splitter : Control
{
private bool _clicked;
internal CurvePropertyTrackBase _track;
public override void Draw()
{
var style = Style.Current;
if (IsMouseOver || _clicked)
Render2D.FillRectangle(new Rectangle(Vector2.Zero, Size), _clicked ? style.BackgroundSelected : style.BackgroundHighlighted);
}
public override void OnEndMouseCapture()
{
base.OnEndMouseCapture();
_clicked = false;
}
public override void Defocus()
{
base.Defocus();
_clicked = false;
}
public override void OnMouseEnter(Vector2 location)
{
base.OnMouseEnter(location);
Cursor = CursorType.SizeNS;
}
public override void OnMouseLeave()
{
Cursor = CursorType.Default;
base.OnMouseLeave();
}
public override bool OnMouseDown(Vector2 location, MouseButton button)
{
if (button == MouseButton.Left)
{
_clicked = true;
Focus();
StartMouseCapture();
return true;
}
return base.OnMouseDown(location, button);
}
public override void OnMouseMove(Vector2 location)
{
base.OnMouseMove(location);
if (_clicked)
{
var height = Mathf.Clamp(PointToParent(location).Y, 40.0f, 1000.0f);
if (!Mathf.NearEqual(height, _track._expandedHeight))
{
_track.Height = _track._expandedHeight = height;
_track.Timeline.ArrangeTracks();
}
}
}
public override bool OnMouseUp(Vector2 location, MouseButton button)
{
if (button == MouseButton.Left && _clicked)
{
_clicked = false;
EndMouseCapture();
return true;
}
return base.OnMouseUp(location, button);
}
}
private byte[] _curveEditingStartData;
private float _expandedHeight = 120.0f;
private Splitter _splitter;
/// <summary>
/// The curve editor.
@@ -25,7 +108,6 @@ namespace FlaxEditor.GUI.Timeline.Tracks
public CurveEditorBase Curve;
private const float CollapsedHeight = 20.0f;
private const float ExpandedHeight = 120.0f;
/// <inheritdoc />
public CurvePropertyTrackBase(ref TrackCreateOptions options)
@@ -155,6 +237,17 @@ namespace FlaxEditor.GUI.Timeline.Tracks
Curve.EnablePanning = expanded ? CurveEditorBase.UseMode.Vertical : CurveEditorBase.UseMode.Off;
Curve.ScrollBars = expanded ? ScrollBars.Vertical : ScrollBars.None;
Curve.UpdateKeyframes();
if (expanded)
{
if(_splitter == null)
_splitter = new Splitter
{
_track = this,
Parent = Curve,
};
var splitterHeight = 4.0f;
_splitter.Bounds = new Rectangle(0, Curve.Height - splitterHeight, Curve.Width, splitterHeight);
}
}
private void OnKeyframesEdited()
@@ -217,10 +310,10 @@ namespace FlaxEditor.GUI.Timeline.Tracks
{
if (Curve == null)
return;
Curve.Edited -= OnKeyframesEdited;
Curve.Dispose();
Curve = null;
_splitter = null;
}
/// <inheritdoc />
@@ -257,7 +350,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// <inheritdoc />
protected override void OnExpandedChanged()
{
Height = IsExpanded ? ExpandedHeight : CollapsedHeight;
Height = IsExpanded ? _expandedHeight : CollapsedHeight;
UpdateCurve();
if (IsExpanded)
Curve.ShowWholeCurve();
+18 -8
View File
@@ -153,17 +153,16 @@ namespace FlaxEditor.Modules
};
}
}
Profiler.BeginEvent("ContentFinding.Search");
string type = ".*";
string name = charsToFind.Trim();
if (charsToFind.Contains(':'))
{
var args = charsToFind.Split(':');
type = ".*" + args[1].Trim() + ".*";
name = ".*" + args[0].Trim() + ".*";
}
if (name.Equals(string.Empty))
name = ".*";
@@ -173,17 +172,28 @@ namespace FlaxEditor.Modules
foreach (var project in Editor.Instance.ContentDatabase.Projects)
{
Profiler.BeginEvent(project.Project.Name);
ProcessItems(nameRegex, typeRegex, project.Folder.Children, matches);
Profiler.EndEvent();
}
//ProcessSceneNodes(nameRegex, typeRegex, Editor.Instance.Scene.Root, matches);
ProcessActors(nameRegex, typeRegex, Editor.Instance.Scene.Root, matches);
_quickActions.ForEach(action =>
{
if (nameRegex.Match(action.Name).Success && typeRegex.Match("Quick Action").Success)
matches.Add(new SearchResult { Name = action.Name, Type = "Quick Action", Item = action });
});
Profiler.BeginEvent("Actors");
ProcessActors(nameRegex, typeRegex, Editor.Instance.Scene.Root, matches);
Profiler.EndEvent();
}
{
Profiler.BeginEvent("QuickActions");
_quickActions.ForEach(action =>
{
if (nameRegex.Match(action.Name).Success && typeRegex.Match("Quick Action").Success)
matches.Add(new SearchResult { Name = action.Name, Type = "Quick Action", Item = action });
});
Profiler.EndEvent();
}
Profiler.EndEvent();
return matches;
}
@@ -239,7 +239,6 @@ bool ScriptsBuilder::RunBuildTool(const StringView& args)
cmdLine.Append(buildToolPath);
cmdLine.Append(TEXT("\" "));
cmdLine.Append(args.Get(), args.Length());
cmdLine.Append(TEXT('\0'));
// TODO: Set env var for the mono MONO_GC_PARAMS=nursery-size64m to boost build performance -> profile it
// Call build tool
@@ -107,14 +107,18 @@ namespace FlaxEditor.Surface.ContextMenu
private void BuildList(List<SearchResult> items)
{
_resultPanel.DisposeChildren();
LockChildrenRecursive();
var dpiScale = DpiScale;
var window = RootWindow.Window;
if (items.Count == 0)
{
Height = _searchBox.Height + 1;
_resultPanel.ScrollBars = ScrollBars.None;
RootWindow.Window.ClientSize = new Vector2(RootWindow.Window.ClientSize.X, Height * dpiScale);
window.ClientSize = new Vector2(window.ClientSize.X, Height * dpiScale);
UnlockChildrenRecursive();
PerformLayout();
return;
}
@@ -148,8 +152,9 @@ namespace FlaxEditor.Surface.ContextMenu
MatchedItems.Add(searchItem);
}
RootWindow.Window.ClientSize = new Vector2(RootWindow.Window.ClientSize.X, Height * dpiScale);
window.ClientSize = new Vector2(window.ClientSize.X, Height * dpiScale);
UnlockChildrenRecursive();
PerformLayout();
}
+6 -2
View File
@@ -221,16 +221,20 @@ namespace FlaxEditor
var snapshotInstances = (object[])snapshotInstance;
if (snapshotInstances == null || snapshotInstances.Length != SnapshotInstances.Length)
throw new ArgumentException("Invalid multi undo action objects.");
var actions = new List<UndoActionObject>();
List<UndoActionObject> actions = null;
for (int i = 0; i < snapshotInstances.Length; i++)
{
var diff = Snapshot[i].Compare(snapshotInstances[i]);
if (diff.Count == 0)
continue;
if (actions == null)
actions = new List<UndoActionObject>();
actions.Add(new UndoActionObject(diff, ActionString, SnapshotInstances[i]));
}
if (actions.Count == 0)
if (actions == null)
return null;
if (actions.Count == 1)
return actions[0];
return new MultiUndoAction(actions);
}
}
+1 -1
View File
@@ -816,6 +816,6 @@ bool EditorUtilities::ReplaceInFile(const StringView& file, const StringView& fi
String text;
if (File::ReadAllText(file, text))
return true;
text.Replace(findWhat.GetText(), replaceWith.GetText());
text.Replace(findWhat.Get(), findWhat.Length(), replaceWith.Get(), replaceWith.Length());
return File::WriteAllText(file, text, Encoding::ANSI);
}
@@ -145,18 +145,31 @@ namespace FlaxEditor.Viewport.Previews
const uint maxSamplesPerIndex = 64;
uint samplesPerIndexDiff = Math.Max(1, samplesPerIndex / Math.Min(samplesPerIndex, maxSamplesPerIndex));
// Calculate the clip range in the view to optimize drawing (eg. if only part fo the clip is visible)
Render2D.PeekClip(out var globalClipping);
Render2D.PeekTransform(out var globalTransform);
var globalRect = new Rectangle(globalTransform.M31, globalTransform.M32, width * globalTransform.M11, height * globalTransform.M22);
var globalMask = Rectangle.Shared(globalClipping, globalRect);
var globalTransformInv = Matrix3x3.Invert(globalTransform);
var localRect = Rectangle.FromPoints(Matrix3x3.Transform2D(globalMask.UpperLeft, globalTransformInv), Matrix3x3.Transform2D(globalMask.BottomRight, globalTransformInv));
var localRectMin = localRect.UpperLeft;
var localRectMax = localRect.BottomRight;
// Render each clip separately
for (uint clipIndex = 0; clipIndex < Mathf.CeilToInt(clipsInView); clipIndex++)
{
var clipX = clipWidth * clipIndex;
var clipRight = Mathf.Min(width, clipX + clipWidth);
var clipStart = clipWidth * clipIndex;
var clipEnd = clipStart + clipWidth;
var xStart = Mathf.Max(clipStart, localRectMin.X);
var xEnd = Mathf.Min(Mathf.Min(width, clipEnd), localRectMax.X);
var samplesOffset = (uint)((xStart - clipStart) * samplesPerIndex);
// Render every audio channel separately
for (uint channelIndex = 0; channelIndex < info.NumChannels; channelIndex++)
{
uint currentSample = channelIndex;
uint currentSample = channelIndex + samplesOffset;
float yCenter = Y + ((2 * channelIndex) + 1) * height / (2.0f * info.NumChannels);
for (float pixelX = clipX; pixelX < clipRight; pixelX++)
for (float pixelX = xStart; pixelX < xEnd; pixelX++)
{
float samplesSum = 0;
int samplesInPixel = 0;
+6 -6
View File
@@ -538,9 +538,9 @@ namespace FlaxEditor.Windows.Assets
for (int i = 0; i < meshData.IndexBuffer.Length; i += 3)
{
// Cache triangle indices
int i0 = meshData.IndexBuffer[i + 0];
int i1 = meshData.IndexBuffer[i + 1];
int i2 = meshData.IndexBuffer[i + 2];
uint i0 = meshData.IndexBuffer[i + 0];
uint i1 = meshData.IndexBuffer[i + 1];
uint i2 = meshData.IndexBuffer[i + 2];
// Cache triangle uvs positions and transform positions to output target
Vector2 uv0 = meshData.VertexBuffer[i0].TexCoord * uvScale;
@@ -562,9 +562,9 @@ namespace FlaxEditor.Windows.Assets
for (int i = 0; i < meshData.IndexBuffer.Length; i += 3)
{
// Cache triangle indices
int i0 = meshData.IndexBuffer[i + 0];
int i1 = meshData.IndexBuffer[i + 1];
int i2 = meshData.IndexBuffer[i + 2];
uint i0 = meshData.IndexBuffer[i + 0];
uint i1 = meshData.IndexBuffer[i + 1];
uint i2 = meshData.IndexBuffer[i + 2];
// Cache triangle uvs positions and transform positions to output target
Vector2 uv0 = meshData.VertexBuffer[i0].LightmapUVs * uvScale;
@@ -645,9 +645,9 @@ namespace FlaxEditor.Windows.Assets
for (int i = 0; i < meshData.IndexBuffer.Length; i += 3)
{
// Cache triangle indices
int i0 = meshData.IndexBuffer[i + 0];
int i1 = meshData.IndexBuffer[i + 1];
int i2 = meshData.IndexBuffer[i + 2];
uint i0 = meshData.IndexBuffer[i + 0];
uint i1 = meshData.IndexBuffer[i + 1];
uint i2 = meshData.IndexBuffer[i + 2];
// Cache triangle uvs positions and transform positions to output target
Vector2 uv0 = meshData.VertexBuffer[i0].TexCoord * uvScale;
@@ -820,7 +820,7 @@ namespace FlaxEditor.Windows.Assets
private struct MeshData
{
public int[] IndexBuffer;
public uint[] IndexBuffer;
public SkinnedMesh.Vertex[] VertexBuffer;
}
+27
View File
@@ -1,6 +1,7 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using System.Xml;
using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.GUI.Input;
using FlaxEditor.Options;
@@ -484,5 +485,31 @@ namespace FlaxEditor.Windows
return result;
}
/// <inheritdoc />
public override bool UseLayoutData => true;
/// <inheritdoc />
public override void OnLayoutSerialize(XmlWriter writer)
{
writer.WriteAttributeString("ShowGUI", ShowGUI.ToString());
writer.WriteAttributeString("ShowDebugDraw", ShowDebugDraw.ToString());
}
/// <inheritdoc />
public override void OnLayoutDeserialize(XmlElement node)
{
if (bool.TryParse(node.GetAttribute("ShowGUI"), out bool value1))
ShowGUI = value1;
if (bool.TryParse(node.GetAttribute("ShowDebugDraw"), out value1))
ShowDebugDraw = value1;
}
/// <inheritdoc />
public override void OnLayoutDeserialize()
{
ShowGUI = true;
ShowDebugDraw = false;
}
}
}
+1
View File
@@ -192,6 +192,7 @@ namespace FlaxEditor.Windows
_contextMenu.AddButton("Clear log", Clear);
_contextMenu.AddButton("Copy selection", _output.Copy);
_contextMenu.AddButton("Select All", _output.SelectAll);
_contextMenu.AddButton("Show in explorer", () => FileSystem.ShowFileExplorer(Path.Combine(Globals.ProjectFolder, "Logs")));
_contextMenu.AddButton("Scroll to bottom", () => { _vScroll.TargetValue = _vScroll.Maximum; }).Icon = Editor.Icons.ArrowDown12;
// Setup editor options
+2 -1
View File
@@ -131,7 +131,8 @@ const Char* SplashScreenQuotes[] =
TEXT("ZOINKS"),
TEXT("Scooby dooby doo"),
TEXT("You shall not load!"),
TEXT("The roof, the roof, the roof is on fire!")
TEXT("The roof, the roof, the roof is on fire!"),
TEXT("I've seen better documentation ...\nFrom ransomware gangs !")
};
SplashScreen::~SplashScreen()