コード例 #1
0
        public void Set(string message, EditorDelegate onAccept)
        {
            SimpleAlert pop = ScriptableObject.CreateInstance <SimpleAlert>();

            pop.Message   = message;
            pop.OnConfirm = onAccept;
            pop.IsVisible = true;
            pop.ShowPopup();
        }
コード例 #2
0
ファイル: Favorites.cs プロジェクト: tuanminh3395/trilleon
        public override void Render()
        {
            GUIStyle add = new GUIStyle(GUI.skin.button);

            add.margin            = new RectOffset(20, 0, -10, 0);
            add.fixedWidth        = 50;
            add.fixedHeight       = 30;
            add.normal.textColor  = Swat.TabButtonTextColor;
            add.normal.background = Swat.TabButtonBackgroundTexture;

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

            addNew.margin           = new RectOffset(20, 0, 0, 0);
            addNew.fixedWidth       = 75;
            addNew.fixedHeight      = 25;
            addNew.fontSize         = 14;
            addNew.normal.textColor = Swat.ActionButtonTextColor;

            if (makeNew)
            {
                addNew.normal.background = Swat.MakeTextureFromColor(Color.black);
            }
            else
            {
                addNew.normal.background = Swat.ActionButtonTexture;
            }

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

            deleteItem.margin            = new RectOffset(20, 0, -2, 0);
            deleteItem.fontSize          = 16;
            deleteItem.normal.textColor  = Color.red;
            deleteItem.normal.background = Swat.TabButtonBackgroundTexture;

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

            launchGroup.margin            = new RectOffset(-10, 2, -5, 0);
            launchGroup.fixedWidth        = 25;
            launchGroup.fixedHeight       = 25;
            launchGroup.normal.textColor  = Swat.TabButtonTextColor;
            launchGroup.normal.background = Swat.TabButtonBackgroundTexture;

            GUIStyle favoriteHeader = new GUIStyle(GUI.skin.label);

            favoriteHeader.padding     = new RectOffset(10, 0, 0, 0);
            favoriteHeader.fontStyle   = FontStyle.Bold;
            favoriteHeader.alignment   = TextAnchor.LowerLeft;
            favoriteHeader.fontSize    = 15;
            favoriteHeader.fixedHeight = 15f;

            GUIStyle nameField = new GUIStyle(GUI.skin.textField);

            nameField.margin = new RectOffset(20, 0, 5, 5);

            GUIStyle typeHeader = new GUIStyle(GUI.skin.label);

            typeHeader.padding  = new RectOffset(20, 0, 0, 0);
            typeHeader.fontSize = 12;

            GUIStyle catFoldOut = new GUIStyle(EditorStyles.foldout);

            catFoldOut.margin    = new RectOffset(20, 0, 0, 0);
            catFoldOut.fontStyle = FontStyle.Italic;
            catFoldOut.fontSize  = 11;

            GUIStyle catTest = new GUIStyle(GUI.skin.label);

            catTest.padding  = new RectOffset(30, 0, 0, 0);
            catTest.fontSize = 12;

            GUILayout.Space(25);
            GUIStyle cs = new GUIStyle(EditorStyles.label);

            cs.padding   = new RectOffset(25, 15, 2, 2);
            cs.wordWrap  = true;
            cs.fontStyle = FontStyle.Italic;
            Nexus.Self.Button(makeNew ? "Cancel" : "Add New", "Add new Favorite test run.",
                              new Nexus.SwatDelegate(delegate() {
                makeNew       = !makeNew;
                isEdit        = false;
                buildingAdded = new List <KeyValuePair <string, string> >();
            }), addNew);
            GUILayout.Space(30);

            if (makeNew)
            {
                EditorGUILayout.BeginHorizontal();
                Nexus.Self.Button("Add", "Add To List.",
                                  new Nexus.SwatDelegate(delegate() {
                    if (!buildingAdded.FindAll(x => x.Key == _categories[SelectedCatIndex]).Any())
                    {
                        buildingAdded.Add(new KeyValuePair <string, string>(string.Format("{0}{1}", _categories[SelectedCatIndex], classIndicator), string.Empty));
                    }
                }), add);
                GUILayout.Space(-20);
                SelectedCatIndex = Nexus.Self.DropDown(SelectedCatIndex, _categories, 20, width: 280);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(10);
                EditorGUILayout.BeginHorizontal();
                Nexus.Self.Button("Add", "Add To List.",
                                  new Nexus.SwatDelegate(delegate() {
                    if (!buildingAdded.FindAll(x => x.Value == _requestedMethods[SelectedTestIndex]).Any())
                    {
                        buildingAdded.Add(new KeyValuePair <string, string>(GetTestsClassName(_requestedMethods[SelectedTestIndex]), _requestedMethods[SelectedTestIndex]));
                    }
                }), add);
                GUILayout.Space(-20);
                SelectedTestIndex = Nexus.Self.DropDown(SelectedTestIndex, _requestedMethods, 20, width: 280);
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(15);
                for (int b = 0; b < buildingAdded.Count; b++)
                {
                    //If the next item is a test under this class, then don't render the classname as a header. We only want to render class names as a header in the saved, non-editable display.
                    if (b + 1 < buildingAdded.Count ? buildingAdded[b].Value.Length == 0 && buildingAdded[b + 1].Value.Length > 0 && buildingAdded[b].Key.Replace("*", string.Empty) == buildingAdded[b + 1].Key : false)
                    {
                        continue;
                    }
                    EditorGUILayout.BeginHorizontal();
                    bool deleted = false;
                    Nexus.Self.Button("X", "Remove this item.",
                                      new Nexus.SwatDelegate(delegate() {
                        //Check if the previous item is a class name and matches this test's class name. If so, then check if the next item does not share the same category name.
                        //If both are true, then remove the previous item, as it is just a category header that no longer has any tests under it. Leave it if there are other tests after this one that require that category header.
                        if ((b - 1 >= 0 ? buildingAdded[b - 1].Value.Length == 0 && buildingAdded[b].Key == buildingAdded[b - 1].Key.Replace("*", string.Empty) : false) && (b + 1 < buildingAdded.Count ? buildingAdded[b + 1].Key != buildingAdded[b].Key : true))
                        {
                            buildingAdded.RemoveAt(b - 1);
                            b--;
                        }
                        buildingAdded.RemoveAt(b);
                        b--;
                        deleted = true;
                    }), deleteItem, new GUILayoutOption[] { GUILayout.Width(20) });
                    if (deleted)
                    {
                        EditorGUILayout.EndHorizontal();
                        continue;
                    }
                    GUILayout.Space(-10);
                    EditorGUILayout.LabelField(string.Format("{0}{1}", buildingAdded[b].Value.Length > 0 ? string.Format("({0}) ", buildingAdded[b].Key) : buildingAdded[b].Key, buildingAdded[b].Value.Length > 0 ? buildingAdded[b].Value : string.Empty), typeHeader);
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(2);
                }
                GUILayout.Space(15);

                EditorGUILayout.LabelField("Name:", typeHeader);
                newName = EditorGUILayout.TextField(newName, nameField, new GUILayoutOption[] { GUILayout.Width(150) });
                Nexus.Self.Button("Save", "Save Favorite.",
                                  new Nexus.SwatDelegate(delegate() {
                    if (newName.Trim().Length == 0)
                    {
                        SimpleAlert.Pop("A name is required to save this Favorites list.", null);
                    }
                    else if (buildingAdded.Count == 0)
                    {
                        SimpleAlert.Pop("At least one category or test needs to be added to this Favorites list to save.", null);
                    }
                    else if (FavoritesList.FindAll(c => c.Key == newName.Trim()).Any() && (isEdit ? FavoritesList[EditId].Key != newName.Trim() : true))
                    {
                        SimpleAlert.Pop("There is already a Favorite with this name. Please choose a unique name.", null);
                    }
                    else
                    {
                        saveCurrent = true;
                        makeNew     = false;
                        SaveNew();
                    }
                }), addNew);
                GUILayout.Space(20);
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                GUILayout.Space(20);
            }

            int foldoutIndex = 0;

            for (int f = 0; f < FavoritesList.Count; f++)
            {
                if (isEdit && EditId == f)
                {
                    continue;
                }

                EditorGUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Width(300) });
                launchGroup.fontSize = 16;
                EditorGUILayout.LabelField(FavoritesList[f].Key, favoriteHeader);
                Nexus.Self.Button("▶", "Launch this Favorite.",
                                  new Nexus.SwatDelegate(delegate() {
                    //This is a Favorite list, and not a true Category. Gather requested tests/classes.
                    List <KeyValuePair <bool, string> > favoriteList = FavoritesList[f].Value;
                    string commandClasses = string.Empty;
                    string commandTests   = string.Empty;
                    for (int x = 0; x < favoriteList.Count; x++)
                    {
                        //Is the next item in the list a test? If so, this category is only meant to define the tests that follow, so ignore it.
                        if (favoriteList[x].Key && x + 1 < favoriteList.Count ? !favoriteList[x + 1].Key : false)
                        {
                            continue;
                        }

                        if (favoriteList[x].Key)
                        {
                            //All Tests In This Class
                            string category = string.Empty;
                            if (favoriteList[x].Value.Contains("("))
                            {
                                category = favoriteList[x].Value.Replace("*", string.Empty).Replace("<", string.Empty).Replace(">", string.Empty).Split('(')[1].Trim(')');
                            }
                            else
                            {
                                category = favoriteList[x].Value.Replace("*", string.Empty).Replace("<", string.Empty).Replace(">", string.Empty);
                            }
                            commandClasses += string.Format("{0},", category);
                        }
                        else
                        {
                            //Just This Test
                            commandTests += string.Format("{0},", favoriteList[x].Value);
                        }
                    }
                    string command = string.Format("&&{0}%{1}", commandClasses.Trim(','), commandTests.Trim(','));;
                    Nexus.Self.Tests.LaunchTests(command, "mix");
                }), launchGroup);
                launchGroup.fontSize = 22;
                Nexus.Self.Button("✎", "Edit this Favorite.",
                                  new Nexus.SwatDelegate(delegate() {
                    makeNew       = true;
                    isEdit        = true;
                    newName       = FavoritesList[f].Key;
                    EditId        = f;
                    buildingAdded = new List <KeyValuePair <string, string> >();
                    for (int l = 0; l < FavoritesList[f].Value.Count; l++)
                    {
                        KeyValuePair <string, string> newItem = new KeyValuePair <string, string>();
                        if (FavoritesList[f].Value[l].Key)
                        {
                            newItem = new KeyValuePair <string, string>(string.Format("{0}{1}", FavoritesList[f].Value[l].Value, classIndicator), string.Empty);
                        }
                        else
                        {
                            newItem = new KeyValuePair <string, string>(GetTestsClassName(FavoritesList[f].Value[l].Value), FavoritesList[f].Value[l].Value);
                        }

                        //Avoid possible duplicates
                        if (l + 1 == FavoritesList[f].Value.Count || (!buildingAdded.FindAll(b => b.Key == newItem.Key).Any() && !buildingAdded.FindAll(b => b.Value == newItem.Value).Any()))
                        {
                            buildingAdded.Add(newItem);
                        }
                    }
                }), launchGroup);
                launchGroup.fontSize = 16;
                Nexus.Self.Button("X", "Delete this Favorite.",
                                  new Nexus.SwatDelegate(delegate() {
                    keyToDelete = FavoritesList[f].Key;
                    SimpleAlert.Pop("Are you sure you want to delete this Favorites list?", new EditorDelegate(DeleteFavorite));
                }), launchGroup);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(10);

                for (int z = 0; z < FavoritesList[f].Value.Count; z++)
                {
                    if ((z + 1 == FavoritesList[f].Value.Count && FavoritesList[f].Value[z].Key) || (z + 1 < FavoritesList[f].Value.Count && FavoritesList[f].Value[z + 1].Key && FavoritesList[f].Value[z].Key))
                    {
                        EditorGUILayout.LabelField(FavoritesList[f].Value[z].Value, typeHeader);
                        GUILayout.Space(10);
                    }
                    else if (FavoritesList[f].Value[z].Key)
                    {
                        Nexus.Self.Foldout(true, new GUIContent(FavoritesList[f].Value[z].Value), true, catFoldOut);
                        GUILayout.Space(4);

                        for (int o = z + 1; o < FavoritesList[f].Value.Count; o++)
                        {
                            if (FavoritesList[f].Value[o].Key)
                            {
                                break;
                            }
                            EditorGUILayout.LabelField(FavoritesList[f].Value[o].Value, catTest);
                        }
                        GUILayout.Space(10);
                    }
                }

                foldoutIndex++;
                GUILayout.Space(20);
            }
        }
コード例 #3
0
        public override void OnGUI()
        {
            if (Nexus.Self == null || Nexus.Self.SelectedTab.Window.GetType() != constraint)
            {
                Close();
                return;
            }

            if (lastWindowWidth != Nexus.Self.position.width)
            {
                positionWindow = true;
            }

            if (positionWindow)
            {
                positionWindow  = false;
                lastWindowWidth = Nexus.Self.position.width;
                PositionWindow();
            }

            GUI.DrawTexture(new Rect(0, 0, position.width, position.height), Swat.MakeTextureFromColor(Color.gray));

            scrollBar        = new GUIStyle();
            scrollBar.margin = new RectOffset(25, 20, 0, 0);

            divider = new GUIStyle(GUI.skin.box);
            divider.normal.background = Swat.MakeTextureFromColor(Color.white);
            divider.margin            = new RectOffset(25, 0, 10, 20);

            toggleGroup        = new GUIStyle();
            toggleGroup.margin = new RectOffset(12, 0, 0, 0);

            toggle                  = new GUIStyle(GUI.skin.label);
            toggle.padding          = new RectOffset(35, 0, 0, 0);
            toggle.normal.textColor = Color.white;
            toggle.fixedWidth       = 25;
            toggle.fixedHeight      = 25;

            toggleLabel = new GUIStyle(GUI.skin.label);
            toggleLabel.normal.textColor = Color.white;

            header                  = new GUIStyle(GUI.skin.label);
            header.fontSize         = 15;
            header.fixedHeight      = 20;
            header.normal.textColor = Color.white;
            header.fontStyle        = FontStyle.Bold;
            header.alignment        = TextAnchor.MiddleCenter;

            buttons                   = new GUIStyle(GUI.skin.button);
            buttons.fixedHeight       = buttonHeight;
            buttons.fixedWidth        = buttonWidth;
            buttons.normal.textColor  = Color.white;
            buttons.normal.background = Swat.MakeTextureFromColor((Color) new Color32(80, 80, 80, 255));

            buttonGroup = new GUIStyle();

            EditorGUILayout.BeginVertical();

            GUILayout.Space(15);
            EditorGUILayout.LabelField("Select Categories", header);
            GUILayout.Box(string.Empty, divider, new GUILayoutOption[] { GUILayout.Height(1), GUILayout.Width(position.width - 50) });

            scrollY = EditorGUILayout.BeginScrollView(scrollY, scrollBar);

            for (int x = 0; x < Cats.Count; x++)
            {
                EditorGUILayout.BeginHorizontal(toggleGroup);
                toggle.padding  = CatsSelected[x] ? new RectOffset(0, 0, -6, 0) : new RectOffset(2, 0, -2, 0);
                toggle.fontSize = CatsSelected[x] ? 25 : 18;
                if (GUILayout.Button(CatsSelected[x] ? Swat.TOGGLE_ON : Swat.TOGGLE_OFF, toggle))
                {
                    CatsSelected[x] = !CatsSelected[x];
                }

                GUILayout.Space(-15);
                if (GUILayout.Button(string.Format("  {0}", Cats[x]), toggleLabel))
                {
                    CatsSelected[x] = !CatsSelected[x];                     //Toggle accompanying checkbox.
                }
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(-10);
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Box(string.Empty, divider, new GUILayoutOption[] { GUILayout.Height(1), GUILayout.Width(position.width - 50) });

            GUILayout.Space(15);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(50);
            toggle.padding  = AutomationMaster.DisregardDependencies ? new RectOffset(0, 0, -6, 0) : new RectOffset(2, 0, -2, 0);
            toggle.fontSize = AutomationMaster.DisregardDependencies ? 25 : 18;
            if (GUILayout.Button(AutomationMaster.DisregardDependencies ? Swat.TOGGLE_ON : Swat.TOGGLE_OFF, toggle))
            {
                AutomationMaster.DisregardDependencies = !AutomationMaster.DisregardDependencies;
            }
            GUILayout.Space(-10);
            if (GUILayout.Button("Also Run Dependencies? ", toggleLabel))
            {
                AutomationMaster.DisregardDependencies = !AutomationMaster.DisregardDependencies;                 //Toggle accompanying checkbox.
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(15);

            float margin = (position.width - (buttonWidth * 2)) / 2;

            buttonGroup.margin = new RectOffset((int)margin, (int)margin, 0, 10);

            EditorGUILayout.BeginHorizontal(buttonGroup);

            if (GUILayout.Button("Cancel", buttons))
            {
                Nexus.Overseer.Master_Editor_Override = new KeyValuePair <string, string>();
                IsVisible = false;
                Close();
            }
            if (GUILayout.Button("Launch", buttons))
            {
                Nexus.Overseer.ignoreDependentTestsForRun = true;
                string command   = string.Empty;
                string testsOnly = string.Empty;
                for (int x = 0; x < Cats.Count; x++)
                {
                    if (CatsSelected[x])
                    {
                        if (Cats[x].StartsWith("*"))
                        {
                            string cat = Cats[x].Replace("*", string.Empty);
                            List <KeyValuePair <string, List <KeyValuePair <bool, string> > > > match = Nexus.Self.Favorites.FavoritesList.FindAll(f => f.Key == cat);
                            if (match.Count == 0)
                            {
                                SimpleAlert.Pop(string.Format("Cannot find data for Favorite, \"{0}\", selected in multi-category launch.", cat), null);
                                return;
                            }
                            else
                            {
                                List <KeyValuePair <bool, string> > contents = match.First().Value;
                                for (int c = 0; c < contents.Count; c++)
                                {
                                    if (contents[c].Key)
                                    {
                                        //If the next item in this list is not a category, then the current category is merely a header for the test list that follows, and should not be included.
                                        if (c + 1 < contents.Count && !contents[c + 1].Key)
                                        {
                                            continue;
                                        }

                                        command += string.Format("{0},", contents[c].Value);
                                    }
                                    else
                                    {
                                        testsOnly += string.Format("{0},", contents[c].Value);
                                    }
                                }
                            }
                        }
                        else
                        {
                            string category = string.Empty;
                            if (Cats[x].Contains("("))
                            {
                                category = Cats[x].Replace("<", string.Empty).Replace(">", string.Empty).Split('(')[1].Trim(')');
                            }
                            else
                            {
                                category = Cats[x].Replace("<", string.Empty).Replace(">", string.Empty);
                            }
                            command += string.Format("{0},", category);
                        }
                    }
                }
                command = command.Trim(',').Replace("*", "@");                 //@ represents favorite when * represents single test.
                if (testsOnly.Length > 0)
                {
                    command = string.Format("&&{0}%{1}", command, testsOnly);
                }

                Close();
                Nexus.Self.Tests.LaunchTests(command, "class");
                IsVisible = false;
                AutomationMaster.DisregardDependencies = true;                 //Ignore dependencies.
            }

            EditorGUILayout.EndHorizontal();
        }
コード例 #4
0
        public override void Render()
        {
            if (_showFileDeletedMessage)
            {
                if (DateTime.Now.Subtract(_fileDeletedTime).TotalSeconds > 2)
                {
                    _showFileDeletedMessage = false;
                }
            }

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

            back.fontSize = 20;
            back.margin   = new RectOffset(25, 0, 10, 20);

            if (ReDrawAutomationReports)
            {
                ReDrawAutomationReports = false;

                if (!Directory.Exists(Path.GetDirectoryName(FileBroker.REPORTS_DIRECTORY)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(FileBroker.REPORTS_DIRECTORY));
                }

                //Grab any report files.
                List <string> all = Directory.GetFiles(FileBroker.REPORTS_DIRECTORY, "report.html", SearchOption.AllDirectories).ToList();
                automationReports = new List <FileInfo>();

                for (int x = 0; x < all.Count; x++)
                {
                    automationReports.Add(new FileInfo(all[x]));
                }

                //Grab meta files for reports.
                all      = Directory.GetFiles(FileBroker.REPORTS_DIRECTORY, "report.meta", SearchOption.AllDirectories).ToList();
                metaData = new List <KeyValuePair <string, List <KeyValuePair <string, string> > > >();
                for (int m = 0; m < all.Count; m++)
                {
                    FileInfo info      = new FileInfo(all[m]);
                    string[] metaLines = FileBroker.ReadUnboundFile(info.FullName);
                    List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >();

                    for (int ml = 0; ml < metaLines.Length; ml++)
                    {
                        string[] keyVals = metaLines[ml].Split(':');
                        values.Add(new KeyValuePair <string, string>(keyVals[0], keyVals[1]));
                    }

                    metaData.Add(new KeyValuePair <string, List <KeyValuePair <string, string> > >(all[m].Split(new string[] { string.Format("{0}{1}", GameMaster.GAME_NAME, FileBroker.FILE_PATH_SPLIT) }, StringSplitOptions.None)[1].Replace(string.Format("{0}report.meta", FileBroker.FILE_PATH_SPLIT), ".html"), values));
                }

                automationReports.Reverse();
            }

            if (!automationReports.Any())
            {
                GUIStyle noResults = new GUIStyle(GUI.skin.label);
                noResults.padding          = new RectOffset(10, 0, 0, 0);
                noResults.fontSize         = 14;
                noResults.normal.textColor = Color.blue;
                GUILayout.Space(20);
                EditorGUILayout.LabelField("No test reports currently exist.", noResults);
                return;
            }

            Color32  boxGreen  = new Color32(20, 175, 0, 255);
            GUIStyle fileLabel = new GUIStyle(GUI.skin.label);

            fileLabel.normal.textColor = boxGreen;
            fileLabel.padding          = new RectOffset(32, 0, 0, 1);

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

            fileNameButton.margin            = new RectOffset(35, 0, 0, 0);
            fileNameButton.normal.background = fileNameButton.active.background = fileNameButton.focused.background = Swat.TabButtonBackgroundTexture;
            fileNameButton.normal.textColor  = Swat.WindowDefaultTextColor;

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

            deleteFileButton.normal.textColor  = Color.red;
            deleteFileButton.fontSize          = 14;
            deleteFileButton.margin            = new RectOffset(1, 0, 0, 5);
            deleteFileButton.normal.background = deleteFileButton.active.background = deleteFileButton.focused.background = Swat.TabButtonBackgroundTexture;
            deleteFileButton.normal.textColor  = Color.red;

            GUIStyle divider = new GUIStyle(GUI.skin.box);

            divider.normal.background = Swat.MakeTextureFromColor(boxGreen);
            divider.margin            = new RectOffset(35, 10, 10, 10);

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

            deleteAllButton.fontSize          = 12;
            deleteAllButton.normal.textColor  = Color.red;
            deleteAllButton.fontStyle         = FontStyle.Bold;
            deleteAllButton.fixedHeight       = 38;
            deleteAllButton.margin            = new RectOffset(0, 25, 5, 0);
            deleteAllButton.normal.background = deleteAllButton.active.background = deleteAllButton.focused.background = Swat.TabButtonBackgroundTexture;
            deleteAllButton.normal.textColor  = Color.red;

            GUILayout.Space(20);

            GUIStyle padding = new GUIStyle();

            padding.margin = new RectOffset(25, 0, 0, 0);
            GUILayout.BeginHorizontal(padding);
            EditorGUILayout.Space();
            if (_showFileDeletedMessage)
            {
                GUIStyle deleteFileAlert = new GUIStyle(GUI.skin.label);
                deleteFileAlert.normal.textColor = Color.red;
                deleteFileAlert.fontSize         = 14;
                deleteFileAlert.fixedHeight      = 28;
                deleteFileAlert.padding          = new RectOffset(30, 0, 14, 0);
                EditorGUILayout.LabelField("Deleted!", deleteFileAlert);
            }
            EditorGUILayout.Space();
            if (GUILayout.Button("Delete All", deleteAllButton, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(75) }))
            {
                SimpleAlert.Pop("Are you sure you want to delete all stored test run reports?", new EditorDelegate(DeleteAll));
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(20);

            for (int ar = 0; ar < automationReports.Count; ar++)
            {
                bool     isNewest  = ar == 0;
                string[] splitTime = automationReports[ar].CreationTime.ToShortTimeString().Split(':');
                int      hour      = int.Parse(splitTime[0]);
                bool     am        = true;
                if (hour >= 12)
                {
                    am = false;
                    if (hour != 12)
                    {
                        hour -= 12;
                    }
                }

                if (!isNewest)
                {
                    fileNameButton.normal.textColor = fileLabel.normal.textColor = Swat.WindowDefaultTextColor;
                }

                string timeOfDay = string.Format("{0}:{1} {2}", hour.ToString(), splitTime[1], am ? "AM" : "PM");
                if (isNewest)
                {
                    EditorGUILayout.LabelField("-----Newest-----", fileLabel);
                }
                EditorGUILayout.LabelField(string.Format("{0}    {1}", automationReports[ar].CreationTime.ToLongDateString(), timeOfDay), fileLabel);

                List <KeyValuePair <string, List <KeyValuePair <string, string> > > > matchMetaResults = metaData.FindAll(x => automationReports[ar].Directory.ToString().Contains(x.Key.Replace(".html", string.Empty)));

                if (matchMetaResults.Any())
                {
                    KeyValuePair <string, List <KeyValuePair <string, string> > > matchMeta = matchMetaResults.First();
                    EditorGUILayout.LabelField(string.Format("{0}:{1}     {2}:{3}     {4}:{5}     {6}:{7}",
                                                             TestManifest.PASSED, matchMeta.Value.Find(x => x.Key == "Passes").Value,
                                                             TestManifest.FAILED, matchMeta.Value.Find(x => x.Key == "Fails").Value,
                                                             TestManifest.SKIPPED, matchMeta.Value.Find(x => x.Key == "Skips").Value,
                                                             TestManifest.IGNORED, matchMeta.Value.Find(x => x.Key == "Ignores").Value), fileLabel);

                    if (Nexus.Self.MouseOver())
                    {
                        Nexus.Self.SetToolTip(matchMeta.Value.Find(x => x.Key == "RunCommand").Value.Replace(",", "\n"));
                    }
                }

                if (isNewest)
                {
                    GUILayout.Box(string.Empty, divider, new GUILayoutOption[] { GUILayout.Height(1), GUILayout.Width(180) });
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Open Report", fileNameButton, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(150) }))
                {
                    System.Diagnostics.Process.Start(automationReports[ar].FullName);
                }
                if (GUILayout.Button("X", deleteFileButton, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(30) }))
                {
                    //Delete report and associated meta file.
                    Directory.Delete(automationReports[ar].Directory.ToString().Replace("/report.html", string.Empty), true);
                    ReDrawAutomationReports = true;
                    _fileDeletedTime        = DateTime.Now;
                    _showFileDeletedMessage = true;
                }
                GUILayout.EndHorizontal();

                if (isNewest)
                {
                    GUILayout.Box(string.Empty, divider, new GUILayoutOption[] { GUILayout.Height(1), GUILayout.Width(180) });
                }

                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
        }
コード例 #5
0
        public override void Render()
        {
            console = new GUIStyle(GUI.skin.box);
            console.normal.background = Swat.MakeTextureFromColor((Color) new Color32(100, 100, 100, 255));
            console.wordWrap          = true;
            console.normal.textColor  = Color.white;
            console.padding           = new RectOffset(10, 20, 0, 0);
            console.fontSize          = 15;
            console.alignment         = TextAnchor.MiddleLeft;

            description                  = new GUIStyle(GUI.skin.label);
            description.wordWrap         = true;
            description.margin           = new RectOffset(10, 10, 0, 0);
            description.padding          = new RectOffset(0, 0, 5, 5);
            description.normal.textColor = Swat.WindowDefaultTextColor;
            description.fontSize         = 12;

            args                  = new GUIStyle(GUI.skin.label);
            args.wordWrap         = true;
            args.margin           = new RectOffset(10, 10, 0, 0);
            args.normal.textColor = Swat.WindowDefaultTextColor;
            args.fontSize         = 11;

            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;

            load = new GUIStyle(GUI.skin.box);
            load.normal.background = Swat.MakeTextureFromColor((Color) new Color32(75, 75, 75, 255));
            load.normal.textColor  = Color.white;
            load.fontSize          = 18;
            load.alignment         = TextAnchor.MiddleCenter;

            open                   = new GUIStyle(GUI.skin.button);
            open.fontSize          = 14;
            open.fixedHeight       = 28;
            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;

            variables                  = new GUIStyle(GUI.skin.textField);
            variables.fontSize         = 12;
            variables.margin           = new RectOffset(10, 10, 0, 0);
            variables.normal.textColor = Swat.WindowDefaultTextColor;

            _scroll = GUILayout.BeginScrollView(_scroll);

            GUILayout.Space(!Application.isPlaying ? 15 : 45);
            EditorGUILayout.LabelField("Filter (Search for command name or description/purpose matching)", description);
            search = EditorGUILayout.TextField(search, variables, new GUILayoutOption[] { GUILayout.MaxWidth(400) });
            GUILayout.Space(25);

            int inputFieldId = 0;

            for (int x = 0; x < Commands.Count; x++)
            {
                Command command       = Commands[x];
                string  longestAlias  = string.Empty;
                bool    filterActive  = !string.IsNullOrEmpty(search.Trim());
                bool    filterMatched = false;
                for (int l = 0; l < command.Aliases.Count; l++)
                {
                    if (filterActive && (command.Aliases[l].ToLower().Contains(search) || command.Purpose.ToLower().Contains(search)))
                    {
                        filterMatched = true;
                    }
                    longestAlias = command.Aliases[l].Length > longestAlias.Length ? command.Aliases[l] : longestAlias;
                }

                if (filterActive && !filterMatched)
                {
                    continue;                     //Don't render this information; no match found.
                }

                EditorGUILayout.LabelField(longestAlias, editorName);
                GUILayout.Space(4);
                EditorGUILayout.LabelField(command.Purpose, description);
                GUILayout.Space(6);

                if (command.Args.Count > 0)
                {
                    for (int a = 0; a < command.Args.Count; a++)
                    {
                        EditorGUILayout.LabelField(string.Format("(Arg {0}) <{1}> {2}", a, command.Args[a].Key, command.Args[a].Value), description);
                        GUILayout.Space(2);
                    }

                    GUILayout.Space(4);
                    if (VariableInputFields.Count == inputFieldId)
                    {
                        VariableInputFields.Add(string.Empty);
                    }
                    VariableInputFields[inputFieldId] = EditorGUILayout.TextField(VariableInputFields[inputFieldId], variables, new GUILayoutOption[] { GUILayout.MaxWidth(400) });
                    GUILayout.Space(8);
                    inputFieldId++;
                }
                if (GUILayout.Button("Launch", open))
                {
                    if (!EditorApplication.isPlaying)
                    {
                        SimpleAlert.Pop("Console commands can only be executed when Play Mode is active.", null);
                    }
                    else
                    {
                        ConsoleCommands.SendCommand(string.Format("{0} {1}", longestAlias, VariableInputFields[inputFieldId - 1]));                         //Minus one because we are handling and incrementing this input before this onClick is implemented.
                        showCommandLog = true;
                    }
                }
                GUILayout.Space(20);
            }
            GUILayout.Space(40);
            GUILayout.EndScrollView();

            string arrow = showCommandLog ? "▲" : "▼";

            if (Application.isPlaying)
            {
                load.padding  = showCommandLog ? new RectOffset(0, 0, -8, 0) : new RectOffset(0, 0, 0, 0);
                load.fontSize = 15;
                if (GUI.Button(new Rect(0, 24, Nexus.Self.position.width, 30), string.Format("{0}    Show Command Log    {0}", arrow), load))
                {
                    showCommandLog = !showCommandLog;
                }
                if (showCommandLog)
                {
                    //_scrollConsole = GUI.BeginScrollView(new Rect(0, 30, Nexus.Self.position.width, 400), _scrollConsole, new Rect(0, 30, Nexus.Self.position.width, 400));
                    GUI.TextArea(new Rect(0, 50, Nexus.Self.position.width, 400), ConsoleCommands.ConsoleLog.text, console);
                    //GUILayout.EndScrollView();
                }
            }
        }