You're breathtaking!

This commit is contained in:
Wojtek Figat
2020-12-07 23:40:54 +01:00
commit 6fb9eee74c
5143 changed files with 1153594 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Specifies a options for an asset reference picker in the editor. Allows to customize view or provide custom value assign policy.
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class AssetReferenceAttribute : Attribute
{
/// <summary>
/// The full name of the asset type to link. Use null or empty to skip it.
/// </summary>
public string TypeName;
/// <summary>
/// True if use asset picker with a smaller height (single line), otherwise will use with full icon.
/// </summary>
public bool UseSmallPicker;
/// <summary>
/// Initializes a new instance of the <see cref="AssetReferenceAttribute"/> class.
/// </summary>
/// <param name="useSmallPicker">True if use asset picker with a smaller height (single line), otherwise will use with full icon.</param>
public AssetReferenceAttribute(bool useSmallPicker)
{
TypeName = null;
UseSmallPicker = useSmallPicker;
}
/// <summary>
/// Initializes a new instance of the <see cref="AssetReferenceAttribute"/> class.
/// </summary>
/// <param name="typeName">The full name of the asset type to link. Use null or empty to skip it.</param>
/// <param name="useSmallPicker">True if use asset picker with a smaller height (single line), otherwise will use with full icon.</param>
public AssetReferenceAttribute(Type typeName = null, bool useSmallPicker = false)
{
TypeName = typeName?.FullName;
UseSmallPicker = useSmallPicker;
}
/// <summary>
/// Initializes a new instance of the <see cref="AssetReferenceAttribute"/> class.
/// </summary>
/// <param name="typeName">The full name of the asset type to link. Use null or empty to skip it.</param>
/// <param name="useSmallPicker">True if use asset picker with a smaller height (single line), otherwise will use with full icon.</param>
public AssetReferenceAttribute(string typeName = null, bool useSmallPicker = false)
{
TypeName = typeName;
UseSmallPicker = useSmallPicker;
}
}
}

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Overrides default editor provided for the target object/class/field/property. Allows to extend visuals and editing experience of the objects.
/// </summary>
/// <seealso cref="CustomEditorAttribute"/>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Event | AttributeTargets.Method)]
public sealed class CustomEditorAliasAttribute : Attribute
{
/// <summary>
/// Custom editor class typename.
/// </summary>
public readonly string TypeName;
/// <summary>
/// Overrides default editor provided for the target object.
/// </summary>
/// <param name="typeName">The custom editor class typename.</param>
public CustomEditorAliasAttribute(string typeName)
{
TypeName = typeName;
}
}
}

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Overrides the default editor provided for the target object/class/field/property. Allows to extend visuals and editing experience of the object.
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Event | AttributeTargets.Method)]
public sealed class CustomEditorAttribute : Attribute
{
/// <summary>
/// Custom editor class type.
/// Note: if attribute is used on CustomEditor class it specifies object type to edit.
/// </summary>
public readonly Type Type;
/// <summary>
/// Overrides default editor provided for the target object.
/// </summary>
/// <param name="type">The custom editor class type.</param>
public CustomEditorAttribute(Type type)
{
Type = type;
}
}
}

View File

@@ -0,0 +1,15 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Specifies default editor provided for the target object/class/field/property. Should be used along with <see cref="FlaxEngine.CustomEditorAttribute"/>.
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Event | AttributeTargets.Method)]
public sealed class DefaultEditorAttribute : Attribute
{
}
}

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Allows to change item display name or a group in the editor.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Event | AttributeTargets.Method)]
public sealed class EditorDisplayAttribute : Attribute
{
/// <summary>
/// Special text sequence used for property names to override the default layout style and inline property into the parent layout.
/// </summary>
public const string InlineStyle = "__inline__";
/// <summary>
/// The group name. Default is null.
/// </summary>
public string Group;
/// <summary>
/// The overriden item display name. Default is null.
/// </summary>
public string Name;
private EditorDisplayAttribute()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="EditorDisplayAttribute"/> class.
/// </summary>
/// <param name="group">The group name.</param>
/// <param name="name">The display name. Use special name `__inline__` (see <see cref="InlineStyle"/>) to inline property into the parent container.</param>
public EditorDisplayAttribute(string group = null, string name = null)
{
Group = group;
Name = name;
}
}
}

View File

@@ -0,0 +1,36 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Allows to declare order of the item in the editor.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Event | AttributeTargets.Method)]
public sealed class EditorOrderAttribute : Attribute
{
/// <summary>
/// Requested order to perform layout on. Used to order the items.
/// </summary>
public int Order;
private EditorOrderAttribute()
{
}
/// <summary>
/// Override display order in visual tree for provided model.
/// </summary>
/// <remarks>
/// Current order is resolved runtime, and can change if custom editor class has changed.
/// </remarks>
/// <param name="order">The order order.</param>
public EditorOrderAttribute(int order)
{
Order = order;
}
}
}

View File

@@ -0,0 +1,44 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Allows to change enum type field or property display mode in the editor.
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class EnumDisplayAttribute : Attribute
{
/// <summary>
/// Enumeration items names formatting modes.
/// </summary>
public enum FormatMode
{
/// <summary>
/// The default formatting. Performs standard name processing to create more human-readable label for User Interface.
/// </summary>
Default = 0,
/// <summary>
/// The none formatting. The enum items names won't be modified.
/// </summary>
None = 1,
}
/// <summary>
/// The formatting mode.
/// </summary>
public FormatMode Mode;
/// <summary>
/// Initializes a new instance of the <see cref="EnumDisplayAttribute"/> class.
/// </summary>
/// <param name="mode">The formatting mode.</param>
public EnumDisplayAttribute(FormatMode mode)
{
Mode = mode;
}
}
}

View File

@@ -0,0 +1,15 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Marks the item to be visible in editor by expanding all the container groups in the upper hierarchy.
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Delegate | AttributeTargets.Event | AttributeTargets.Method)]
public sealed class ExpandGroupsAttribute : Attribute
{
}
}

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Inserts a header control with a custom text into the editor layout.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class HeaderAttribute : Attribute
{
/// <summary>
/// The header text.
/// </summary>
public string Text;
private HeaderAttribute()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="HeaderAttribute"/> class.
/// </summary>
/// <param name="text">The header text.</param>
public HeaderAttribute(string text)
{
Text = text;
}
}
}

View File

@@ -0,0 +1,20 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Makes a variable not show up in the editor.
/// </summary>
[Serializable]
public sealed class HideInEditorAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="HideInEditorAttribute"/> class.
/// </summary>
public HideInEditorAttribute()
{
}
}
}

View File

@@ -0,0 +1,50 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Used to make a float or int variable in a script be restricted to a specific range.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class LimitAttribute : Attribute
{
/// <summary>
/// The minimum range value.
/// </summary>
public float Min;
/// <summary>
/// The maximum range value.
/// </summary>
public float Max;
/// <summary>
/// The slider speed used to edit value.
/// </summary>
public float SliderSpeed;
private LimitAttribute()
{
Min = 0.0f;
Max = 100.0f;
SliderSpeed = 1.0f;
}
/// <summary>
/// Initializes a new instance of the <see cref="LimitAttribute"/> class.
/// </summary>
/// <param name="min">The minimum limit value.</param>
/// <param name="max">The maximum limit value.</param>
/// <param name="sliderSpeed">The slider speed.</param>
public LimitAttribute(float min, float max = float.MaxValue, float sliderSpeed = 1.0f)
{
Min = min;
Max = max;
SliderSpeed = sliderSpeed;
}
}
}

View File

@@ -0,0 +1,15 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Instructs UI editor to use multiline textbox for editing <see cref="String"/> property or field.
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class MultilineTextAttribute : Attribute
{
}
}

View File

@@ -0,0 +1,43 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Used to make a float or int variable in a script be restricted to a specific range.
/// When used, the float or int will be shown as a slider in the editor instead of default number field.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class RangeAttribute : Attribute
{
/// <summary>
/// The minimum range value.
/// </summary>
public float Min;
/// <summary>
/// The maximum range value.
/// </summary>
public float Max;
private RangeAttribute()
{
Min = 0.0f;
Max = 1.0f;
}
/// <summary>
/// Initializes a new instance of the <see cref="RangeAttribute"/> class.
/// </summary>
/// <param name="min">The minimum range value.</param>
/// <param name="max">The maximum range value.</param>
public RangeAttribute(float min, float max)
{
Min = min;
Max = max;
}
}
}

View File

@@ -0,0 +1,13 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Makes a variable show up in the editor as read-only (editing is disabled).
/// </summary>
public sealed class ReadOnlyAttribute : Attribute
{
}
}

View File

@@ -0,0 +1,16 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Makes a variable show up in the editor.
/// </summary>
/// <remarks>
/// If used on a private field/property you may also need to add <see cref="SerializeAttribute"/> to ensure that modified value is being serialized.
/// </remarks>
public sealed class ShowInEditorAttribute : Attribute
{
}
}

View File

@@ -0,0 +1,34 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Inserts an empty space between controls in the editor.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class SpaceAttribute : Attribute
{
/// <summary>
/// The spacing in pixel (vertically).
/// </summary>
public float Height;
private SpaceAttribute()
{
Height = 10.0f;
}
/// <summary>
/// Initializes a new instance of the <see cref="SpaceAttribute"/> class.
/// </summary>
/// <param name="height">The spacing.</param>
public SpaceAttribute(float height)
{
Height = height;
}
}
}

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Specifies a tooltip for a property/field in the editor.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.All)]
public sealed class TooltipAttribute : Attribute
{
/// <summary>
/// The tooltip text.
/// </summary>
public string Text;
private TooltipAttribute()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TooltipAttribute"/> class.
/// </summary>
/// <param name="text">The tooltip text.</param>
public TooltipAttribute(string text)
{
Text = text;
}
}
}

View File

@@ -0,0 +1,46 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Specifies a options for an type reference picker in the editor. Allows to customize view or provide custom value assign policy (eg/ restrict types to inherit from a given type).
/// </summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter)]
public class TypeReferenceAttribute : Attribute
{
/// <summary>
/// The full name of the type to link (includes types inheriting from it). Use null or empty to skip it.
/// </summary>
public string TypeName;
/// <summary>
/// The name of the function (static or member) to invoke to check if the given type is valid to assign. Function must return boolean value and have one argument of type SystemType. Use null or empty to skip it.
/// </summary>
public string CheckMethod;
/// <summary>
/// Initializes a new instance of the <see cref="TypeReferenceAttribute"/> class.
/// </summary>
/// <param name="typeName">The full name of the type to link (includes types inheriting from it). Use null or empty to skip it.</param>
/// <param name="checkMethod"> The name of the function (static or member) to invoke to check if the given type is valid to assign. Function must return boolean value and have one argument of type SystemType. Use null or empty to skip it.</param>
public TypeReferenceAttribute(Type typeName, string checkMethod = null)
{
TypeName = typeName.FullName;
CheckMethod = checkMethod;
}
/// <summary>
/// Initializes a new instance of the <see cref="TypeReferenceAttribute"/> class.
/// </summary>
/// <param name="typeName">The full name of the type to link (includes types inheriting from it). Use null or empty to skip it.</param>
/// <param name="checkMethod"> The name of the function (static or member) to invoke to check if the given type is valid to assign. Function must return boolean value and have one argument of type SystemType. Use null or empty to skip it.</param>
public TypeReferenceAttribute(string typeName = null, string checkMethod = null)
{
TypeName = typeName;
CheckMethod = checkMethod;
}
}
}

View File

@@ -0,0 +1,40 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Shows property/field in the editor only if the specified member has a given value. Can be used to hide properties based on other properties (also private properties). The given member has to be bool type.
/// </summary>
/// <seealso cref="System.Attribute" />
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class VisibleIfAttribute : Attribute
{
/// <summary>
/// The member name.
/// </summary>
public string MemberName;
/// <summary>
/// True if invert member value when computing the visibility value.
/// </summary>
public bool Invert;
private VisibleIfAttribute()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="HeaderAttribute"/> class.
/// </summary>
/// <param name="memberName">The name of the field or property of the object. Must be a bool type.</param>
/// <param name="invert">True if invert member value when computing the visibility value.</param>
public VisibleIfAttribute(string memberName, bool invert = false)
{
MemberName = memberName;
Invert = invert;
}
}
}