Esempio n. 1
0
        protected virtual void  OnGUI()
        {
            if (this.maxSize == this.minSize)
            {
                if (GUI.Button(new Rect(this.position.width - 20F, 0F, 20F, 20F), "X") == true)
                {
                    this.Close();
                }
            }

            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGScenesWindow.FreeAdContent);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5F);

                GUILayout.BeginVertical(GUILayoutOptionPool.MinWidth(200F));
                {
                    GUILayout.Label("Recent Scenes:", GeneralStyles.Title1);
                    this.recentListDrawer.OnGUI(GUILayoutUtility.GetRect(0F, 100F));

                    GUILayout.Label("All Scenes:", GeneralStyles.Title1);
                    this.allListDrawer.OnGUI(GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.ExpandHeightTrue));
                }
                GUILayout.EndVertical();

                GUILayout.Space(2F);

                GUILayout.BeginVertical();
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Build Scenes:", GeneralStyles.Title1);

                        if (HQ.Settings != null)
                        {
                            Utility.content.text = "Load profile";
                            Rect r = GUILayoutUtility.GetRect(Utility.content, "ToolbarDropDown");
                            if (GUI.Button(r, Utility.content, "ToolbarDropDown") == true)
                            {
                                GenericMenu    menu     = new GenericMenu();
                                ScenesSettings settings = HQ.Settings.Get <ScenesSettings>();

                                if (settings.profiles.Count > 0)
                                {
                                    for (int i = 0; i < settings.profiles.Count; i++)
                                    {
                                        menu.AddItem(new GUIContent((i + 1) + " - " + settings.profiles[i].name + " (" + settings.profiles[i].scenes.Count + ")"), false, this.LoadProfile, i);
                                    }
                                }
                                else
                                {
                                    menu.AddItem(new GUIContent("No profile available."), false, null);
                                }

                                menu.DropDown(r);
                            }

                            Utility.content.text = "☰";
                            r = GUILayoutUtility.GetRect(Utility.content, "GV Gizmo DropDown", GUILayoutOptionPool.ExpandWidthFalse);
                            if (GUI.Button(r, Utility.content, "GV Gizmo DropDown") == true)
                            {
                                PopupWindow.Show(r, new OptionPopup(this));
                            }

                            if (this.maxSize == this.minSize)
                            {
                                GUILayout.Space(20F);
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    this.enabledScenesCounter  = 0;
                    this.buildListDrawer.array = EditorBuildSettings.scenes;
                    this.buildListDrawer.OnGUI(GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.ExpandHeightTrue));

                    GUILayout.Space(5F);
                }
                GUILayout.EndVertical();

                GUILayout.Space(5F);
            }
            GUILayout.EndHorizontal();

            if (Event.current.type == EventType.MouseDown)
            {
                if (this.lastClick + Constants.DoubleClickTime > EditorApplication.timeSinceStartup)
                {
                    this.Close();
                }
                this.lastClick = EditorApplication.timeSinceStartup;
                Event.current.Use();
            }

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Esempio n. 2
0
        public override void    OnGUI(Rect r)
        {
            this.currentVars = this.perWindowVars.Get(RowUtility.drawingWindow);

            float yOrigin   = r.y;
            float maxHeight = r.height;

            r.y     += 2F;
            r.height = Constants.SingleLineHeight + 2F;             // Layout is requiring 2 more pixels.
            GUILayout.BeginArea(r);
            {
                GUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                {
                    if (GUILayout.Button("Clear", GeneralStyles.ToolbarButton) == true)
                    {
                        this.Clear();
                    }

                    List <NGServerInstance> servers = ConnectionsManager.Servers;

                    lock (ConnectionsManager.Servers)
                    {
                        EditorGUI.BeginDisabledGroup(this.connectingThread != null || servers.Count == 0);
                        {
                            if (servers.Count == 0)
                            {
                                Utility.content.text = "No server";
                            }
                            else if (servers.Count == 1)
                            {
                                Utility.content.text = "1 server";
                            }
                            else
                            {
                                Utility.content.text = servers.Count + " servers";
                            }

                            Rect r2 = GUILayoutUtility.GetRect(Utility.content, GeneralStyles.ToolbarDropDown);

                            if (GUI.Button(r2, Utility.content, GeneralStyles.ToolbarDropDown) == true)
                            {
                                PopupWindow.Show(new Rect(0F, 16F, 0F, 0F), new ServersSelectorWindow(this));
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                    }

                    EditorGUI.BeginDisabledGroup(this.connectingThread != null || this.IsClientConnected());
                    {
                        if (this.tcpClientProviderNames.Length > 1)
                        {
                            EditorGUI.BeginChangeCheck();
                            this.selectedTcpClientProvider = EditorGUILayout.Popup(this.selectedTcpClientProvider, this.tcpClientProviderNames, GeneralStyles.ToolbarDropDown);
                            if (EditorGUI.EndChangeCheck() == true)
                            {
                                this.console.SaveModules();
                            }
                        }

                        EditorGUI.BeginChangeCheck();
                        this.address = EditorGUILayout.TextField(this.address, GUILayoutOptionPool.MinWidth(50F));
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            this.console.SaveModules();
                        }

                        if (string.IsNullOrEmpty(this.address) == true)
                        {
                            Rect r2 = GUILayoutUtility.GetLastRect();
                            EditorGUI.LabelField(r2, LC.G("RemoteModule_Address"), GeneralStyles.TextFieldPlaceHolder);
                        }

                        string port = this.port.ToString();
                        if (port == "0")
                        {
                            port = string.Empty;
                        }
                        EditorGUI.BeginChangeCheck();
                        port = EditorGUILayout.TextField(port, GUILayoutOptionPool.MaxWidth(40F));
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            try
                            {
                                if (string.IsNullOrEmpty(port) == false)
                                {
                                    this.port = Mathf.Clamp(int.Parse(port), 0, UInt16.MaxValue - 1);
                                }
                                else
                                {
                                    this.port = 0;
                                }
                            }
                            catch
                            {
                                this.port = 0;
                                GUI.FocusControl(null);
                            }

                            this.console.SaveModules();
                        }

                        if ((port == string.Empty || port == "0") && this.port == 0)
                        {
                            Rect r2 = GUILayoutUtility.GetLastRect();
                            EditorGUI.LabelField(r2, LC.G("RemoteModule_Port"), GeneralStyles.TextFieldPlaceHolder);
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    GUILayout.FlexibleSpace();

                    if (this.IsClientConnected() == true)
                    {
                        if (GUILayout.Button(LC.G("RemoteModule_Disconnect"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(80F)) == true)
                        {
                            this.CloseClient();
                        }

                        if (string.IsNullOrEmpty(this.servicesWarning) == false)
                        {
                            Rect r2 = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(16F));

                            r2.x += 4F;
                            r2.y += 2F;
                            GUI.DrawTexture(r2, UtilityResources.WarningIcon);
                            if (Event.current.type == EventType.MouseDown &&
                                r2.Contains(Event.current.mousePosition) == true)
                            {
                                this.showServicesWarning = !this.showServicesWarning;
                                Event.current.Use();
                            }
                        }
                    }
                    else
                    {
                        if (this.connectingThread == null)
                        {
                            if (GUILayout.Button(LC.G("RemoteModule_Connect"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(80F)) == true)
                            {
                                this.Connect(this.address, this.port);
                            }
                        }
                        else
                        {
                            Utility.content.text  = "Connecting";
                            Utility.content.image = GeneralStyles.StatusWheel.image;
                            GUILayout.Label(Utility.content, GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(90F));
                            Utility.content.image = null;
                            this.console.Repaint();

                            if (GUILayout.Button("X", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(16F)) == true)
                            {
                                this.connectingThread.Abort();
                                this.connectingThread.Join(0);
                                this.connectingThread = null;
                            }
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
            r.y     += r.height;
            r.height = Constants.SingleLineHeight;

            if (this.showServicesWarning == true &&
                string.IsNullOrEmpty(this.servicesWarning) == false)
            {
                r.height = Constants.SingleLineHeight + Constants.SingleLineHeight;
                EditorGUI.HelpBox(r, this.servicesWarning, MessageType.Warning);

                Rect r2 = r;
                r2.xMin = r.xMax - 20F;
                r2.yMin = r.yMax - 15F;

                if (GUI.Button(r2, "X") == true)
                {
                    this.showServicesWarning = false;
                }

                r.y     += r.height;
                r.height = Constants.SingleLineHeight;
            }

            r = this.DrawStreamTabs(r);

            if (this.currentVars.workingStream < 0)
            {
                return;
            }

            if (this.IsClientConnected() == true)
            {
                float streamHeight = maxHeight - (r.y - yOrigin) - Constants.SingleLineHeight;
                float xMin         = r.xMin;

                r.xMin = 0F;
                r.y   += streamHeight;

                // Draw CLI before rows.
                r.height = Constants.SingleLineHeight;
                this.DrawCLI(r);
                // Shit of a hack to handle input for completion and its drawing.
                this.parser.PostGUI(r, ref this.command);

                r.xMin   = xMin;
                r.y     -= streamHeight;
                r.height = streamHeight;

                this.streams[this.currentVars.workingStream].OnGUI(r);
                r.y += streamHeight;

                // Redraw again to display in front.
                this.parser.PostGUI(r, ref this.command);
            }
            else
            {
                r.height = maxHeight - (r.y - yOrigin);
                this.streams[this.currentVars.workingStream].OnGUI(r);
            }
        }