From 252d306d5b812d315f0db2e39b24374025b22d94 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 13 May 2015 17:18:50 +0100 Subject: [PATCH] Improved readability of Event Handler block info --- .../Flowchart/Editor/FlowchartWindow.cs | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs index 2e210f83..e0ef14fb 100755 --- a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs @@ -313,6 +313,34 @@ namespace Fungus 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 if (Application.isPlaying) { @@ -556,35 +584,9 @@ namespace Fungus GUI.backgroundColor = Color.white; 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) { - GUIStyle descriptionStyle = new GUIStyle(EditorStyles.whiteLabel); + GUIStyle descriptionStyle = new GUIStyle(EditorStyles.helpBox); descriptionStyle.wordWrap = true; GUILayout.Label(block.description, descriptionStyle); }