- 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,
|
Name = module.Title,
|
||||||
Tag = module.TypeID,
|
Tag = module.TypeID,
|
||||||
TooltipText = module.Description,
|
TooltipText = $"{module.Signature}\n{module.Description}",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cm.ItemClicked += item => AddModule((ushort)item.Tag);
|
cm.ItemClicked += item => AddModule((ushort)item.Tag);
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
private NodeArchetype _parameterGetNodeArchetype;
|
private NodeArchetype _parameterGetNodeArchetype;
|
||||||
private NodeArchetype _parameterSetNodeArchetype;
|
private NodeArchetype _parameterSetNodeArchetype;
|
||||||
private bool _useDescriptionPanel;
|
private bool _useDescriptionPanel;
|
||||||
private string _currentDescriptionText;
|
|
||||||
private Panel _descriptionPanel;
|
private Panel _descriptionPanel;
|
||||||
|
private Label _descriptionSignatureLabel;
|
||||||
private Label _descriptionLabel;
|
private Label _descriptionLabel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -224,7 +224,20 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
};
|
};
|
||||||
_descriptionPanel = descriptionPanel;
|
_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,
|
Parent = _descriptionPanel,
|
||||||
HorizontalAlignment = TextAlignment.Near,
|
HorizontalAlignment = TextAlignment.Near,
|
||||||
@@ -581,12 +594,12 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
_groups[i].Open(animate);
|
_groups[i].Open(animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDescriptionText(string text)
|
public void SetDescriptionText(string header, string text)
|
||||||
{
|
{
|
||||||
if(!_useDescriptionPanel)
|
if(!_useDescriptionPanel)
|
||||||
return;
|
return;
|
||||||
_currentDescriptionText = text;
|
_descriptionSignatureLabel.Text = header;
|
||||||
_descriptionLabel.Text = _currentDescriptionText;
|
_descriptionLabel.Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
Group = group;
|
Group = group;
|
||||||
_groupArchetype = groupArchetype;
|
_groupArchetype = groupArchetype;
|
||||||
_archetype = archetype;
|
_archetype = archetype;
|
||||||
TooltipText = _archetype.Description;
|
TooltipText = $"{_archetype.Signature}\n{_archetype.Description}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -342,7 +342,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
|||||||
public override void OnMouseEnter(Float2 location)
|
public override void OnMouseEnter(Float2 location)
|
||||||
{
|
{
|
||||||
base.OnMouseEnter(location);
|
base.OnMouseEnter(location);
|
||||||
Group.ContextMenu.SetDescriptionText(_archetype.Description);
|
Group.ContextMenu.SetDescriptionText(_archetype.Signature, _archetype.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string SubTitle;
|
public string SubTitle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Node signature for tooltip and description purposes
|
||||||
|
/// </summary>
|
||||||
|
public string Signature;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Short node description.
|
/// Short node description.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -210,6 +215,7 @@ namespace FlaxEditor.Surface
|
|||||||
Flags = Flags,
|
Flags = Flags,
|
||||||
Title = Title,
|
Title = Title,
|
||||||
SubTitle = SubTitle,
|
SubTitle = SubTitle,
|
||||||
|
Signature = Signature,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
AlternativeTitles = (string[])AlternativeTitles?.Clone(),
|
AlternativeTitles = (string[])AlternativeTitles?.Clone(),
|
||||||
Tag = Tag,
|
Tag = Tag,
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace FlaxEditor.Surface
|
|||||||
Archetype = nodeArch;
|
Archetype = nodeArch;
|
||||||
GroupArchetype = groupArch;
|
GroupArchetype = groupArch;
|
||||||
AutoFocus = false;
|
AutoFocus = false;
|
||||||
TooltipText = nodeArch.Description;
|
TooltipText = TooltipText = $"{nodeArch.Signature}\n{nodeArch.Description}";
|
||||||
CullChildren = false;
|
CullChildren = false;
|
||||||
BackgroundColor = Style.Current.BackgroundNormal;
|
BackgroundColor = Style.Current.BackgroundNormal;
|
||||||
|
|
||||||
|
|||||||
@@ -440,12 +440,24 @@ namespace FlaxEditor.Surface
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetVisualScriptMemberInfoDescription(ScriptMemberInfo member)
|
internal static string GetVisualScriptMemberInfoSignature(ScriptMemberInfo member, bool appendPropertyInfo = true)
|
||||||
{
|
{
|
||||||
var name = member.Name;
|
var name = member.Name;
|
||||||
var declaringType = member.DeclaringType;
|
var declaringType = member.DeclaringType;
|
||||||
var valueType = member.ValueType;
|
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();
|
var sb = new StringBuilder();
|
||||||
if (member.IsStatic)
|
if (member.IsStatic)
|
||||||
sb.Append("static ");
|
sb.Append("static ");
|
||||||
@@ -456,20 +468,9 @@ namespace FlaxEditor.Surface
|
|||||||
sb.Append(declaringType.Name);
|
sb.Append(declaringType.Name);
|
||||||
sb.Append('.');
|
sb.Append('.');
|
||||||
sb.Append(name);
|
sb.Append(name);
|
||||||
if (member.IsMethod)
|
|
||||||
{
|
// Is a method and not a property
|
||||||
// Getter/setter method of the property
|
if (member.IsMethod && !isGetterOrSetter)
|
||||||
if (name.StartsWith("get_") || name.StartsWith("set_"))
|
|
||||||
{
|
|
||||||
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('(');
|
sb.Append('(');
|
||||||
var parameters = member.GetParameters();
|
var parameters = member.GetParameters();
|
||||||
@@ -482,8 +483,7 @@ namespace FlaxEditor.Surface
|
|||||||
}
|
}
|
||||||
sb.Append(')');
|
sb.Append(')');
|
||||||
}
|
}
|
||||||
}
|
else if (member.IsProperty && appendPropertyInfo)
|
||||||
else if (member.IsProperty)
|
|
||||||
{
|
{
|
||||||
sb.Append(' ');
|
sb.Append(' ');
|
||||||
sb.Append('{');
|
sb.Append('{');
|
||||||
@@ -495,6 +495,19 @@ namespace FlaxEditor.Surface
|
|||||||
sb.Append('}');
|
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
|
// Tooltip
|
||||||
var tooltip = Editor.Instance.CodeDocs.GetTooltip(member);
|
var tooltip = Editor.Instance.CodeDocs.GetTooltip(member);
|
||||||
if (!string.IsNullOrEmpty(tooltip))
|
if (!string.IsNullOrEmpty(tooltip))
|
||||||
|
|||||||
@@ -370,7 +370,8 @@ namespace FlaxEditor.Surface
|
|||||||
node.DefaultValues[2] = parameters.Length;
|
node.DefaultValues[2] = parameters.Length;
|
||||||
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||||
node.Title = SurfaceUtils.GetMethodDisplayName((string)node.DefaultValues[1]);
|
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.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||||
node.Tag = member;
|
node.Tag = member;
|
||||||
|
|
||||||
@@ -418,7 +419,8 @@ namespace FlaxEditor.Surface
|
|||||||
node.DefaultValues[3] = member.IsStatic;
|
node.DefaultValues[3] = member.IsStatic;
|
||||||
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||||
node.Title = "Get " + name;
|
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);
|
node.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||||
|
|
||||||
// Create group archetype
|
// Create group archetype
|
||||||
@@ -452,7 +454,8 @@ namespace FlaxEditor.Surface
|
|||||||
node.DefaultValues[3] = member.IsStatic;
|
node.DefaultValues[3] = member.IsStatic;
|
||||||
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
node.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||||
node.Title = "Set " + name;
|
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);
|
node.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||||
|
|
||||||
// Create group archetype
|
// Create group archetype
|
||||||
@@ -510,7 +513,8 @@ namespace FlaxEditor.Surface
|
|||||||
bindNode.DefaultValues[1] = name;
|
bindNode.DefaultValues[1] = name;
|
||||||
bindNode.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
bindNode.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||||
bindNode.Title = "Bind " + name;
|
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);
|
bindNode.SubTitle = string.Format(" (in {0})", scriptTypeName);
|
||||||
((IList<NodeArchetype>)group.Archetypes).Add(bindNode);
|
((IList<NodeArchetype>)group.Archetypes).Add(bindNode);
|
||||||
|
|
||||||
@@ -520,6 +524,7 @@ namespace FlaxEditor.Surface
|
|||||||
unbindNode.DefaultValues[1] = name;
|
unbindNode.DefaultValues[1] = name;
|
||||||
unbindNode.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
unbindNode.Flags &= ~NodeFlags.NoSpawnViaGUI;
|
||||||
unbindNode.Title = "Unbind " + name;
|
unbindNode.Title = "Unbind " + name;
|
||||||
|
unbindNode.Signature = bindNode.Signature;
|
||||||
unbindNode.Description = bindNode.Description;
|
unbindNode.Description = bindNode.Description;
|
||||||
unbindNode.SubTitle = bindNode.SubTitle;
|
unbindNode.SubTitle = bindNode.SubTitle;
|
||||||
((IList<NodeArchetype>)group.Archetypes).Add(unbindNode);
|
((IList<NodeArchetype>)group.Archetypes).Add(unbindNode);
|
||||||
|
|||||||
Reference in New Issue
Block a user