using Facepunch.ActionGraphs; using Sandbox.Internal; namespace Sandbox.Internal { /// /// Provides a title or a "nice name" for DisplayInfo of a member or a type. /// public interface ITitleProvider { /// /// The title. /// public string Value { get; } } /// /// Provides placeholder text for DisplayInfo of a member or a type. /// public interface IPlaceholderProvider { /// /// The placeholder text. /// public string Value { get; } } /// /// Provides a description for DisplayInfo of a member or a type. /// public interface IDescriptionProvider { /// /// The description. /// public string Value { get; } } /// /// Provides category or group for DisplayInfo of a member or a type. /// public interface ICategoryProvider { /// /// The category. /// public string Value { get; } } /// /// Provides internal class name for DisplayInfo of a member or a type. /// public interface IClassNameProvider { /// /// The class name. /// Typically a class name is all lower case, has spaces replaced by underscores (_) or dashes (-) and contains no other special symbols. /// public string Value { get; } } /// /// Provides an icon for DisplayInfo of a member or a type. /// public interface IIconProvider { /// /// The icon. Typically this is the name of a material icon. /// public string Value { get; } } /// /// Provides an order number for DisplayInfo of a member or a type. /// public interface IOrderProvider { /// /// Order value, for sorting in menus. /// public int Value { get; } } /// /// Automatically added to codegenerated classes to let them determine their location /// This helps when looking for resources relative to them, like style sheets. /// Replaced in Sept 2023 by SourceLocationAttribute, which is added to classes and members. /// [AttributeUsage( AttributeTargets.Class, AllowMultiple = true, Inherited = false )] public class ClassFileLocationAttribute : System.Attribute { public string Path { get; set; } public ClassFileLocationAttribute( string value ) { Path = value; } } public interface ISourcePathProvider { string Path { get; } } public interface ISourceLineProvider : ISourcePathProvider { int Line { get; } } public interface ISourceColumnProvider : ISourceLineProvider { int Column { get; } } public interface IMemberNameProvider : ISourcePathProvider { string MemberName { get; } } /// /// Automatically added to classes and their members to let them determine their location /// This helps when looking for resources relative to them, like style sheets. /// [AttributeUsage( AttributeTargets.All, AllowMultiple = true, Inherited = false )] public class SourceLocationAttribute : ClassFileLocationAttribute, ISourceLineProvider { public int Line { get; set; } public SourceLocationAttribute( string path, int line ) : base( path ) { Line = line; } } /// /// Automatically added to classes that implement OnUpdate() /// public interface IUpdateSubscriber { } /// /// Automatically added to classes that implement OnFixedUpdate() /// public interface IFixedUpdateSubscriber { } /// /// Automatically added to classes that implement OnPreRender() /// public interface IPreRenderSubscriber { } } /// /// Add placeholder text, typically displayed for string properties when the text entry field is empty. /// This info can then be retrieved via DisplayInfo library. /// public class PlaceholderAttribute : System.Attribute, IPlaceholderProvider, IUninheritable { /// public string Value { get; set; } string IPlaceholderProvider.Value => Value; public PlaceholderAttribute( string value ) { Value = value; } } /// /// Set the class name for this type or member. /// This info can then be retrieved via DisplayInfo library. /// public class ClassNameAttribute : System.Attribute, IClassNameProvider, IUninheritable { /// public string Value { get; set; } string IClassNameProvider.Value => Value; public ClassNameAttribute( string value ) { Value = value; } } /// /// Sets the title or a "nice name" of a type or a type member. /// This info can then be retrieved via DisplayInfo library. /// public class TitleAttribute : System.Attribute, ITitleProvider, ITitleAttribute, IUninheritable { /// public string Value { get; set; } string ITitleProvider.Value => Value; public TitleAttribute( string value ) { Value = value; } } /// /// Sets the description of a type or a type member. This attribute is usually applied automatically by codegen based on the XML comment of the type or member. /// This info can then be retrieved via DisplayInfo library. /// [AttributeUsage( AttributeTargets.All, AllowMultiple = true )] public class DescriptionAttribute : System.Attribute, IDescriptionProvider, IDescriptionAttribute, IUninheritable { /// public string Value { get; set; } string IDescriptionProvider.Value => Value; public DescriptionAttribute( string value ) { Value = value; } } /// /// Sets the category or the group of a type or a type member. /// This info can then be retrieved via DisplayInfo library. /// public class CategoryAttribute : System.Attribute, ICategoryProvider, IGroupAttribute, IUninheritable { /// public string Value { get; set; } string ICategoryProvider.Value => Value; public CategoryAttribute( string value ) { Value = value; } } /// /// Sets the category or the group of a type or a type member. /// This info can then be retrieved via DisplayInfo library. /// public class GroupAttribute : System.Attribute, ICategoryProvider, IGroupAttribute, IUninheritable { /// public string Value { get; set; } public string Icon { get; set; } /// /// If true then the group should start closed /// public bool StartFolded { get; set; } string ICategoryProvider.Value => Value; public GroupAttribute( string value ) { Value = value; } } /// /// Very much like a GroupAttribute, except we're indicating that the group can be toggle on and off using the named property /// public class ToggleGroupAttribute : GroupAttribute { public string Label { get; set; } public ToggleGroupAttribute( string value ) : base( value ) { } } /// /// Sets the icon of a type or a type member. Colors are expected in HTML formats, like "rgb(255,255,255)" or "#FFFFFF". /// This info can then be retrieved via DisplayInfo library. /// public sealed class IconAttribute : System.Attribute, IIconProvider, IIconAttribute, IUninheritable { /// public string Value { get; set; } string IIconProvider.Value => Value; /// /// The preferred background color for the icon. /// public Color? BackgroundColor { get; private set; } /// /// The preferred color of the icon itself. /// public Color? ForegroundColor { get; private set; } public IconAttribute( string icon, string bgColor, string fgColor ) { Value = icon; BackgroundColor = bgColor; ForegroundColor = fgColor; } public IconAttribute( string icon ) { Value = icon; } } /// /// Visual order of this member for UI purposes. /// This info can then be retrieved via DisplayInfo library. /// public sealed class OrderAttribute : System.Attribute { /// /// The visual order. /// public int Value { get; set; } public OrderAttribute( int value ) { Value = value; } } namespace Sandbox { /// /// Expand the value editor to fill the next line in the inspector, leaving the title above it /// public sealed class WideModeAttribute : System.Attribute { public bool HasLabel { get; set; } = true; } /// /// Display this in the inspector - but don't let anyone edit it /// public sealed class ReadOnlyAttribute : System.Attribute { } /// /// When applied to a string property, show a multi-line text box instead of a single line. /// public sealed class TextAreaAttribute : System.Attribute { } /// /// When applied to a string property, use an input action selector. /// public sealed class InputActionAttribute : System.Attribute { } /// /// When applied to a Type property, allows you to specify a Type that the property's value must derive from. /// public sealed class TargetTypeAttribute : System.Attribute { /// /// The type that the property's value must derive from. /// public Type Type { get; set; } public TargetTypeAttribute( Type type ) { Type = type; } } /// /// When applied to a string property, uses a font name selector. /// [AttributeUsage( AttributeTargets.Property | AttributeTargets.Field )] public sealed class FontNameAttribute : System.Attribute { } /// /// When applied to a string property, uses a Material Icon selector. /// [AttributeUsage( AttributeTargets.Property | AttributeTargets.Field )] public sealed class IconNameAttribute : System.Attribute { } /// /// When applied to a Color property, allows you to specify whether the color should have an alpha channel and/or be in HDR. /// [AttributeUsage( AttributeTargets.Property | AttributeTargets.Field )] public sealed class ColorUsageAttribute : System.Attribute { public bool HasAlpha { get; set; } = true; public bool IsHDR { get; set; } = true; public ColorUsageAttribute( bool hasAlpha = true, bool isHDR = true ) { HasAlpha = hasAlpha; IsHDR = isHDR; } } /// /// Sets the category or the group of a type or a type member. /// This info can then be retrieved via DisplayInfo library. /// public class FeatureAttribute : System.Attribute, IUninheritable { /// /// How we will group features together /// public string Identifier { get; set; } /// /// Title of the feature. Keep it short please! /// public string Title { get; set; } /// /// The description of the feature /// public string Description { get; set; } /// /// Icon to show next to the feature /// public string Icon { get; set; } /// /// The color of the feature button. Helps group things, helps things to stand out. Defaults to white. /// public EditorTint Tint { get; set; } public FeatureAttribute( string value ) { Identifier = value; Title = value; } } public class TintAttribute : System.Attribute { public EditorTint Tint; public TintAttribute( EditorTint tint ) { Tint = tint; } } public enum EditorTint { White, Pink, Green, Yellow, Blue, Red } /// /// Mark a boolean property as a feature toggle /// public class FeatureEnabledAttribute : FeatureAttribute, IUninheritable { public FeatureEnabledAttribute( string value ) : base( value ) { } } /// /// Add a header above this property /// [AttributeUsage( AttributeTargets.Property )] public sealed class HeaderAttribute : System.Attribute { public string Title { get; set; } public HeaderAttribute( string header ) { Title = header; } } /// /// Add a space above this property /// [AttributeUsage( AttributeTargets.Property )] public sealed class SpaceAttribute : System.Attribute { public float Height { get; set; } = 22; public SpaceAttribute( float height = 22 ) { Height = height; } } /// /// Add a link to some documentation for this component, or /// [AttributeUsage( AttributeTargets.Property | AttributeTargets.Class )] public sealed class HelpUrlAttribute : System.Attribute { public string Url { get; set; } public HelpUrlAttribute( string url ) { Url = url; } } /// /// Draw a box with information above this property /// public sealed class InfoBoxAttribute : System.Attribute, IUninheritable { /// /// Message to display /// public string Message { get; set; } /// /// The icon to show (material icons) /// public string Icon { get; set; } /// /// The color of this info box. Helps group things, helps things to stand out. Defaults to blue. /// public EditorTint Tint { get; set; } = EditorTint.Blue; public InfoBoxAttribute( string message, string icon = "info", EditorTint tint = EditorTint.Blue ) { Message = message; Icon = icon; Tint = tint; } } /// /// When applied to a Vector property, provides normal selection tools. /// [AttributeUsage( AttributeTargets.Property | AttributeTargets.Field )] public sealed class NormalAttribute : System.Attribute { } }