mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ScriptCore: Added LabelAttribute
This commit is contained in:
@@ -852,7 +852,18 @@ internal class EntityEditor
|
|||||||
|
|
||||||
IEnumerable<Attribute> attributes = field.GetCustomAttributes();
|
IEnumerable<Attribute> attributes = field.GetCustomAttributes();
|
||||||
|
|
||||||
string prettyName = field.Name.ToPrettyName();
|
LabelAttribute? label = GetAttribute<LabelAttribute>(attributes);
|
||||||
|
|
||||||
|
string prettyName;
|
||||||
|
|
||||||
|
if (label != null)
|
||||||
|
{
|
||||||
|
prettyName = label.Label ?? field.Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prettyName = field.Name.ToPrettyName();
|
||||||
|
}
|
||||||
|
|
||||||
object? newValue = ShowFieldEditor(value, value?.GetType() ?? field.FieldType, prettyName, attributes);
|
object? newValue = ShowFieldEditor(value, value?.GetType() ?? field.FieldType, prettyName, attributes);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GlitchyEngine.Editor;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies a string that will be shown as the label of the field in the editor.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Field)]
|
||||||
|
public sealed class LabelAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The label of the field. If <see langword="null"/>, the actual field name will be shown instead of the "prettified" name that is shown for fields without the <see cref="LabelAttribute"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string? Label { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RangeAttribute"/> with a minimum, maximum value and optionally a speed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="label"><inheritdoc cref="Label"/></param>
|
||||||
|
public LabelAttribute(string? label)
|
||||||
|
{
|
||||||
|
Label = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user