Skip to content

Commit

Permalink
Combine a few functions to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mminer committed Mar 19, 2020
1 parent d0cc547 commit 9f0ecc8
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,37 +144,29 @@ void Update()

#endregion

void DrawCollapsedLog(Log log, GUIStyle logStyle, GUIStyle badgeStyle)
{
GUILayout.BeginHorizontal();

GUILayout.Label(log.GetTruncatedMessage(), logStyle);
GUILayout.FlexibleSpace();
GUILayout.Label(log.count.ToString(), GUI.skin.box);

GUILayout.EndHorizontal();
}

void DrawExpandedLog(Log log, GUIStyle logStyle)
{
for (var i = 0; i < log.count; i += 1)
{
GUILayout.Label(log.GetTruncatedMessage(), logStyle);
}
}

void DrawLog(Log log, GUIStyle logStyle, GUIStyle badgeStyle)
{
GUI.contentColor = logTypeColors[log.type];

if (isCollapsed)
{
DrawCollapsedLog(log, logStyle, badgeStyle);
// Draw collapsed log with badge indicating count.
GUILayout.BeginHorizontal();
GUILayout.Label(log.GetTruncatedMessage(), logStyle);
GUILayout.FlexibleSpace();
GUILayout.Label(log.count.ToString(), GUI.skin.box);
GUILayout.EndHorizontal();
}
else
{
DrawExpandedLog(log, logStyle);
// Draw expanded log.
for (var i = 0; i < log.count; i += 1)
{
GUILayout.Label(log.GetTruncatedMessage(), logStyle);
}
}

GUI.contentColor = Color.white;
}

void DrawLogList()
Expand Down Expand Up @@ -207,9 +199,6 @@ void DrawLogList()
{
ScrollToBottom();
}

// Ensure GUI colour is reset before drawing other components.
GUI.contentColor = Color.white;
}

void DrawToolbar()
Expand Down

0 comments on commit 9f0ecc8

Please sign in to comment.