- Archetypes now fetch signature and description independently
- Added larger label for signature to description panel
This commit is contained in:
@@ -122,7 +122,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
Name = module.Title,
|
||||
Tag = module.TypeID,
|
||||
TooltipText = module.Description,
|
||||
TooltipText = $"{module.Signature}\n{module.Description}",
|
||||
});
|
||||
}
|
||||
cm.ItemClicked += item => AddModule((ushort)item.Tag);
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
private NodeArchetype _parameterGetNodeArchetype;
|
||||
private NodeArchetype _parameterSetNodeArchetype;
|
||||
private bool _useDescriptionPanel;
|
||||
private string _currentDescriptionText;
|
||||
private Panel _descriptionPanel;
|
||||
private Label _descriptionSignatureLabel;
|
||||
private Label _descriptionLabel;
|
||||
|
||||
/// <summary>
|
||||
@@ -224,7 +224,20 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
};
|
||||
_descriptionPanel = descriptionPanel;
|
||||
|
||||
var descriptionLabel = new Label(8,8,Width-16,Height-16)
|
||||
var signatureFontReference = new FontReference(Style.Current.FontLarge.Asset, 11);
|
||||
var signatureLabel = new Label(8, 8, Width - 16, Height - 16)
|
||||
{
|
||||
Parent = _descriptionPanel,
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
VerticalAlignment = TextAlignment.Near,
|
||||
Wrapping = TextWrapping.WrapWords,
|
||||
Font = signatureFontReference,
|
||||
Bold = true,
|
||||
Italic = true,
|
||||
};
|
||||
_descriptionSignatureLabel = signatureLabel;
|
||||
|
||||
var descriptionLabel = new Label(8, 40, Width - 16, Height - 16)
|
||||
{
|
||||
Parent = _descriptionPanel,
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
@@ -581,12 +594,12 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
_groups[i].Open(animate);
|
||||
}
|
||||
|
||||
public void SetDescriptionText(string text)
|
||||
public void SetDescriptionText(string header, string text)
|
||||
{
|
||||
if(!_useDescriptionPanel)
|
||||
return;
|
||||
_currentDescriptionText = text;
|
||||
_descriptionLabel.Text = _currentDescriptionText;
|
||||
_descriptionSignatureLabel.Text = header;
|
||||
_descriptionLabel.Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
Group = group;
|
||||
_groupArchetype = groupArchetype;
|
||||
_archetype = archetype;
|
||||
TooltipText = _archetype.Description;
|
||||
TooltipText = $"{_archetype.Signature}\n{_archetype.Description}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -342,7 +342,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
public override void OnMouseEnter(Float2 location)
|
||||
{
|
||||
base.OnMouseEnter(location);
|
||||
Group.ContextMenu.SetDescriptionText(_archetype.Description);
|
||||
Group.ContextMenu.SetDescriptionText(_archetype.Signature, _archetype.Description);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -134,6 +134,11 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
public string SubTitle;
|
||||
|
||||
/// <summary>
|
||||
/// Node signature for tooltip and description purposes
|
||||
/// </summary>
|
||||
public string Signature;
|
||||
|
||||
/// <summary>
|
||||
/// Short node description.
|
||||
/// </summary>
|
||||
@@ -210,6 +215,7 @@ namespace FlaxEditor.Surface
|
||||
Flags = Flags,
|
||||
Title = Title,
|
||||
SubTitle = SubTitle,
|
||||
Signature = Signature,
|
||||
Description = Description,
|
||||
AlternativeTitles = (string[])AlternativeTitles?.Clone(),
|
||||
Tag = Tag,
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace FlaxEditor.Surface
|
||||
Archetype = nodeArch;
|
||||
GroupArchetype = groupArch;
|
||||
AutoFocus = false;
|
||||
TooltipText = nodeArch.Description;
|
||||
TooltipText = TooltipText = $"{nodeArch.Signature}\n{nodeArch.Description}";
|
||||
CullChildren = false;
|
||||
BackgroundColor = Style.Current.BackgroundNormal;
|
||||
|
||||
|
||||
@@ -440,12 +440,24 @@ namespace FlaxEditor.Surface
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
internal static string GetVisualScriptMemberInfoDescription(ScriptMemberInfo member)
|
||||
internal static string GetVisualScriptMemberInfoSignature(ScriptMemberInfo member, bool appendPropertyInfo = true)
|
||||
{
|
||||
var name = member.Name;
|
||||
var declaringType = member.DeclaringType;
|
||||
var valueType = member.ValueType;
|
||||
|
||||
// Getter/setter method of the property - we can return early here
|
||||
bool isGetterOrSetter = name.StartsWith("get_") || name.StartsWith("set_");
|
||||
if (member.IsMethod && isGetterOrSetter)
|
||||
{
|
||||
var flags = member.IsStatic ? BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly : BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
||||
var property = declaringType.GetMembers(name.Substring(4), MemberTypes.Property, flags);
|
||||
if (property != null && property.Length != 0)
|
||||
{
|
||||
return GetVisualScriptMemberInfoDescription(property[0]);
|
||||
}
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
if (member.IsStatic)
|
||||
sb.Append("static ");
|
||||
@@ -456,34 +468,22 @@ namespace FlaxEditor.Surface
|
||||
sb.Append(declaringType.Name);
|
||||
sb.Append('.');
|
||||
sb.Append(name);
|
||||
if (member.IsMethod)
|
||||
|
||||
// Is a method and not a property
|
||||
if (member.IsMethod && !isGetterOrSetter)
|
||||
{
|
||||
// Getter/setter method of the property
|
||||
if (name.StartsWith("get_") || name.StartsWith("set_"))
|
||||
sb.Append('(');
|
||||
var parameters = member.GetParameters();
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
var flags = member.IsStatic ? BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly : BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
||||
var property = declaringType.GetMembers(name.Substring(4), MemberTypes.Property, flags);
|
||||
if (property != null && property.Length != 0)
|
||||
{
|
||||
return GetVisualScriptMemberInfoDescription(property[0]);
|
||||
}
|
||||
}
|
||||
// Method
|
||||
else
|
||||
{
|
||||
sb.Append('(');
|
||||
var parameters = member.GetParameters();
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
sb.Append(", ");
|
||||
ref var param = ref parameters[i];
|
||||
param.ToString(sb);
|
||||
}
|
||||
sb.Append(')');
|
||||
if (i != 0)
|
||||
sb.Append(", ");
|
||||
ref var param = ref parameters[i];
|
||||
param.ToString(sb);
|
||||
}
|
||||
sb.Append(')');
|
||||
}
|
||||
else if (member.IsProperty)
|
||||
else if (member.IsProperty && appendPropertyInfo)
|
||||
{
|
||||
sb.Append(' ');
|
||||
sb.Append('{');
|
||||
@@ -495,6 +495,19 @@ namespace FlaxEditor.Surface
|
||||
sb.Append('}');
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
internal static string GetVisualScriptMemberShortDescription(ScriptMemberInfo member)
|
||||
{
|
||||
return Editor.Instance.CodeDocs.GetTooltip(member);
|
||||
}
|
||||
|
||||
internal static string GetVisualScriptMemberInfoDescription(ScriptMemberInfo member)
|
||||
{
|
||||
var signature = GetVisualScriptMemberInfoSignature(member);
|
||||
var sb = new StringBuilder(signature);
|
||||
|
||||
// Tooltip
|
||||
var tooltip = Editor.Instance.CodeDocs.GetTooltip(member);
|
||||
if (!string.IsNullOrEmpty(tooltip))
|
||||
|
||||
@@ -370,7 +370,8 @@ namespace FlaxEditor.Surface
|
||||
node.DefaultValues[2] = parameters.Length;
|
||||
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||
node.Title = SurfaceUtils.GetMethodDisplayName((string)node.DefaultValues[1]);
|
||||
node.Description = SurfaceUtils.GetVisualScriptMemberInfoDescription(member);
|
||||
node.Signature = SurfaceUtils.GetVisualScriptMemberInfoSignature(member);
|
||||
node.Description = SurfaceUtils.GetVisualScriptMemberShortDescription(member);
|
||||
node.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||
node.Tag = member;
|
||||
|
||||
@@ -418,7 +419,8 @@ namespace FlaxEditor.Surface
|
||||
node.DefaultValues[3] = member.IsStatic;
|
||||
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||
node.Title = "Get " + name;
|
||||
node.Description = SurfaceUtils.GetVisualScriptMemberInfoDescription(member);
|
||||
node.Signature = SurfaceUtils.GetVisualScriptMemberInfoSignature(member);
|
||||
node.Description = SurfaceUtils.GetVisualScriptMemberShortDescription(member);
|
||||
node.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||
|
||||
// Create group archetype
|
||||
@@ -452,7 +454,8 @@ namespace FlaxEditor.Surface
|
||||
node.DefaultValues[3] = member.IsStatic;
|
||||
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||
node.Title = "Set " + name;
|
||||
node.Description = SurfaceUtils.GetVisualScriptMemberInfoDescription(member);
|
||||
node.Signature = SurfaceUtils.GetVisualScriptMemberInfoSignature(member);
|
||||
node.Description = SurfaceUtils.GetVisualScriptMemberShortDescription(member);
|
||||
node.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||
|
||||
// Create group archetype
|
||||
@@ -510,7 +513,8 @@ namespace FlaxEditor.Surface
|
||||
bindNode.DefaultValues[1] = name;
|
||||
bindNode.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||
bindNode.Title = "Bind " + name;
|
||||
bindNode.Description = SurfaceUtils.GetVisualScriptMemberInfoDescription(member);
|
||||
bindNode.Signature = SurfaceUtils.GetVisualScriptMemberInfoSignature(member);
|
||||
bindNode.Description = SurfaceUtils.GetVisualScriptMemberShortDescription(member);
|
||||
bindNode.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||
((IList<NodeArchetype>)group.Archetypes).Add(bindNode);
|
||||
|
||||
@@ -520,6 +524,7 @@ namespace FlaxEditor.Surface
|
||||
unbindNode.DefaultValues[1] = name;
|
||||
unbindNode.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||
unbindNode.Title = "Unbind " + name;
|
||||
unbindNode.Signature = bindNode.Signature;
|
||||
unbindNode.Description = bindNode.Description;
|
||||
unbindNode.SubTitle = bindNode.SubTitle;
|
||||
((IList<NodeArchetype>)group.Archetypes).Add(unbindNode);
|
||||
|
||||
Reference in New Issue
Block a user