Example #1
0
        public static T ShowWindow <T>(Type type, string name, DockNextTo dockNextTo = DockNextTo.Default, string tooltip = "Swat Window") where T : EditorWindow
        {
            /*
             * Close any existing windows, as window instance may exist in Editor, but not be accessible.
             * If we do not close that invalid instance, the GetWindow method below will return the
             * broken instance. The broken window will be inaccessible and will freeze remaining GUI windows.
             */

            GetWindow(type, false, name).Close();

            Assembly   editorAssembly = typeof(Editor).Assembly;
            Type       dockWindow     = null;
            DockNextTo dockThis;

            if (dockNextTo != DockNextTo.Default)
            {
                dockThis = dockNextTo;
            }
            else
            {
                dockThis = DockNextTo;                 //Will retrieve the default Dock position from on Trilleon Settings.
            }

            switch (dockThis)
            {
            case DockNextTo.Float:
                dockWindow = null;
                break;

            case global::DockNextTo.SceneView:
                dockWindow = typeof(SceneView);
                break;

            case global::DockNextTo.GameView:
                dockWindow = editorAssembly.GetType("UnityEditor.GameView");
                break;

            case global::DockNextTo.Hierarchy:
                dockWindow = editorAssembly.GetType("UnityEditor.SceneHierarchyWindow");
                break;

            case global::DockNextTo.Console:
                dockWindow = editorAssembly.GetType("UnityEditor.ConsoleWindow");
                break;

            case global::DockNextTo.Inspector:
            default:
                dockWindow = editorAssembly.GetType("UnityEditor.InspectorWindow");
                break;
            }

            EditorWindow win = EditorWindow.GetWindow <T>(name, true, dockWindow);

            win.minSize      = new Vector2(350, 350);
            win.titleContent = new GUIContent(name, tooltip);
            return((T)win);
        }
Example #2
0
        public static void SetTabPreferences()
        {
            lastPassDock    = dock = Swat.DockNextTo;
            _tabPreferences = new List <KeyValuePair <string, string> >();

            for (int w = 0; w < Nexus.Self.SwatWindows.Count; w++)
            {
                TabDetails match = Nexus.Self.SwatWindows.Find(x => x.PriorityID == w + 1);
                if (match == null)
                {
                    continue;
                }
                string windowName = match.Window.GetType().Name;
                //If no data exists for this window, add it to the end of existing ranked windows.
                if (!_tabPreferences.FindAll(x => x.Key == windowName).Any())
                {
                    _tabPreferences.Add(new KeyValuePair <string, string>(windowName, match.Get(TabSize.Small).TabText));
                }
            }
        }
Example #3
0
        public override void Render()
        {
            description                  = new GUIStyle(GUI.skin.label);
            description.fontSize         = 12;
            description.wordWrap         = true;
            description.margin           = new RectOffset(10, 10, 0, 0);
            description.normal.textColor = Swat.WindowDefaultTextColor;

            dropDownLabel                  = new GUIStyle(GUI.skin.label);
            dropDownLabel.fontSize         = 12;
            dropDownLabel.padding          = new RectOffset(10, 0, -5, 0);
            dropDownLabel.normal.textColor = Swat.WindowDefaultTextColor;

            editorName                  = new GUIStyle(GUI.skin.label);
            editorName.fontSize         = 16;
            editorName.fixedHeight      = 20;
            editorName.fontStyle        = FontStyle.Bold;
            editorName.padding          = new RectOffset(8, 0, 0, 0);
            editorName.normal.textColor = Swat.WindowDefaultTextColor;

            open                   = new GUIStyle(GUI.skin.button);
            open.fontSize          = 14;
            open.fixedHeight       = 32;
            open.fixedWidth        = 100;
            open.margin            = new RectOffset(10, 10, 0, 0);
            open.normal.textColor  = Swat.WindowDefaultTextColor;
            open.normal.background = open.active.background = open.focused.background = Swat.ToggleButtonBackgroundSelectedTexture;

            GUILayout.Space(25);

            EditorGUILayout.LabelField("Assistant", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField("This window watches inspected elements in the hierarchy window and displays automation-relevant details on this object. With the presented information," +
                                       "you may choose actions to perform on the object and generate code stubs for interacting with that object.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                Nexus.Self.SelectTab(Nexus.Self.Generator);
                Nexus.Self.Generator.SelectedSubTab = GeneratorSubTab.Assistant;
            }
            GUILayout.Space(18);

            EditorGUILayout.LabelField("Buddy Details", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField("This window allows customization of Buddy System data for editor-based test runs.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                Nexus.Self.SelectTab(Nexus.Self.BuddyData);
            }
            GUILayout.Space(18);

            EditorGUILayout.LabelField("Command Console", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField("This window displays all of the console/cheat commands registered in the code. From here, the aliases, arguments, and details of each command are displayed." +
                                       "Commands can be launched with optional arguments from this window.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                Nexus.Self.SelectTab(Nexus.Self.CommandConsoleView);
            }
            GUILayout.Space(18);

            EditorGUILayout.LabelField("Dependency Architecture", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField(@"This window displays the Dependency Class and Dependency Test attribute usage within the all existing tests.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                Nexus.Self.SelectTab(Nexus.Self.Architect);
            }
            GUILayout.Space(18);

            EditorGUILayout.LabelField("Dependency Web", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField(@"This window displays Dependency Web usage throughout existing tests, helping to visualize the relationships between tests in a graphical web format." +
                                       "Because of the way this window is rendered, docking options are limited to Floating and DockNextToGameWindow only when opening.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                //Web must be viewed in a large screen move. Dock next to Game, or allow float.
                Swat.ShowWindow <DependencyVisualizer>(typeof(DependencyVisualizer), "Web", dock == DockNextTo.Float ? dock : DockNextTo.GameView);
            }
            GUILayout.Space(18);

            EditorGUILayout.LabelField("Recorder", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField(@"This window allows you to begin recording automation-relevant actions that you take in the Unity Editor. When you stop recording, all actions are converted into code that can" +
                                       "be pasted directly into a test method, and played back as a new test.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                Nexus.Self.SelectTab(Nexus.Self.Generator);
                Nexus.Self.Generator.SelectedSubTab = GeneratorSubTab.Recorder;
            }
            GUILayout.Space(18);

            EditorGUILayout.LabelField("Settings", editorName);
            GUILayout.Space(4);
            EditorGUILayout.LabelField(@"All Trilleon settings keys are displayed here so that their values can easily be updated, and new custom keys can be added on the fly.", description);
            GUILayout.Space(4);
            if (GUILayout.Button("Open", open))
            {
                Nexus.Self.SelectTab(Nexus.Self.Settings);
            }

            GUILayout.Space(40);
            EditorGUILayout.LabelField("Customize Your Nexus", editorName);

            GUILayout.Space(18);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Default Test View", dropDownLabel, new GUILayoutOption[] { GUILayout.Width(125) });
            defaultTestView = (DefaultTestView)Nexus.Self.DropDown(defaultTestView, 0, 25, 140);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(25);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Dock Next To:", dropDownLabel, new GUILayoutOption[] { GUILayout.Width(125) });
            dock = (DockNextTo)Nexus.Self.DropDown(dock, 0, 25, 140);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(25);

            if (dock != lastPassDock)
            {
                UpdateDockPreference();
                lastPassDock = dock;
            }
            if (defaultTestView != lastPassDefaultTestView)
            {
                SaveDefaultTestView();
                lastPassDefaultTestView = defaultTestView;
            }

            EditorGUILayout.LabelField("Simply select the arrows below change the order in which tabs render at the top of the Nexus window. Changes are made and saved instantly.", description);
            GUILayout.Space(20);

            GUIStyle windowName = new GUIStyle();

            windowName.fontSize    = 15;
            windowName.fixedHeight = 30;
            windowName.alignment   = TextAnchor.MiddleLeft;

            GUIStyle upDownArrowButtons = new GUIStyle(GUI.skin.button);

            upDownArrowButtons.fixedHeight       = 15;
            upDownArrowButtons.fixedWidth        = 25;
            upDownArrowButtons.normal.background = Swat.TabButtonBackgroundTexture;
            upDownArrowButtons.normal.textColor  = Color.blue;

            for (int x = 0; x < TabPreferences.Count; x++)
            {
                stepWrapper             = new GUIStyle();
                stepWrapper.fixedHeight = 30;
                if (recentlyReorderedIndex == x)
                {
                    if ((int)currentAlphaStep - 1 < 0)
                    {
                        currentAlphaStep       = 60;
                        recentlyReorderedIndex = -1;
                    }
                    else
                    {
                        currentAlphaStep -= (byte)1;
                        stepWrapper.normal.background = Swat.MakeTextureFromColor((Color) new Color32(0, 200, 0, currentAlphaStep));
                        Nexus.Self.Repaint();
                    }
                }

                EditorGUILayout.BeginHorizontal(stepWrapper, new GUILayoutOption[] { GUILayout.MaxWidth(200) });
                GUILayout.Space(15);
                upDownArrowButtons.fontSize = 15;

                EditorGUILayout.BeginVertical();
                if (x == 0)
                {
                    upDownArrowButtons.normal.textColor = Color.grey;
                }
                else
                {
                    upDownArrowButtons.normal.textColor = Color.blue;
                }
                if (GUILayout.Button(Swat.MOVEUP, upDownArrowButtons))
                {
                    if (x != 0)
                    {
                        recentlyReorderedIndex = ReOrderAction(x, true);
                    }
                }
                GUILayout.Space(-3f);
                upDownArrowButtons.fontSize = 11;
                if (x == TabPreferences.Count - 1)
                {
                    upDownArrowButtons.normal.textColor = Color.grey;
                }
                else
                {
                    upDownArrowButtons.normal.textColor = Color.blue;
                }
                if (GUILayout.Button(Swat.MOVEDOWN, upDownArrowButtons))
                {
                    if (x != TabPreferences.Count - 1)
                    {
                        recentlyReorderedIndex = ReOrderAction(x, false);
                    }
                }
                else
                {
                    upDownArrowButtons.normal.textColor = Color.blue;
                }
                EditorGUILayout.EndVertical();

                GUILayout.Space(10);
                EditorGUILayout.LabelField(string.Format("{0}   {1}", TabPreferences[x].Value, TabPreferences[x].Key), windowName, new GUILayoutOption[] { GUILayout.Width(175) });
                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space(20);
        }