示例#1
0
        public void Initialize(PlayModeStateChange p)
        {
            _initialized = true;
            if (SelectedTab == null)
            {
                SelectedTab = SwatWindows.First();
            }

            for (int s = 0; s < SwatWindows.Count; s++)
            {
                SwatWindows[s].Window.Set();
            }

            //Close all open popup instances.
            List <Type>     popTypes      = new List <Type>();
            List <Assembly> assembliesAll = AppDomain.CurrentDomain.GetAssemblies().ToList();

            for (int x = 0; x < assembliesAll.Count; x++)
            {
                popTypes.AddRange(assembliesAll[x].GetTypes().ToList().FindAll(m => m.IsClass && m.GetInterface("SwatPopup") != null));
            }
            for (int pt = 0; pt < popTypes.Count; pt++)
            {
                EditorWindow.GetWindow(popTypes[pt], false).Close();
            }
            Errors = new List <SwatControlError>();
            Repaint();
        }
示例#2
0
        public void SwitchTabOrder(string tabOne, string tabTwo)
        {
            TabDetails tabOneSwap = SwatWindows.Find(x => x.Window.GetType().Name == tabOne);

            SwatWindows.Remove(tabOneSwap);
            TabDetails tabTwoSwap = SwatWindows.Find(x => x.Window.GetType().Name == tabTwo);

            SwatWindows.Remove(tabTwoSwap);
            int idOne = tabOneSwap.PriorityID;
            int idTwo = tabTwoSwap.PriorityID;

            tabOneSwap.PriorityID = idTwo;
            tabTwoSwap.PriorityID = idOne;
            SwatWindows.Add(tabOneSwap);
            SwatWindows.Add(tabTwoSwap);
        }
示例#3
0
        /*TODO: Fix it not being called.
         * void OnGUI() {
         *
         *      bool active = false;
         *      Event e = Event.current;
         *      if(e != null && e.type == EventType.keyDown) {
         *
         *              if(Event.current.keyCode == KeyCode.LeftShift) {
         *
         *                      active = true;
         *
         *              }
         *
         *      }
         *      if(active) {
         *
         *              for(int s = 0; s < SwatWindows.Count; s++) {
         *
         *                      bool activated = false;
         *                      for(int k = 0; k < SwatWindows[s].Shortcut.Count; k++) {
         *
         *                              if(Event.current.keyCode == SwatWindows[s].Shortcut[k]) {
         *
         *                                      activated = true;
         *
         *                              } else {
         *
         *                                      activated = false;
         *                                      break;
         *
         *                              }
         *
         *                      }
         *
         *                      if(activated) {
         *
         *                              SelectedTab = SwatWindows[s];
         *
         *                      }
         *
         *              }
         *
         *      }
         *
         * }*/

        /// <summary>
        /// Render all tabs and selected SWAT window.
        /// </summary>
        public void Render()
        {
            RenderToolTip = false;
            if (!_initialized)
            {
                Initialize(PlayModeStateChange.EnteredEditMode);
                                #if UNITY_2017_2_OR_NEWER
                EditorApplication.playModeStateChanged += Initialize;
                                #else
                EditorApplication.playmodeStateChanged += Initialize;
                                #endif
            }

            GUI.DrawTexture(new Rect(0, 0, position.width, position.height), WindowBackgroundTexture);

            if (popping)
            {
                GUI.DrawTexture(new Rect(0, 0, position.width, position.height), Swat.MakeTextureFromColor((Color) new Color32(100, 100, 100, 150)));
            }

            if (!SwatWindows.Any())
            {
                return;
            }

            _tabButton        = new GUIStyle(GUI.skin.button);
            _closeButtonWidth = 25;

            //Render tabs based on current size of window.
            _tabWidthTotal = 90 * SwatWindows.Count + _closeButtonWidth;

            if (position.width >= _tabWidthTotal)
            {
                _currentTabSize = TabSize.Large;
            }
            else if (position.width > (_tabWidthTotal / 1.25))
            {
                _currentTabSize = TabSize.Medium;
            }
            else
            {
                _currentTabSize = TabSize.Small;
            }

            _tabWidthTotal = position.width;             //Tabs will span the entire width of the Swat window.

            EditorGUILayout.BeginHorizontal();

            //Only render the tab group if this is a primary window. Sub windows (such as Favorites) will not be included in the toolbar.
            if (SelectedTab.PriorityID >= 0)
            {
                for (int tb = 1; tb < SwatWindows.Count; tb++)
                {
                    TabDetails tabDetails = SwatWindows.Find(s => s.PriorityID == tb);
                    if (tabDetails == null)
                    {
                        continue;                         //Hidden window, so no tabs.
                    }
                    RenderTab(tabDetails);
                }

                List <TabDetails> priorityZeros = SwatWindows.FindAll(s => s.PriorityID == 0);
                for (int p = 0; p < priorityZeros.Count; p++)
                {
                    RenderTab(priorityZeros[p]);
                }
            }

            _tabButton = new GUIStyle(GUI.skin.button);
            _tabButton.normal.textColor  = SelectedTab.PriorityID >= 0 ? Color.red : TextGreen;
            _tabButton.margin            = new RectOffset(-2, -2, 0, 0);
            _tabButton.fontSize          = 14;
            _tabButton.alignment         = TextAnchor.MiddleCenter;
            _tabButton.normal.background = TabButtonBackgroundTexture;
            _closeButtonWidth            = SelectedTab.PriorityID >= 0 ? _closeButtonWidth : 50;

            Nexus.Self.Button(SelectedTab.PriorityID >= 0 ? "X" : "<<<", "Show/Hide currently-selected game object in heirarchy window.",
                              new Nexus.SwatDelegate(delegate() {
                if (SelectedTab.PriorityID >= 0)
                {
                    this.CloseSwat();
                }
                else
                {
                    SelectedTab = LastSelectedTab;
                }
            }), _tabButton, new GUILayoutOption[] { GUILayout.Height(25), GUILayout.Width(_closeButtonWidth) });

            EditorGUILayout.EndHorizontal();

            if (SelectedTab != LastSelectedTab)
            {
                _scroll = new Vector2(0, 0);
                SelectedTab.Window.OnTabSelected();
            }

            if (!SelectedTab.OverrideScroll)
            {
                _scroll = EditorGUILayout.BeginScrollView(_scroll);
            }

            try {
                if (SelectedTab.Window == null)
                {
                    return;
                }
                if (LastSelectedTab != SelectedTab && SelectedTab.PriorityID >= 0)
                {
                    LastSelectedTab = SwatWindows.Find(x => x.Window == SelectedTab.Window);
                }
                SelectedTab.Window.Render();
                RenderAnyError();
                RenderLoadingOverlay();
            } catch (Exception e) {
                if (IsValidError(e.Message))
                {
                    throw e;
                }
            }

            if (!SelectedTab.OverrideScroll)
            {
                EditorGUILayout.EndScrollView();
            }

            RenderToolTipIfHovering(position);
        }
示例#4
0
 public void AddWindowTab(TabDetails details)
 {
     SwatWindows.Add(details);
 }
示例#5
0
 public void SelectTab(SwatWindow tabToSelect)
 {
     SelectedTab = SwatWindows.Find(x => x.Window == tabToSelect);
 }
示例#6
0
        void OnEnable()
        {
            //If AutomationMaster has not been initialized, we may encounter errors using the Nexus window. Attaching the AutoConsole listener will allow for more helpful explanations.
            if (!AutomationMaster.Initialized)
            {
                Application.logMessageReceived -= AutoConsole.GetLog;                 //Detach if already attached.
                Application.logMessageReceived += AutoConsole.GetLog;                 //Attach handler to recieve incoming logs.
            }
            Application.logMessageReceived += ExceptionCallback;

            //Windows
            Architect          = new DependencyArchitecture();
            BuddyData          = new BuddyData();
            Console            = new RunnerConsole();
            CommandConsoleView = new CommandConsoleView();
            Generator          = new Generator();
            Results            = new RunResults();
            Settings           = new Settings();
            Tests     = new TestManifest();
            Tools     = new AdditionalTools();
            Favorites = new Favorites();
            Manifest  = new Manifest();

            Application.runInBackground             = true;
            EditorApplication.playmodeStateChanged += PlaymodeStateChangeUpdates;
            Set();

            m_ShowExtraFields = new AnimBool(true);
            m_ShowExtraFields.valueChanged.AddListener(Repaint);

            //Custom defined Tab order set from Additional Tools?
            List <string>            tabOrderData = FileBroker.GetNonUnityTextResource(FileResource.NexusTabs).Split(AutomationMaster.DELIMITER).ToList().RemoveNullAndEmpty();
            Dictionary <string, int> tabData      = new Dictionary <string, int>();

            for (int t = 0; t < tabOrderData.Count; t++)
            {
                string[] data = tabOrderData[t].Split('$');
                tabData.Add(data.First(), data.Last().ToInt());
            }

            TabDetails tab;

            //Test Manager Tab.
            int priorityId = 0;

            tabData.TryGetValue(Tests.GetType().Name, out priorityId);
            tab          = new TabDetails(Tests, priorityId > 0 ? priorityId : 1);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha1
            };
            tab.Tabs.Add(new SizedTab("⇊", TabSize.Small, 18));
            tab.Tabs.Add(new SizedTab("Tests", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Tests View", TabSize.Large));
            AddWindowTab(tab);

            //Automation Console Window Tab.
            tabData.TryGetValue(Console.GetType().Name, out priorityId);
            tab          = new TabDetails(Console, priorityId > 0 ? priorityId : 2);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha2
            };
            tab.Tabs.Add(new SizedTab("✦", TabSize.Small, 18));
            tab.Tabs.Add(new SizedTab("Console", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Auto Console", TabSize.Large));
            tab.OverrideScroll = true;
            AddWindowTab(tab);

            //Command Console View Tab.
            tabData.TryGetValue(CommandConsoleView.GetType().Name, out priorityId);
            tab          = new TabDetails(CommandConsoleView, priorityId > 0 ? priorityId : 3);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha3
            };
            tab.Tabs.Add(new SizedTab("☊", TabSize.Small, 22));
            tab.Tabs.Add(new SizedTab("Commands", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Commands View", TabSize.Large));
            tab.OverrideScroll = true;
            AddWindowTab(tab);

            //Test Results Window Tab.
            tabData.TryGetValue(Results.GetType().Name, out priorityId);
            tab          = new TabDetails(Results, priorityId > 0 ? priorityId : 4);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha4
            };
            tab.Tabs.Add(new SizedTab("☑", TabSize.Small, TextGreen, 18));
            tab.Tabs.Add(new SizedTab("Results", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Tests Results", TabSize.Large));
            AddWindowTab(tab);

            //Generator Window Tab.
            tabData.TryGetValue(Generator.GetType().Name, out priorityId);
            tab          = new TabDetails(Generator, priorityId > 0 ? priorityId : 5);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha5
            };
            tab.Tabs.Add(new SizedTab("●", TabSize.Small, Color.red, 26));
            tab.Tabs.Add(new SizedTab("Generator", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Generator", TabSize.Large));
            tab.OverrideScroll = true;
            AddWindowTab(tab);

            //Architect Hidden Tab
            tabData.TryGetValue(Architect.GetType().Name, out priorityId);
            tab          = new TabDetails(Architect, priorityId > 0 ? priorityId : 6);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha6
            };
            tab.Tabs.Add(new SizedTab("❖", TabSize.Small, 18));
            tab.Tabs.Add(new SizedTab("Dep Arc", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Dependency", TabSize.Large));
            AddWindowTab(tab);

            //Buddy Data Hidden Tab
            tabData.TryGetValue(BuddyData.GetType().Name, out priorityId);
            tab          = new TabDetails(BuddyData, priorityId > 0 ? priorityId : 7);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha7
            };
            tab.Tabs.Add(new SizedTab("❦", TabSize.Small, 18));
            tab.Tabs.Add(new SizedTab("Buddy", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Buddy Data", TabSize.Large));
            AddWindowTab(tab);

            //Settings Hidden Tab
            tabData.TryGetValue(Settings.GetType().Name, out priorityId);
            tab          = new TabDetails(Settings, priorityId > 0 ? priorityId : 8);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha8
            };
            tab.Tabs.Add(new SizedTab("✎", TabSize.Small, 18));
            tab.Tabs.Add(new SizedTab("Settings", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Settings", TabSize.Large));
            AddWindowTab(tab);

            //Other Tools Tab.
            tab          = new TabDetails(Tools, 0);
            tab.Shortcut = new List <KeyCode> {
                KeyCode.Alpha9
            };
            tab.Tabs.Add(new SizedTab("✙", TabSize.Small, 18));
            tab.Tabs.Add(new SizedTab("Tools", TabSize.Medium));
            tab.Tabs.Add(new SizedTab("Other Tools", TabSize.Large));
            AddWindowTab(tab);

            //Favorites Tab (Reusable Test Runs).
            tab = new TabDetails(Favorites, -1);
            AddWindowTab(tab);

            //Manifest Tab (Current Test Run).
            tab = new TabDetails(Manifest, -1);
            AddWindowTab(tab);

            AddPopup(ScriptableObject.CreateInstance <SimpleAlert>());
            AddPopup(ScriptableObject.CreateInstance <RunTestsAlert>());
            AddPopup(ScriptableObject.CreateInstance <RunClassesAlert>());
            AddPopup(ScriptableObject.CreateInstance <ConsoleMessage>());

            SelectTab(SwatWindows.Find(x => x.PriorityID == 1).Window);              //Sets this as the default landing on load.
        }