Merge branch '1.2' into IconOverhaul

This commit is contained in:
W2.Wizard
2021-05-13 15:21:36 +02:00
committed by GitHub
577 changed files with 26583 additions and 26529 deletions

View File

@@ -131,6 +131,7 @@ namespace FlaxEditor.Windows
"LZ4 Library - Copyright (c) Yann Collet. All rights reserved.",
"fmt - www.fmtlib.net",
"minimp3 - www.github.com/lieff/minimp3",
"Tracy Profiler - www.github.com/wolfpld/tracy",
"Ogg and Vorbis - Xiph.org Foundation",
"OpenAL Soft - www.github.com/kcat/openal-soft",
"OpenFBX - www.github.com/nem0/OpenFBX",

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using System.Xml;
using FlaxEditor.Content;
using FlaxEditor.Content.Create;
@@ -10,6 +11,7 @@ using FlaxEditor.Viewport.Cameras;
using FlaxEditor.Viewport.Previews;
using FlaxEngine;
using FlaxEngine.GUI;
using Object = FlaxEngine.Object;
namespace FlaxEditor.Windows.Assets
{
@@ -20,6 +22,15 @@ namespace FlaxEditor.Windows.Assets
/// <seealso cref="FlaxEditor.Windows.Assets.AssetEditorWindow" />
public sealed class CollisionDataWindow : AssetEditorWindowBase<CollisionData>
{
[Flags]
private enum MaterialSlotsMask : uint
{
// @formatter:off
Slot0=1u<<0,Slot1=1u<<1,Slot2=1u<<2,Slot3=1u<<3,Slot4=1u<<4,Slot5=1u<<5,Slot6=1u<<6,Slot7=1u<<7,Slot8=1u<<8,Slot9=1u<<9,Slot10=1u<<10,Slot11=1u<<11,Slot12=1u<<12,Slot13=1u<<13,Slot14=1u<<14,Slot15=1u<<15,Slot16=1u<<16,Slot17=1u<<17,Slot18=1u<<18,Slot19=1u<<19,Slot20=1u<<20,Slot21=1u<<21,Slot22=1u<<22,Slot23=1u<<23,Slot24=1u<<24,Slot25=1u<<25,Slot26=1u<<26,Slot27=1u<<27,Slot28=1u<<28,Slot29=1u<<29,Slot30=1u<<30,Slot31=1u<<31,
// @formatter:on
All = uint.MaxValue,
}
/// <summary>
/// The asset properties proxy object.
/// </summary>
@@ -34,11 +45,14 @@ namespace FlaxEditor.Windows.Assets
public CollisionDataType Type;
[EditorOrder(10), EditorDisplay("General"), Tooltip("Source model asset to use for collision data generation")]
public Model Model;
public ModelBase Model;
[EditorOrder(20), Limit(0, 5), EditorDisplay("General", "Model LOD Index"), Tooltip("Source model LOD index to use for collision data generation (will be clamped to the actual model LODs collection size)")]
public int ModelLodIndex;
[EditorOrder(30), EditorDisplay("General"), Tooltip("The source model material slots mask. One bit per-slot. Can be sued to exclude particular material slots from collision cooking.")]
public MaterialSlotsMask MaterialSlotsMask = MaterialSlotsMask.All;
[EditorOrder(100), EditorDisplay("Convex Mesh", "Convex Flags"), Tooltip("Convex mesh generation flags")]
public ConvexMeshGenerationFlags ConvexFlags;
@@ -88,28 +102,23 @@ namespace FlaxEditor.Windows.Assets
private class CookData : CreateFileEntry
{
private PropertiesProxy Proxy;
private CollisionDataType Type;
private Model Model;
private int ModelLodIndex;
private ConvexMeshGenerationFlags ConvexFlags;
private int ConvexVertexLimit;
public PropertiesProxy Proxy;
public CollisionDataType Type;
public ModelBase Model;
public int ModelLodIndex;
public uint MaterialSlotsMask;
public ConvexMeshGenerationFlags ConvexFlags;
public int ConvexVertexLimit;
public CookData(PropertiesProxy proxy, string resultUrl, CollisionDataType type, Model model, int modelLodIndex, ConvexMeshGenerationFlags convexFlags, int convexVertexLimit)
public CookData(string resultUrl)
: base("Collision Data", resultUrl)
{
Proxy = proxy;
Type = type;
Model = model;
ModelLodIndex = modelLodIndex;
ConvexFlags = convexFlags;
ConvexVertexLimit = convexVertexLimit;
}
/// <inheritdoc />
public override bool Create()
{
bool failed = FlaxEditor.Editor.CookMeshCollision(ResultUrl, Type, Model, ModelLodIndex, ConvexFlags, ConvexVertexLimit);
bool failed = FlaxEditor.Editor.CookMeshCollision(ResultUrl, Type, Model, ModelLodIndex, MaterialSlotsMask, ConvexFlags, ConvexVertexLimit);
Proxy._isCooking = false;
Proxy.Window.UpdateWiresModel();
@@ -121,7 +130,16 @@ namespace FlaxEditor.Windows.Assets
public void Cook()
{
_isCooking = true;
Window.Editor.ContentImporting.Create(new CookData(this, Asset.Path, Type, Model, ModelLodIndex, ConvexFlags, ConvexVertexLimit));
Window.Editor.ContentImporting.Create(new CookData(Asset.Path)
{
Proxy = this,
Type = Type,
Model = Model,
ModelLodIndex = ModelLodIndex,
MaterialSlotsMask = (uint)MaterialSlotsMask,
ConvexFlags = ConvexFlags,
ConvexVertexLimit = ConvexVertexLimit,
});
}
public void OnLoad(CollisionDataWindow window)
@@ -135,7 +153,7 @@ namespace FlaxEditor.Windows.Assets
Type = options.Type;
if (Type == CollisionDataType.None)
Type = CollisionDataType.ConvexMesh;
Model = FlaxEngine.Content.LoadAsync<Model>(options.Model);
Model = FlaxEngine.Content.LoadAsync<ModelBase>(options.Model);
ModelLodIndex = options.ModelLodIndex;
ConvexFlags = options.ConvexFlags;
ConvexVertexLimit = options.ConvexVertexLimit;
@@ -151,7 +169,7 @@ namespace FlaxEditor.Windows.Assets
}
private readonly SplitPanel _split;
private readonly ModelPreview _preview;
private readonly ModelBasePreview _preview;
private readonly CustomEditorPresenter _propertiesPresenter;
private readonly PropertiesProxy _properties;
private Model _collisionWiresModel;
@@ -176,7 +194,7 @@ namespace FlaxEditor.Windows.Assets
};
// Model preview
_preview = new ModelPreview(true)
_preview = new ModelBasePreview(true)
{
ViewportCamera = new FPSCamera(),
Parent = _split.Panel1
@@ -195,7 +213,7 @@ namespace FlaxEditor.Windows.Assets
// Sync helper actor size with actual preview model (preview scales model for better usage experience)
if (_collisionWiresShowActor && _collisionWiresShowActor.IsActive)
{
_collisionWiresShowActor.Transform = _preview.PreviewActor.Transform;
_collisionWiresShowActor.Transform = _preview.StaticModel.Transform;
}
base.Update(deltaTime);
@@ -230,14 +248,14 @@ namespace FlaxEditor.Windows.Assets
}
_collisionWiresShowActor.Model = _collisionWiresModel;
_collisionWiresShowActor.SetMaterial(0, FlaxEngine.Content.LoadAsyncInternal<MaterialBase>(EditorAssets.WiresDebugMaterial));
_preview.Model = FlaxEngine.Content.LoadAsync<Model>(_asset.Options.Model);
_preview.Asset = FlaxEngine.Content.LoadAsync<ModelBase>(_asset.Options.Model);
}
/// <inheritdoc />
protected override void UnlinkItem()
{
_properties.OnClean();
_preview.Model = null;
_preview.Asset = null;
base.UnlinkItem();
}
@@ -245,7 +263,7 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
protected override void OnAssetLinked()
{
_preview.Model = null;
_preview.Asset = null;
base.OnAssetLinked();
}

View File

@@ -17,6 +17,9 @@ namespace FlaxEditor.Windows.Assets
{
private readonly CustomEditorPresenter _presenter;
private readonly ToolStripButton _saveButton;
private readonly ToolStripButton _undoButton;
private readonly ToolStripButton _redoButton;
private readonly Undo _undo;
private object _object;
private bool _isRegisteredForScriptsReload;
@@ -24,8 +27,16 @@ namespace FlaxEditor.Windows.Assets
public JsonAssetWindow(Editor editor, AssetItem item)
: base(editor, item)
{
// Undo
_undo = new Undo();
_undo.UndoDone += OnUndoRedo;
_undo.RedoDone += OnUndoRedo;
// Toolstrip
_saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save");
_toolstrip.AddSeparator();
_undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo (Ctrl+Z)");
_redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo (Ctrl+Y)");
// Panel
var panel = new Panel(ScrollBars.Vertical)
@@ -36,9 +47,19 @@ namespace FlaxEditor.Windows.Assets
};
// Properties
_presenter = new CustomEditorPresenter(null, "Loading...");
_presenter = new CustomEditorPresenter(_undo, "Loading...");
_presenter.Panel.Parent = panel;
_presenter.Modified += MarkAsEdited;
// Setup input actions
InputActions.Add(options => options.Undo, _undo.PerformUndo);
InputActions.Add(options => options.Redo, _undo.PerformRedo);
}
private void OnUndoRedo(IUndoAction action)
{
MarkAsEdited();
UpdateToolstrip();
}
private void OnScriptsReloadBegin()
@@ -64,13 +85,14 @@ namespace FlaxEditor.Windows.Assets
}
ClearEditedFlag();
_item.RefreshThumbnail();
}
/// <inheritdoc />
protected override void UpdateToolstrip()
{
_saveButton.Enabled = IsEdited;
_undoButton.Enabled = _undo.CanUndo;
_redoButton.Enabled = _undo.CanRedo;
base.UpdateToolstrip();
}
@@ -80,6 +102,7 @@ namespace FlaxEditor.Windows.Assets
{
_object = Asset.CreateInstance();
_presenter.Select(_object);
_undo.Clear();
ClearEditedFlag();
// Auto-close on scripting reload if json asset is from game scripts (it might be reloaded)

View File

@@ -0,0 +1,212 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using FlaxEditor.Content;
using FlaxEditor.CustomEditors;
using FlaxEditor.GUI;
using FlaxEngine;
using FlaxEngine.GUI;
using FlaxEngine.Utilities;
namespace FlaxEditor.Windows.Assets
{
/// <summary>
/// Editor window to view/modify <see cref="LocalizedStringTable"/> asset.
/// </summary>
/// <seealso cref="LocalizedStringTable" />
/// <seealso cref="FlaxEditor.Windows.Assets.AssetEditorWindow" />
public sealed class LocalizedStringTableWindow : AssetEditorWindowBase<LocalizedStringTable>
{
private readonly CustomEditorPresenter _presenter;
private readonly ToolStripButton _saveButton;
private readonly ToolStripButton _undoButton;
private readonly ToolStripButton _redoButton;
private readonly Undo _undo;
private Proxy _proxy;
private class EntryEditor : CustomEditor
{
private TextBox[] _textBoxes;
private bool _isRefreshing;
public override void Initialize(LayoutElementsContainer layout)
{
var values = (string[])Values[0];
if (values == null || values.Length == 0)
{
values = new string[1];
values[0] = string.Empty;
}
if (_textBoxes == null || _textBoxes.Length != values.Length)
_textBoxes = new TextBox[values.Length];
for (int i = 0; i < values.Length; i++)
{
var value = values[i];
var textBox = layout.TextBox(value.IsMultiline());
textBox.TextBox.Tag = i;
textBox.TextBox.Text = value;
textBox.TextBox.TextBoxEditEnd += OnEditEnd;
_textBoxes[i] = textBox.TextBox;
}
}
public override void Refresh()
{
base.Refresh();
var values = (string[])Values[0];
if (values != null && values.Length == _textBoxes.Length)
{
_isRefreshing = true;
var style = FlaxEngine.GUI.Style.Current;
var wrongColor = new Color(1.0f, 0.0f, 0.02745f, 1.0f);
var wrongColorBorder = Color.Lerp(wrongColor, style.TextBoxBackground, 0.6f);
for (int i = 0; i < _textBoxes.Length; i++)
{
var textBox = _textBoxes[i];
if (!textBox.IsEditing)
{
textBox.Text = values[i];
if (string.IsNullOrEmpty(textBox.Text))
{
textBox.BorderColor = wrongColorBorder;
textBox.BorderSelectedColor = wrongColor;
}
else
{
textBox.BorderColor = Color.Transparent;
textBox.BorderSelectedColor = style.BackgroundSelected;
}
}
}
_isRefreshing = false;
}
}
protected override void Deinitialize()
{
base.Deinitialize();
_textBoxes = null;
_isRefreshing = false;
}
private void OnEditEnd(TextBoxBase textBox)
{
if (_isRefreshing)
return;
var values = (string[])Values[0];
var length = Mathf.Max(values?.Length ?? 0, 1);
var toSet = new string[length];
if (values != null && values.Length == length)
Array.Copy(values, toSet, length);
var index = (int)textBox.Tag;
toSet[index] = textBox.Text;
SetValue(toSet);
}
}
private class Proxy
{
[EditorOrder(0), EditorDisplay("General"), Tooltip("The locale of the localized string table (eg. pl-PL)."),]
[CustomEditor(typeof(FlaxEditor.CustomEditors.Editors.CultureInfoEditor))]
public string Locale;
[EditorOrder(10), EditorDisplay("Entries", EditorDisplayAttribute.InlineStyle), Tooltip("The string table. Maps the message id into the localized text. For plural messages the list contains separate items for value numbers.")]
[Collection(Spacing = 10, OverrideEditorTypeName = "FlaxEditor.Windows.Assets.LocalizedStringTableWindow+EntryEditor")]
public Dictionary<string, string[]> Entries;
}
/// <inheritdoc />
public LocalizedStringTableWindow(Editor editor, AssetItem item)
: base(editor, item)
{
// Undo
_undo = new Undo();
_undo.UndoDone += OnUndoRedo;
_undo.RedoDone += OnUndoRedo;
// Toolstrip
_saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save32, Save).LinkTooltip("Save");
_toolstrip.AddSeparator();
_undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo32, _undo.PerformUndo).LinkTooltip("Undo (Ctrl+Z)");
_redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo32, _undo.PerformRedo).LinkTooltip("Redo (Ctrl+Y)");
// Panel
var panel = new Panel(ScrollBars.Vertical)
{
AnchorPreset = AnchorPresets.StretchAll,
Offsets = new Margin(0, 0, _toolstrip.Bottom, 0),
Parent = this
};
// Properties
_presenter = new CustomEditorPresenter(_undo, "Loading...");
_presenter.Panel.Parent = panel;
_presenter.Modified += MarkAsEdited;
// Setup input actions
InputActions.Add(options => options.Undo, _undo.PerformUndo);
InputActions.Add(options => options.Redo, _undo.PerformRedo);
}
private void OnUndoRedo(IUndoAction action)
{
MarkAsEdited();
UpdateToolstrip();
}
/// <inheritdoc />
public override void Save()
{
if (!IsEdited)
return;
_asset.Locale = _proxy.Locale;
_asset.Entries = _proxy.Entries;
if (_asset.Save(_item.Path))
{
Editor.LogError("Cannot save asset.");
return;
}
ClearEditedFlag();
}
/// <inheritdoc />
protected override void UpdateToolstrip()
{
_saveButton.Enabled = IsEdited;
_undoButton.Enabled = _undo.CanUndo;
_redoButton.Enabled = _undo.CanRedo;
base.UpdateToolstrip();
}
/// <inheritdoc />
protected override void OnAssetLoaded()
{
_proxy = new Proxy
{
Locale = _asset.Locale,
Entries = _asset.Entries,
};
_presenter.Select(_proxy);
_undo.Clear();
ClearEditedFlag();
base.OnAssetLoaded();
}
/// <inheritdoc />
public override void OnItemReimported(ContentItem item)
{
// Refresh the properties (will get new data in OnAssetLoaded)
_presenter.Deselect();
ClearEditedFlag();
base.OnItemReimported(item);
}
}
}

View File

@@ -565,7 +565,6 @@ namespace FlaxEditor.Windows.Assets
public UVsLayoutPreviewControl()
{
Offsets = new Margin(4);
AnchorPreset = AnchorPresets.HorizontalStretchMiddle;
AutomaticInvalidate = false;
}
@@ -619,9 +618,9 @@ namespace FlaxEditor.Windows.Assets
}
/// <inheritdoc />
protected override void DrawChildren()
public override void DrawSelf()
{
base.DrawChildren();
base.DrawSelf();
var size = Size;
if (_channel == UVChannel.None || size.MaxValue < 5.0f)

View File

@@ -36,6 +36,9 @@ namespace FlaxEditor.Windows.Assets
/// <inheritdoc />
public override Undo Undo => _window.Undo;
/// <inheritdoc />
public override List<SceneGraphNode> Selection => _window.Selection;
}
/// <summary>

View File

@@ -114,9 +114,9 @@ namespace FlaxEditor.Windows.Assets
}
/// <inheritdoc />
public override void Draw()
public override void DrawSelf()
{
base.Draw();
base.DrawSelf();
var style = Style.Current;
var asset = _window.Asset;
@@ -676,7 +676,6 @@ namespace FlaxEditor.Windows.Assets
public UVsLayoutPreviewControl()
{
Offsets = new Margin(4);
AnchorPreset = AnchorPresets.HorizontalStretchMiddle;
AutomaticInvalidate = false;
}

View File

@@ -43,6 +43,7 @@ namespace FlaxEditor.Windows
{ PlatformType.PS4, new PS4() },
{ PlatformType.XboxScarlett, new XboxScarlett() },
{ PlatformType.Android, new Android() },
{ PlatformType.Switch, new Switch() },
};
public BuildTabProxy(GameCookerWindow win, PlatformSelector platformSelector)
@@ -57,6 +58,7 @@ namespace FlaxEditor.Windows
PerPlatformOptions[PlatformType.PS4].Init("Output/PS4", "PS4");
PerPlatformOptions[PlatformType.XboxScarlett].Init("Output/XboxScarlett", "XboxScarlett");
PerPlatformOptions[PlatformType.Android].Init("Output/Android", "Android");
PerPlatformOptions[PlatformType.Switch].Init("Output/Switch", "Switch");
}
public abstract class Platform
@@ -188,6 +190,11 @@ namespace FlaxEditor.Windows
protected override BuildPlatform BuildPlatform => BuildPlatform.AndroidARM64;
}
public class Switch : Platform
{
protected override BuildPlatform BuildPlatform => BuildPlatform.Switch;
}
public class Editor : CustomEditor
{
private PlatformType _platform;
@@ -229,6 +236,9 @@ namespace FlaxEditor.Windows
case PlatformType.Android:
name = "Android";
break;
case PlatformType.Switch:
name = "Switch";
break;
default:
name = CustomEditorsUtil.GetPropertyNameUI(_platform.ToString());
break;

View File

@@ -5,6 +5,29 @@ using FlaxEditor.GUI;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEngine
{
partial class ProfilerCPU
{
partial struct Event
{
/// <summary>
/// Gets the event name.
/// </summary>
public unsafe string Name
{
get
{
fixed (char* name = &Name0)
{
return new string(name);
}
}
}
}
}
}
namespace FlaxEditor.Windows.Profiler
{
/// <summary>
@@ -204,7 +227,7 @@ namespace FlaxEditor.Windows.Profiler
{
var e = events[i];
if (e.Depth == 0 && new string(e.Name) == "Update")
if (e.Depth == 0 && e.Name == "Update")
{
return new ViewRange(ref e);
}
@@ -225,7 +248,7 @@ namespace FlaxEditor.Windows.Profiler
double scale = 100.0;
float x = (float)((e.Start - startTime) * scale);
float width = (float)(length * scale);
string name = new string(e.Name).Replace("::", ".");
string name = e.Name.Replace("::", ".");
var control = new Timeline.Event(x + xOffset, e.Depth + depthOffset, width)
{
@@ -399,7 +422,7 @@ namespace FlaxEditor.Windows.Profiler
subEventsMemoryTotal += sub.ManagedMemoryAllocation + e.NativeMemoryAllocation;
}
string name = new string(e.Name).Replace("::", ".");
string name = e.Name.Replace("::", ".");
var row = new Row
{

View File

@@ -2,7 +2,9 @@
#include "SplashScreen.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/TimeSpan.h"
#include "Engine/Engine/CommandLine.h"
#include "Engine/Engine/Globals.h"
#include "Engine/Render2D/FontAsset.h"
#include "Engine/Render2D/Font.h"
#include "Engine/Render2D/TextLayoutOptions.h"
@@ -120,6 +122,17 @@ const Char* SplashScreenQuotes[] =
TEXT("All we had to do was follow the damn train, CJ"),
TEXT("28 stab wounds"),
TEXT("Here we go again"),
TEXT("@everyone"),
TEXT("uwu some spiders on the ceiling"),
TEXT("There you are you little shit"),
TEXT("potato"),
TEXT("python is a programming snek"),
TEXT("Flax will start when pigs will fly"),
TEXT("I'm the android sent by CyberLife"),
TEXT("fancy-ass ray tracing rtx on lighting"),
TEXT("ZOINKS"),
TEXT("Scooby dooby doo"),
TEXT("You shall not load"),
};
SplashScreen::~SplashScreen()