<commit_before>using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using Fungus;

public class FungusEditorWindow : EditorWindow
{
	private List<Sequence> windowSequenceMap = new List<Sequence>();
    private Vector2 scrollPos;                         // ScrollViews use a Vector2 to track the state of each scroll bar

	private GameObject cachedSelection;

    [MenuItem("Window/Fungus Editor")]
    static void Init()
    {
        GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor");
    }

	public void OnInspectorUpdate()
	{
		Repaint();
	}

	SequenceController GetSequenceController()
	{
		GameObject activeObject = Selection.activeGameObject;

		while (activeObject != null)
		{
			SequenceController sequenceController = activeObject.GetComponent<SequenceController>();
			Sequence sequence = activeObject.GetComponent<Sequence>();

			if (sequenceController != null)
			{
				// Found sequence controller
				return sequenceController;
			}
			else if (sequence != null &&
			         sequence.transform.parent != null)
			{
				// Check parent for sequence controller
				activeObject = sequence.transform.parent.gameObject;
			}
			else
			{
				activeObject = null;
			}
		}

		return null;
	}

    void OnGUI()
    {
		SequenceController sequenceController = GetSequenceController();
		if (sequenceController == null)
		{
			return;
		}

		string labelText = sequenceController.name;
		if (Application.isPlaying)
		{
			if (sequenceController.activeSequence == null)
			{
				labelText += ": Idle";
			}
			else
			{
				labelText += ": Active";
			}
		}

		GUILayout.BeginHorizontal();
		GUILayout.FlexibleSpace();
		GUILayout.Label(labelText);
		GUILayout.Space(30);
		GUILayout.EndHorizontal();

		Sequence[] sequences = sequenceController.GetComponentsInChildren<Sequence>();

		Rect scrollViewRect = new Rect();
		foreach (Sequence s in sequences)
		{
			scrollViewRect.xMin = Mathf.Min(scrollViewRect.xMin, s.nodeRect.xMin);
			scrollViewRect.xMax = Mathf.Max(scrollViewRect.xMax, s.nodeRect.xMax);
			scrollViewRect.yMin = Mathf.Min(scrollViewRect.yMin, s.nodeRect.yMin);
			scrollViewRect.yMax = Mathf.Max(scrollViewRect.yMax, s.nodeRect.yMax);
		}
		scrollViewRect.xMin -= 10;
		scrollViewRect.yMin -= 10;

		scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos, scrollViewRect);

        // In games, GUI.Window pops up a window on your screen. In the Editor, GUI.Window shows a sub-window inside an EditorWindow.
        // All calls to GUI.Window need to be wrapped in a BeginWindows / EndWindows pair.
        // http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.BeginWindows.html
        BeginWindows();

		windowSequenceMap.Clear();
		for (int i = 0; i < sequences.Length; ++i)
		{
			Sequence sequence = sequences[i];
			sequence.nodeRect = GUI.Window(i, sequence.nodeRect, DrawWindow, sequence.name);
			windowSequenceMap.Add(sequence);
		}

		// Draw connections
		foreach (Sequence s in windowSequenceMap)
		{
			DrawConnections(s, false);
		}
		foreach (Sequence s in windowSequenceMap)
		{
			DrawConnections(s, true);
		}

        EndWindows();

        GUI.EndScrollView();
    }

    void DrawWindow(int windowId)
    {
		// Select game object when node is clicked
		if (Event.current.button == 0 && 
	    	Event.current.type == EventType.MouseUp) 
		{
			if (windowId < windowSequenceMap.Count)
			{
				Sequence s = windowSequenceMap[windowId];
				if (s != null)
				{
					Selection.activeGameObject = s.gameObject;
				}
			}
		}

		if (FungusCommandEditor.selectedCommand != null)
		{
			if (Selection.activeGameObject == null)
			{
				FungusCommandEditor.selectedCommand = null;<commit_msg>Moved Fungus Editor label to bottom<commit_after>using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using Fungus;

public class FungusEditorWindow : EditorWindow
{
	private List<Sequence> windowSequenceMap = new List<Sequence>();
    private Vector2 scrollPos;                         // ScrollViews use a Vector2 to track the state of each scroll bar

	private GameObject cachedSelection;

    [MenuItem("Window/Fungus Editor")]
    static void Init()
    {
        GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor");
    }

	public void OnInspectorUpdate()
	{
		Repaint();
	}

	SequenceController GetSequenceController()
	{
		GameObject activeObject = Selection.activeGameObject;

		while (activeObject != null)
		{
			SequenceController sequenceController = activeObject.GetComponent<SequenceController>();
			Sequence sequence = activeObject.GetComponent<Sequence>();

			if (sequenceController != null)
			{
				// Found sequence controller
				return sequenceController;
			}
			else if (sequence != null &&
			         sequence.transform.parent != null)
			{
				// Check parent for sequence controller
				activeObject = sequence.transform.parent.gameObject;
			}
			else
			{
				activeObject = null;
			}
		}

		return null;
	}

    void OnGUI()
    {
		SequenceController sequenceController = GetSequenceController();
		if (sequenceController == null)
		{
			return;
		}

		Sequence[] sequences = sequenceController.GetComponentsInChildren<Sequence>();

		Rect scrollViewRect = new Rect();
		foreach (Sequence s in sequences)
		{
			scrollViewRect.xMin = Mathf.Min(scrollViewRect.xMin, s.nodeRect.xMin);
			scrollViewRect.xMax = Mathf.Max(scrollViewRect.xMax, s.nodeRect.xMax);
			scrollViewRect.yMin = Mathf.Min(scrollViewRect.yMin, s.nodeRect.yMin);
			scrollViewRect.yMax = Mathf.Max(scrollViewRect.yMax, s.nodeRect.yMax);
		}
		scrollViewRect.xMin -= 10;
		scrollViewRect.yMin -= 10;

		scrollPos = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPos, scrollViewRect);

        // In games, GUI.Window pops up a window on your screen. In the Editor, GUI.Window shows a sub-window inside an EditorWindow.
        // All calls to GUI.Window need to be wrapped in a BeginWindows / EndWindows pair.
        // http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow.BeginWindows.html
        BeginWindows();

		windowSequenceMap.Clear();
		for (int i = 0; i < sequences.Length; ++i)
		{
			Sequence sequence = sequences[i];
			sequence.nodeRect = GUI.Window(i, sequence.nodeRect, DrawWindow, sequence.name);
			windowSequenceMap.Add(sequence);
		}

		// Draw connections
		foreach (Sequence s in windowSequenceMap)
		{
			DrawConnections(s, false);
		}
		foreach (Sequence s in windowSequenceMap)
		{
			DrawConnections(s, true);
		}

        EndWindows();

        GUI.EndScrollView();

		string labelText = sequenceController.name;
		if (Application.isPlaying)
		{
			if (sequenceController.activeSequence == null)
			{
				labelText += ": Idle";
			}
			else
			{
				labelText += ": Active";
			}
		}
		
		GUILayout.BeginVertical();
		GUILayout.FlexibleSpace();
		GUILayout.Label(labelText);
		GUILayout.EndVertical();
    }

    void DrawWindow(int windowId)
    {
		// Select game object when node is clicked
		if (Event.current.button == 0 && 
	    	Event.current.type == EventType.MouseUp) 
		{
			if (windowId < windowSequenceMap.Count)
			{
				Sequence s = windowSequenceMap[windowId];
				if (s != null)
				{
					Selection.activeGameObject = s.gameObject;
				}
			}
		}

		if (FungusCommandEditor.selectedCommand != null)
		{
			if (Selection.activeGameObject == null)
			{
				FungusCommandEditor.selectedCommand = null;
{'fraction_non_alphanumeric': 0.10575510749098678, 'fraction_numerical': 0.0032047002269995992, 'mean_word_length': 3.3648018648018647, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6634748', 'n_tokens_mistral': 2581, 'n_tokens_neox': 2193, 'n_words': 517}