Browse Source

Improved readability of Event Handler block info

master
chrisgregan 10 years ago
parent
commit
252d306d5b
  1. 56
      Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

56
Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

@ -313,6 +313,34 @@ namespace Fungus
EndWindows(); EndWindows();
// Draw Event Handler labels
foreach (Block block in blocks)
{
if (block.eventHandler != null)
{
string handlerLabel = "";
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType());
if (info != null)
{
handlerLabel = "<" + info.EventHandlerName + "> ";
}
GUIStyle handlerStyle = new GUIStyle(EditorStyles.whiteLabel);
handlerStyle.wordWrap = true;
handlerStyle.margin.top = 0;
handlerStyle.margin.bottom = 0;
handlerStyle.alignment = TextAnchor.MiddleCenter;
Rect rect = new Rect(block.nodeRect);
rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block.nodeRect.width);
rect.x += flowchart.scrollPos.x;
rect.y += flowchart.scrollPos.y - rect.height;
GUI.Label(rect, handlerLabel, handlerStyle);
}
}
// Draw play icons beside all executing blocks // Draw play icons beside all executing blocks
if (Application.isPlaying) if (Application.isPlaying)
{ {
@ -556,35 +584,9 @@ namespace Fungus
GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.white;
GUILayout.Box(block.blockName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height)); GUILayout.Box(block.blockName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height));
if (block.eventHandler != null)
{
string handlerLabel = "";
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType());
if (info != null)
{
handlerLabel = "<" + info.EventHandlerName + "> ";
}
string handlerSummary = block.eventHandler.GetSummary();
if (handlerSummary.Length > 0)
{
handlerLabel += handlerSummary;
}
GUIStyle handlerStyle = new GUIStyle(EditorStyles.helpBox);
handlerStyle.wordWrap = true;
handlerStyle.margin.top = 0;
handlerStyle.margin.bottom = 0;
GUILayout.Label(handlerLabel, handlerStyle);
// Move connection marker down below handler description
float height = 44 + handlerStyle.CalcHeight(new GUIContent(handlerLabel), block.nodeRect.width);
block.nodeRect.height = height;
}
if (block.description.Length > 0) if (block.description.Length > 0)
{ {
GUIStyle descriptionStyle = new GUIStyle(EditorStyles.whiteLabel); GUIStyle descriptionStyle = new GUIStyle(EditorStyles.helpBox);
descriptionStyle.wordWrap = true; descriptionStyle.wordWrap = true;
GUILayout.Label(block.description, descriptionStyle); GUILayout.Label(block.description, descriptionStyle);
} }

Loading…
Cancel
Save