Merge remote-tracking branch 'origin/master' into 1.10
This commit is contained in:
@@ -200,7 +200,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
ViewportCamera = new FPSCamera(),
|
||||
Parent = _split.Panel1
|
||||
};
|
||||
_preview.Task.ViewFlags &= ~ViewFlags.Sky & ~ViewFlags.Bloom;
|
||||
_preview.Task.ViewFlags &= ~ViewFlags.Sky & ~ViewFlags.Bloom & ~ViewFlags.EyeAdaptation;
|
||||
|
||||
// Asset properties
|
||||
_propertiesPresenter = new CustomEditorPresenter(null);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.GUI.Drag;
|
||||
@@ -86,7 +85,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
{
|
||||
return Editor.Instance.CodeEditing.Actors.Get().Contains(actorType);
|
||||
}
|
||||
|
||||
|
||||
private static bool ValidateDragControlType(ScriptType controlType)
|
||||
{
|
||||
return Editor.Instance.CodeEditing.Controls.Get().Contains(controlType);
|
||||
@@ -171,7 +170,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
var actor = item.OnEditorDrop(this);
|
||||
actor.Name = item.ShortName;
|
||||
_window.Spawn(actor);
|
||||
var graphNode = _window.Graph.Root.Find(actor);;
|
||||
var graphNode = _window.Graph.Root.Find(actor);
|
||||
;
|
||||
if (graphNode != null)
|
||||
graphNodes.Add(graphNode);
|
||||
}
|
||||
@@ -235,7 +235,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
}
|
||||
actor.Name = actorType.Name;
|
||||
_window.Spawn(actor);
|
||||
var graphNode = _window.Graph.Root.Find(actor);;
|
||||
var graphNode = _window.Graph.Root.Find(actor);
|
||||
;
|
||||
if (graphNode != null)
|
||||
graphNodes.Add(graphNode);
|
||||
}
|
||||
@@ -292,7 +293,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
// Basic editing options
|
||||
|
||||
var b = contextMenu.AddButton("Rename", Rename);
|
||||
var b = contextMenu.AddButton("Rename", RenameSelection);
|
||||
b.Enabled = isSingleActorSelected;
|
||||
|
||||
b = contextMenu.AddButton("Duplicate", Duplicate);
|
||||
@@ -416,7 +417,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
contextMenu.Show(parent, location);
|
||||
}
|
||||
|
||||
private void Rename()
|
||||
/// <inheritdoc />
|
||||
public void RenameSelection()
|
||||
{
|
||||
var selection = Selection;
|
||||
if (selection.Count != 0 && selection[0] is ActorNode actor)
|
||||
@@ -427,6 +429,12 @@ namespace FlaxEditor.Windows.Assets
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void FocusSelection()
|
||||
{
|
||||
_viewport.FocusSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns the specified actor to the prefab (adds actor to root).
|
||||
/// </summary>
|
||||
@@ -470,7 +478,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
// Spawn it
|
||||
Spawn(actor);
|
||||
Rename();
|
||||
RenameSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
/// </summary>
|
||||
/// <seealso cref="Prefab" />
|
||||
/// <seealso cref="FlaxEditor.Windows.Assets.AssetEditorWindow" />
|
||||
public sealed partial class PrefabWindow : AssetEditorWindowBase<Prefab>, IPresenterOwner
|
||||
public sealed partial class PrefabWindow : AssetEditorWindowBase<Prefab>, IPresenterOwner, ISceneContextWindow
|
||||
{
|
||||
private readonly SplitPanel _split1;
|
||||
private readonly SplitPanel _split2;
|
||||
@@ -212,8 +212,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
InputActions.Add(options => options.Paste, Paste);
|
||||
InputActions.Add(options => options.Duplicate, Duplicate);
|
||||
InputActions.Add(options => options.Delete, Delete);
|
||||
InputActions.Add(options => options.Rename, Rename);
|
||||
InputActions.Add(options => options.FocusSelection, _viewport.FocusSelection);
|
||||
InputActions.Add(options => options.Rename, RenameSelection);
|
||||
InputActions.Add(options => options.FocusSelection, FocusSelection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -95,15 +95,15 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
case LogType.Warning:
|
||||
Group = LogGroup.Warning;
|
||||
Icon = _window.IconWarning;
|
||||
Icon = _window._iconWarning;
|
||||
break;
|
||||
case LogType.Info:
|
||||
Group = LogGroup.Info;
|
||||
Icon = _window.IconInfo;
|
||||
Icon = _window._iconInfo;
|
||||
break;
|
||||
default:
|
||||
Group = LogGroup.Error;
|
||||
Icon = _window.IconError;
|
||||
Icon = _window._iconError;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -131,20 +131,21 @@ namespace FlaxEditor.Windows
|
||||
else if (index % 2 == 0)
|
||||
Render2D.FillRectangle(clientRect, style.Background * 0.9f);
|
||||
|
||||
var color = Group == LogGroup.Error ? _window._colorError : (Group == LogGroup.Warning ? _window._colorWarning : _window._colorInfo);
|
||||
|
||||
// Icon
|
||||
var iconColor = Group == LogGroup.Error ? Color.Red : (Group == LogGroup.Warning ? Color.Yellow : style.Foreground);
|
||||
Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), iconColor);
|
||||
Render2D.DrawSprite(Icon, new Rectangle(5, 0, 32, 32), color);
|
||||
|
||||
// Title
|
||||
var textRect = new Rectangle(38, 2, clientRect.Width - 40, clientRect.Height - 10);
|
||||
Render2D.PushClip(ref clientRect);
|
||||
if (LogCount == 1)
|
||||
{
|
||||
Render2D.DrawText(style.FontMedium, Desc.Title, textRect, style.Foreground);
|
||||
Render2D.DrawText(style.FontMedium, Desc.Title, textRect, color);
|
||||
}
|
||||
else if (LogCount > 1)
|
||||
{
|
||||
Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, style.Foreground);
|
||||
Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, color);
|
||||
}
|
||||
Render2D.PopClip();
|
||||
}
|
||||
@@ -304,10 +305,12 @@ namespace FlaxEditor.Windows
|
||||
private readonly ToolStripButton[] _groupButtons = new ToolStripButton[3];
|
||||
|
||||
private LogType _iconType = LogType.Info;
|
||||
|
||||
internal SpriteHandle IconInfo;
|
||||
internal SpriteHandle IconWarning;
|
||||
internal SpriteHandle IconError;
|
||||
private SpriteHandle _iconInfo;
|
||||
private SpriteHandle _iconWarning;
|
||||
private SpriteHandle _iconError;
|
||||
private Color _colorInfo;
|
||||
private Color _colorWarning;
|
||||
private Color _colorError;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DebugLogWindow"/> class.
|
||||
@@ -317,7 +320,7 @@ namespace FlaxEditor.Windows
|
||||
: base(editor, true, ScrollBars.None)
|
||||
{
|
||||
Title = "Debug Log";
|
||||
Icon = IconInfo;
|
||||
Icon = _iconInfo;
|
||||
FlaxEditor.Utilities.Utils.SetupCommonInputActions(this);
|
||||
|
||||
// Toolstrip
|
||||
@@ -361,7 +364,6 @@ namespace FlaxEditor.Windows
|
||||
editor.Options.Apply(editor.Options.Options);
|
||||
}).SetAutoCheck(true).LinkTooltip("Shows/hides info messages");
|
||||
UpdateCount();
|
||||
OnEditorOptionsChanged(Editor.Options.Options);
|
||||
|
||||
// Split panel
|
||||
_split = new SplitPanel(Orientation.Vertical, ScrollBars.Vertical, ScrollBars.Both)
|
||||
@@ -394,14 +396,17 @@ namespace FlaxEditor.Windows
|
||||
};
|
||||
|
||||
// Cache entries icons
|
||||
IconInfo = Editor.Icons.Info64;
|
||||
IconWarning = Editor.Icons.Warning64;
|
||||
IconError = Editor.Icons.Error64;
|
||||
_iconInfo = Editor.Icons.Info64;
|
||||
_iconWarning = Editor.Icons.Warning64;
|
||||
_iconError = Editor.Icons.Error64;
|
||||
|
||||
// Bind events
|
||||
Editor.Options.OptionsChanged += OnEditorOptionsChanged;
|
||||
Debug.Logger.LogHandler.SendLog += LogHandlerOnSendLog;
|
||||
Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog;
|
||||
|
||||
// Init editor options
|
||||
OnEditorOptionsChanged(Editor.Options.Options);
|
||||
}
|
||||
|
||||
private void OnEditorOptionsChanged(EditorOptions options)
|
||||
@@ -413,6 +418,9 @@ namespace FlaxEditor.Windows
|
||||
_groupButtons[0].Checked = options.Interface.DebugLogShowErrorMessages;
|
||||
_groupButtons[1].Checked = options.Interface.DebugLogShowWarningMessages;
|
||||
_groupButtons[2].Checked = options.Interface.DebugLogShowInfoMessages;
|
||||
_colorInfo = options.Interface.OutputLogTextColor;
|
||||
_colorWarning = options.Interface.OutputLogWarningTextColor;
|
||||
_colorError = options.Interface.OutputLogErrorTextColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -422,7 +430,6 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
if (_entriesPanel == null)
|
||||
return;
|
||||
|
||||
RemoveEntries();
|
||||
}
|
||||
|
||||
|
||||
@@ -596,7 +596,9 @@ namespace FlaxEditor.Windows
|
||||
_output.DefaultStyle.Font == options.Interface.OutputLogTextFont &&
|
||||
_output.DefaultStyle.Color == options.Interface.OutputLogTextColor &&
|
||||
_output.DefaultStyle.ShadowColor == options.Interface.OutputLogTextShadowColor &&
|
||||
_output.DefaultStyle.ShadowOffset == options.Interface.OutputLogTextShadowOffset)
|
||||
_output.DefaultStyle.ShadowOffset == options.Interface.OutputLogTextShadowOffset &&
|
||||
_output.WarningStyle.Color == options.Interface.OutputLogWarningTextColor &&
|
||||
_output.ErrorStyle.Color == options.Interface.OutputLogErrorTextColor)
|
||||
return;
|
||||
|
||||
_output.DefaultStyle = new TextBlockStyle
|
||||
@@ -607,10 +609,11 @@ namespace FlaxEditor.Windows
|
||||
ShadowOffset = options.Interface.OutputLogTextShadowOffset,
|
||||
BackgroundSelectedBrush = new SolidColorBrush(Style.Current.BackgroundSelected),
|
||||
};
|
||||
|
||||
_output.WarningStyle = _output.DefaultStyle;
|
||||
_output.WarningStyle.Color = Color.Yellow;
|
||||
_output.WarningStyle.Color = options.Interface.OutputLogWarningTextColor;
|
||||
_output.ErrorStyle = _output.DefaultStyle;
|
||||
_output.ErrorStyle.Color = Color.Red;
|
||||
_output.ErrorStyle.Color = options.Interface.OutputLogErrorTextColor;
|
||||
|
||||
_timestampsFormats = options.Interface.OutputLogTimestampsFormat;
|
||||
_showLogType = options.Interface.OutputLogShowLogType;
|
||||
@@ -938,7 +941,7 @@ namespace FlaxEditor.Windows
|
||||
var cachedScrollValue = _vScroll.Value;
|
||||
var cachedSelection = _output.SelectionRange;
|
||||
var cachedOutputTargetViewOffset = _output.TargetViewOffset;
|
||||
var isBottomScroll = _vScroll.Value >= _vScroll.Maximum - (_scrollSize*2) || wasEmpty;
|
||||
var isBottomScroll = _vScroll.Value >= _vScroll.Maximum - (_scrollSize * 2) || wasEmpty;
|
||||
_output.Text = _textBuffer.ToString();
|
||||
_output.TargetViewOffset = cachedOutputTargetViewOffset;
|
||||
_textBufferCount = _entries.Count;
|
||||
|
||||
@@ -1,14 +1,32 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
|
||||
namespace FlaxEditor.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Shared interface for scene editing utilities.
|
||||
/// </summary>
|
||||
public interface ISceneContextWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Opends popup for renaming selected objects.
|
||||
/// </summary>
|
||||
void RenameSelection();
|
||||
|
||||
/// <summary>
|
||||
/// Focuses selected objects.
|
||||
/// </summary>
|
||||
void FocusSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for editor windows dedicated to scene editing.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Windows.EditorWindow" />
|
||||
public abstract class SceneEditorWindow : EditorWindow
|
||||
public abstract class SceneEditorWindow : EditorWindow, ISceneContextWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SceneEditorWindow"/> class.
|
||||
@@ -21,5 +39,38 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
FlaxEditor.Utilities.Utils.SetupCommonInputActions(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void FocusSelection()
|
||||
{
|
||||
Editor.Windows.EditWin.Viewport.FocusSelection();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RenameSelection()
|
||||
{
|
||||
var selection = Editor.SceneEditing.Selection;
|
||||
var selectionCount = selection.Count;
|
||||
|
||||
// Show a window with options to rename multiple actors.
|
||||
if (selectionCount > 1)
|
||||
{
|
||||
var selectedActors = new Actor[selectionCount];
|
||||
|
||||
for (int i = 0; i < selectionCount; i++)
|
||||
if (selection[i] is ActorNode actorNode)
|
||||
selectedActors[i] = actorNode.Actor;
|
||||
|
||||
RenameWindow.Show(selectedActors, Editor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectionCount != 0 && selection[0] is ActorNode actor)
|
||||
{
|
||||
Editor.SceneEditing.Select(actor);
|
||||
var sceneWindow = Editor.Windows.SceneWin;
|
||||
actor.TreeNode.StartRenaming(sceneWindow, sceneWindow.SceneTreePanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace FlaxEditor.Windows
|
||||
|
||||
// Basic editing options
|
||||
var firstSelection = hasSthSelected ? Editor.SceneEditing.Selection[0] as ActorNode : null;
|
||||
b = contextMenu.AddButton("Rename", inputOptions.Rename, Rename);
|
||||
b = contextMenu.AddButton("Rename", inputOptions.Rename, RenameSelection);
|
||||
b.Enabled = hasSthSelected;
|
||||
b = contextMenu.AddButton("Duplicate", inputOptions.Duplicate, Editor.SceneEditing.Duplicate);
|
||||
b.Enabled = hasSthSelected && (firstSelection != null ? firstSelection.CanDuplicate : true);
|
||||
@@ -145,6 +145,7 @@ namespace FlaxEditor.Windows
|
||||
bool hasPrefabLink = canEditScene && isSingleActorSelected && (firstSelection != null ? firstSelection.HasPrefabLink : false);
|
||||
if (hasPrefabLink)
|
||||
{
|
||||
contextMenu.AddButton("Open Prefab", () => Editor.Prefabs.OpenPrefab(firstSelection));
|
||||
contextMenu.AddButton("Select Prefab", Editor.Prefabs.SelectPrefab);
|
||||
contextMenu.AddButton("Break Prefab Link", Editor.Prefabs.BreakLinks);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace FlaxEditor.Windows
|
||||
InputActions.Add(options => options.ScaleMode, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale);
|
||||
InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection());
|
||||
InputActions.Add(options => options.LockFocusSelection, () => Editor.Windows.EditWin.Viewport.LockFocusSelection());
|
||||
InputActions.Add(options => options.Rename, Rename);
|
||||
InputActions.Add(options => options.Rename, RenameSelection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -143,31 +143,6 @@ namespace FlaxEditor.Windows
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
private void Rename()
|
||||
{
|
||||
var selection = Editor.SceneEditing.Selection;
|
||||
var selectionCount = selection.Count;
|
||||
|
||||
// Show a window with options to rename multiple actors.
|
||||
if (selectionCount > 1)
|
||||
{
|
||||
var selectedActors = new Actor[selectionCount];
|
||||
|
||||
for (int i = 0; i < selectionCount; i++)
|
||||
if (selection[i] is ActorNode actorNode)
|
||||
selectedActors[i] = actorNode.Actor;
|
||||
|
||||
RenameWindow.Show(selectedActors, Editor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectionCount != 0 && selection[0] is ActorNode actor)
|
||||
{
|
||||
Editor.SceneEditing.Select(actor);
|
||||
actor.TreeNode.StartRenaming(this, _sceneTreePanel);
|
||||
}
|
||||
}
|
||||
|
||||
private void Spawn(Type type)
|
||||
{
|
||||
// Create actor
|
||||
@@ -197,7 +172,7 @@ namespace FlaxEditor.Windows
|
||||
Editor.SceneEditing.Spawn(actor, parentActor);
|
||||
|
||||
Editor.SceneEditing.Select(actor);
|
||||
Rename();
|
||||
RenameSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -293,7 +268,7 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
return Editor.Instance.CodeEditing.Actors.Get().Contains(actorType);
|
||||
}
|
||||
|
||||
|
||||
private static bool ValidateDragControlType(ScriptType controlType)
|
||||
{
|
||||
return Editor.Instance.CodeEditing.Controls.Get().Contains(controlType);
|
||||
|
||||
Reference in New Issue
Block a user